Jump to content
  • Advertisement
Sign in to follow this  
Arik

Images size changes using managed Direct3D

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

Hello I'm trying to create a 2D game with Direct3D 9 using C#. I've got Sprite and Texture variables, and I've loaded a texture to use. Now, whenever I call the Draw or the Draw2D methods in the Sprite class, it draws the texture images with different size; I've tried to load a 800*600 image, and it chaned it to 1024*1024! I've tried to load another image, and it changed it to 256*256.. Why is this happenning? How can I show the images in their original size? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Arik, this occurs because the TextureLoader helper in Managed DirectX converts any textures that aren't already powers of twos in dimension into a texture that is in powers of two in dimension.

Share this post


Link to post
Share on other sites
There should be another override to the FromFile function that will let you specify what size you want your texture to be. What video card do you have? Some older cards can hansle non-power-of-2 numbers.

Share this post


Link to post
Share on other sites
Thanks for the replies
Well, I've tried to define the texture's size in the FromFile method, but it didn't help...

My video card is Radeon 9600.. I guess it can handle non power of 2 numbers..
How can I show code in this forum?
I'll post my code, and I guess it'll be easier for you to help..

Share this post


Link to post
Share on other sites
In all fairness, even if your card can cope with non-binary-size textures, other people's may not.

Your best bet is to just save all the images as the next power of two in both dimensions. When you import it, just blit it to a surface that's the correct size; the rest of the texture will just be truncated. It'll take up a bit more memory space, but it'll solve the problem, and it'll work on anyone's card :)

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!