Strange problem with sprites

Started by
4 comments, last by georgiano 14 years, 6 months ago
Hi there, I have the following strange problem. I create a window 800x600 and IDirect3dDevice9 with resolution 1280x1024. I try loading a 1024x768 bitmap using D3DXCreateTextureFromFile to create the texture then I create a sprite and draw it. But the image is drawn flattened from the side. Hope someone will figure it out.
Advertisement
You sure you got your texture coordinates there right?
Your description (i wish you showed a picture) sounds like its being clamped.
Why would I need texture coordinates when I am using the texture to draw ID3DXSprite?


After loading the texture I used GetLevelDesc to see what the width and height of the texture are and although the image is 1024x768 the texture was created 1024x1024. I can't figure out why this is happening but I found the solution. I just use D3DXCreateTextureFromFileEx and specify 1024 for the width and 768 for the height and everythig else is left with the default values.
Usually textures should be powers-of-two only. When the texture of size 1024*768 is loaded it's probably having some extra blank space added to make it up to 1024*1024, which is why it isn't drawing at the correct size. You should aim to always create textures in power-of-two sizes (16,32,64,128,256,512,1024, etc)). They don't have to be square but the length of each edge should be a power of two.
That definitely makes sense.

This topic is closed to new replies.

Advertisement