Sign in to follow this  
SelethD

Possible texture size problem?

Recommended Posts

Im working on an app that needs to load a texture (LPDIRECT3DTEXTURE9) from a .bmp file then display the texture using the sprite (LPD3DXSPRITE) interface. Everything was working fine and I was loading a 512 x 512 pixel image as the texture, until I added a font class using (LPD3DXFONT). Then I noticed that after 40 seconds of the app running, the text (that displayed my mouse coordinates) became scrambled for a few seconds, then returned to normal, this repeated every 40 seconds or so. So I tore apart my font class, and coundnt find anything wrong, then I tried drawing the texture to the screen using a smaller RECT not 512x512 but 10x10. Sill the text was scrambled. Finally the only thing I found that made it stop screwing up was when my .bmp was loaded with the dimensions 256x512. So is there a max size to .bmp images used as textures? Or do I have some deeper problem that I am unaware of? Any help?

Share this post


Link to post
Share on other sites
If my hardware is unable to handle a 512 x 512 pixel texture, is directx supposed to let me know? Like fail in the call to load the texture? Below is my source for loading the texture, but it never tells me anything is wrong.

/source
if( FAILED( D3DXCreateTextureFromFile(g_pd3dDevice, "clock.bmp", &g_pClockTexture ) ) )
{
MessageBox(NULL, "Could not find clock.jpg", "Clock Practice.exe", MB_OK);
return E_FAIL;
}


Share this post


Link to post
Share on other sites
Quote:
Original post by POLSKASH
The max size is determined by your hardware. Your card may not support 512x512 textures. There is no set limit just for .bmp files though.
Actually, bitmaps can only store up to 65535x65535 images (The width and heights are WORDs)

Quote:
Original post by SelethD
If my hardware is unable to handle a 512 x 512 pixel texture, is directx supposed to let me know? Like fail in the call to load the texture?
Yes, that code should fail if your card doesn't support that size of textures. Although even my old Voodoo 2 supported 512x512 textures.
You can look at the MaxTextureWidth and MaxTextureHeight members of the D3DCAPS9 structure (From IDirect3D9::GetDeviceCaps()) to determine the maximum size for your textures.

The strange thing about your problem is that it runs fine for a short time. Have you noticied any problems with other textures? Does the same thing happen if you use the reference rasterizer? What about specifying a different memory pool, using D3DXCreateTextureFromFileEx() (Try system memory - only for debugging mind, it'll be slower). It's possible that your texture is getting destroyed while in video memory, but I don't know why that would happen.

Share this post


Link to post
Share on other sites
SelethD,

How are you drawing your fonts? Are you passing the Text::DrawText function a pointer to your sprite? if so, you need to make sure your sprite is inside the Begin() / End() block - i was using a threading system that made it possible (but unlikely) for this to occurr and it would occasionally cause problems until i tracked this down.

Aface

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this