Sign in to follow this  

Images size changes using managed Direct3D

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

This topic is 4841 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.

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