Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

anotherfantasy

Strange error in declaring textures

This topic is 5954 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have this Maze class class CMaze: public CGrid { public: LPDIRECT3DVERTEXBUFFER8 wallpic; // Buffer to hold vertices LPDIRECT3DTEXTURE8 pTexture; // Our texture HRESULT Init( HWND *hwnd, LPDIRECT3DDEVICE8 d3ddevice ); HRESULT Draw( LPDIRECT3DDEVICE8 d3ddevice ); HRESULT Update( Keys *key, DWORD time ); HRESULT DeInit(); }; clearly, i declared a texture. however in HRESULT CMaze::Init( HWND *hwnd, LPDIRECT3DDEVICE8 d3ddevice) { LPDIRECT3DTEXTURE8 pTexture=NULL; // Use D3DX to create a texture from a file based image if( FAILED( D3DXCreateTextureFromFile( d3ddevice, "banana.bmp", &pTexture ) ) ) return E_FAIL; ........................ i get an error if i don''t re-declare pTexture. if i take out that line, i get the error "undeclared var pTexture" even though it is a member of the class.

Share this post


Link to post
Share on other sites
Advertisement
oh yeah. the code compiles, when when i run it, there is no texture on the buffer. i''m doing the testing with the texture bana texture tutorial in the SDK. the cylinder spins and everything but there''s no texture.

Share this post


Link to post
Share on other sites
Yeh you cant redeclare pTexture in the Init function as you are loading the texture into the temporary var and not the member var. I dont know why it doesnt recognize the member var, thats a weird one, are you sure you are including the dx libraries in the header and not the cpp file, could be a problem,

if all else fails, try this:

HRESULT CMaze::Init( HWND *hwnd, LPDIRECT3DDEVICE8 d3ddevice)
{
LPDIRECT3DTEXTURE8 pNew=NULL;
// Use D3DX to create a texture from a file based image
if( FAILED( D3DXCreateTextureFromFile( d3ddevice, "banana.bmp",
&pNew ) ) )
return E_FAIL;

CMaze:Texture = pNew;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!