Sign in to follow this  
rmetzger

Texture size in screen coordinates?

Recommended Posts

Hello.

I am drawing a 40 x 40 pixel sprite in Direct3D9 using LPD3DXSPRITE. I am also drawing a square on the screen using a line strip that is also 40 x 40 pixels. The two are not the same size on screen though. I have not changed the world matrix or set up a camera or anything like that. All I have done is draw these two things. The are both drawn in screen coordinates. Why are they not the same size and how do I get them to be the same size?

Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
Be careful if you use D3DXCreateTextureFromFile/D3DXCreateTextureFromFileEx, as that function by default will scale to the next power-of-2 texture size.


Ok, that makes sense. It did look around 64 pixels on the screen and as if it had been stretched. I forgot about the power-of-2 thing. Is there a way to easily make the texture 40 pixels on the screen?

Share this post


Link to post
Share on other sites
If you want to load a texture that's not power of two, use D3DXCreateTextureFromFileEx and for the width and height parameter use D3DX_DEFAULT_NONPOW2. I'm pretty sure if you use the Ex function, simply specifying 40 for the width and height will work too. I though it only rounded up the size to power of two when you used the D3DXCreateTextureFromFile function.

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