1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Konstruktor - Initialisierungen
CSprite::CSprite(void)
{
m_lpSprite = NULL;
m_lpTexture = NULL;
}
// Destructor - freigeben der Objekte
CSprite::~CSprite(void)
{
if(NULL != m_lpSprite)
{
m_lpSprite->Release();
m_lpSprite = NULL;
}
if(NULL != m_lpTexture)
{
m_lpTexture->Release();
m_lpTexture = NULL;
}
}
// Position setzen
void CSprite::SetPosition(float x,float y,float z)
{
m_vPosition.x = 10;
m_vPosition.y = 10;
m_vPosition.z = 0;
}
void CSprite::Create(LPDIRECT3DDEVICE9 lpDevice, LPCWSTR lpFileName)
{
m_lpDevice = lpDevice;
// Sprite anlegen
D3DXCreateSprite(m_lpDevice,&m_lpSprite);
// Inforationen über die Textur holen
D3DXIMAGE_INFO ImgInfo;
D3DXGetImageInfoFromFileW(lpFileName,&ImgInfo);
// Textur anlegen
D3DXCreateTextureFromFileExW(m_lpDevice,
lpFileName,
ImgInfo.Width,
ImgInfo.Height,
1,0,
D3DFMT_UNKNOWN,
D3DPOOL_MANAGED,
D3DX_FILTER_NONE,
D3DX_FILTER_NONE,
0,0,0,
&m_lpTexture);
// Breite und Höhe speichern
m_Width = ImgInfo.Width;
m_Height = ImgInfo.Height;
}
void CSprite::Draw(void)
{
m_lpSprite->Draw(m_lpTexture,
NULL,
&D3DXVECTOR3(1.0f,1.0f,1.0f),
&m_vPosition,
0xFFFFFFAF);
}
|