Sign in to follow this  

Possible power of 2 annoyances?

Recommended Posts

I'm getting fed up with this one. I have a window of 640*480, i've created a test texture of 512*512 and get this: screenie same with any texture dimensions really. i've bordered it in red since even if i create a 1024*1024 texture with a 640*480 graphic in the top left it still skews out of shape in this way to create the sprite i've tried both
HRESULT Texture=D3DXCreateTextureFromFile(d3dDevice, textureFilename, &m_texture);

HRESULT Texture=D3DXCreateTextureFromFileEx(d3dDevice,textureFilename,D3DX_DEFAULT_NONPOW2, 
			D3DCOLOR_XRGB(255, 0, 255), NULL, NULL, &m_texture);

and it's the exact same both times. initially i was just using a 640*480 image which i'd resized to 1024*512 to keep it power of 2, but when that didn't work i tried a power of 2 square just to test it out... surely if a texture already is the power of 2 then this should be something else? cos i can't think what it can be :-/ i'll put up some more code if it's needed, but it's just very basically sprite loading and drawing to a position of 0,0

Share this post

Link to post
Share on other sites
If you have requested in Win32 that the window size is X by Y, this doesn't mean that the client area you are drawing in is X by y because you have the window borders. If you want to know how big to make a texture to make it fit perfectly to the client area, call GetClientRect() to find out the dimensions. What is likely happening here is that the aspect ration of the things being drawn is squashed.

It sounds like you are squashing or stretching a texture that is larger or smaller than the back buffer you are drawing too into the back buffer, thus causing distortion.

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