?? objecttexture.cpp
字號:
// ObjectTexture.cpp: implementation of the CObjectTexture class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MapEdit.h"
#include "ObjectTexture.h"
#include "GlobalDefs.h"
#include <D3dx9tex.h>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CObjectTexture::CObjectTexture()
{
m_pTexture = NULL;
m_nWidth = 0;
m_nHeight = 0;
}
CObjectTexture::~CObjectTexture()
{
Release();
}
// Create texture ////////////////////////////////////////////////////
BOOL CObjectTexture::Create(LPDIRECT3DDEVICE9 &pDevice, LPCTSTR inFileName, DWORD inColorKey)
{
D3DXIMAGE_INFO imageInfo;
memset(&imageInfo, 0, sizeof(imageInfo));
// Release texture first.
Release();
// Create texture
D3DXCreateTextureFromFileEx(pDevice, inFileName, D3DX_DEFAULT, D3DX_DEFAULT, 0, 0,
D3DFMT_UNKNOWN, D3DPOOL_MANAGED,D3DX_DEFAULT, D3DX_DEFAULT,
inColorKey, &imageInfo, NULL, &m_pTexture);
if (NULL == m_pTexture)
{
return FALSE;
}
// Get the image infos
m_nWidth = imageInfo.Width;
m_nHeight = imageInfo.Height;
return TRUE;
}
// Release ///////////////////////////////////////////////////////////
void CObjectTexture::Release()
{
if (NULL != m_pTexture)
{
SAFE_RELEASE(m_pTexture);
}
}
// Get the size of texture ///////////////////////////////////////////
int CObjectTexture::GetHeight()
{
return m_nHeight;
}
int CObjectTexture::GetWidth()
{
return m_nWidth;
}
// Get texture //////////////////////////////////////////////////////
LPDIRECT3DTEXTURE9 CObjectTexture::GetTexture()
{
return m_pTexture;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -