Jump to content
  • Advertisement
Sign in to follow this  
georgiano

Strange problem with sprites

This topic is 3263 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

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.

Share this post


Link to post
Share on other sites
Advertisement
You sure you got your texture coordinates there right?
Your description (i wish you showed a picture) sounds like its being clamped.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!