Strange problem with Texture

Started by
2 comments, last by viddak 21 years, 11 months ago
I have a little problem with my program. I have a class like this: class board { public: void render(float *t); // Methods board(LPDIRECT3DDEVICE8 g_pd3dDevice); virtual ~board(); // Variable & Objects LPDIRECT3DDEVICE8 mD3D; FONT2DVERTEX *v; LPDIRECT3DTEXTURE8 *m_pTexture; LPDIRECT3DVERTEXBUFFER8 m_pVB; }; the constructor is : board::board(LPDIRECT3DDEVICE8 g_pd3dDevice) { mD3D=g_pd3dDevice; m_pTexture=NULL; DWORD m_dwTexWidth=256; DWORD m_dwTexHeight=256; D3DCAPS8 d3dCaps; mD3D->GetDeviceCaps( &d3dCaps ); // Create a new texture for the font HRESULT hr = mD3D->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, m_pTexture ); if( FAILED(hr) ) exit(0); } It''s compile very well, but at the execution the program exit and the debugor send me : Direct3D8: (ERROR) :Bad parameter passed pTexture. CreateTexture failedFirst-chance exception in 3d.exe (KERNEL32.DLL): 0xC0000005: Access Violation. Direct3D8: (ERROR) :Failure trying to create a texture But when I do this change : board::board(LPDIRECT3DDEVICE8 g_pd3dDevice) { mD3D=g_pd3dDevice; LPDIRECT3DTEXTURE8 pTexture; DWORD m_dwTexWidth=256; DWORD m_dwTexHeight=256; D3DCAPS8 d3dCaps; mD3D->GetDeviceCaps( &d3dCaps ); // Create a new texture for the font HRESULT hr = mD3D->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, &pTexture ); if( FAILED(hr) ) exit(0); } the program work fine. What''s wrong with this strange Trouble. Thanks in advance.
Advertisement
Well, the CreateTexture function asks for a pointer to pointer, witch just basicaly tells it where to store the new texture, because it creates it in memory and increases the rref. by one. dont wory about this, you just had that paramiter wrong.

[ my engine ][ my game ][ my email ]
SPAM
Rate me up.
HRESULT hr = mD3D->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1,
0, D3DFMT_A4R4G4B4,
D3DPOOL_MANAGED, &m_pTexture);

HTH


Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
try D3DFMT_UNKNOWN as the format

[ my engine ][ my game ][ my email ]
SPAM
Rate me up.

This topic is closed to new replies.

Advertisement