Jump to content
  • Advertisement


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


having trouble loading textures

This topic is 6187 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 did it before, and I'm pretty sure I'm using the same code as before but now it isn't working. My graphics class is based on the code from this article but I don't think that matters http://www.gamasutra.com/features/20010629/geczy_codelisting.htm I am using the FAILED macro and debugging and so I've traced the problem down to the function that gets the texture. It doesn't FAIL but it doesn't do anything to the pointer either, if leaves it with whatever value it has going in. Here are the parts that are relevant, I'm only leaving out parts that I'm sure don't matter. I have the headers I need included too
class Graphics //in the .h

	Graphics(HWND hwnd);
	IDirect3D8* pD3D;
	IDirect3DDevice8* pd3dDevice;
	D3DCAPS8 *pd3dcaps;
	ID3DXSprite* pd3dxSprite;
	map<string,IDirect3DTexture8*> textures;
	IDirect3DTexture8* LoadTexture(char* filename);

Graphics::Graphics(HWND hWnd)
	pd3dDevice = NULL;
	pd3dxSprite = NULL;
	pd3dcaps = new D3DCAPS8();
	pD3D = Direct3DCreate8( D3D_SDK_VERSION );
	// Get the current desktop display mode

	pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT,&d3ddm );
	// Parameters for the D3DDevice.

	// This sets the video format to match the current desktop display.

	// Check docs for other options you can set here

	ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferWidth = d3ddm.Width;
	d3dpp.BackBufferHeight = d3ddm.Height;
	d3dpp.BackBufferFormat = d3ddm.Format;

	// Create the Direct3D device, using the default adapter (most systems 

	// only have one, unless they have multiple graphics hardware cards

	// installed). See SDK for more details on other options here.

//turn REF into HAL to get hardware back

if( FAILED	(pD3D->CreateDevice( D3DADAPTER_DEFAULT, 
&d3dpp, &pd3dDevice )
)){ string s = "error"; }
	// Device state would normally be set here

	//make the sprite thing

if( FAILED	(D3DXCreateSprite(pd3dDevice,&pd3dxSprite)))
{	string s = "error";
//I am using a.bmp to eliminate the possibility of spelling errors


//LPDIRECT3DTEXTURE8 is the same as the texture type

//I have all the ugly stuff cleaned up in my better version

LPDIRECT3DTEXTURE8 Graphics::LoadTexture(char *filename)
     LPDIRECT3DTEXTURE8 pd3dTexture = NULL;
     // Set black as our source color key

     D3DCOLOR colorkey = 0xFF000000;
     // The D3DX function will fill in the following image 

//info for us  

     D3DXIMAGE_INFO SrcInfo; //! this actually works btw

     // Load image from file 

	 if( FAILED(
     D3DXCreateTextureFromFileEx( pd3dDevice, filename,
 0, 0, 1, 0, 
          D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 
          colorkey, &SrcInfo , NULL, &pd3dTexture)
{string s = "error";}
return pd3dTexture;
so what happens is I call D3DXCreateTextureFromFileEx and I don't get an error, if I did s would initialize and I would see that while debugging. The odd thing is that ScrInfo gets filled in properly with the height and width and other stuff so apparently it is reading the file. It just isn't setting my pointer to it. Other than that the rest of my program is working perfectly. Edited by - Glak on August 12, 2001 4:53:42 AM

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
oh actually it does fail in the attempt to load the texture, dumb MSVC++ bug hid it. So does anyone know what my problem is?

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I remembered how to fix it! No bug, I just have to set my computer''s color depth to 16 bit. No idea why, maybe because I have a voodoo3.

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!