• Advertisement
Sign in to follow this  

Possible power of 2 annoyances?

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

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);





and
HRESULT Texture=D3DXCreateTextureFromFileEx(d3dDevice,textureFilename,D3DX_DEFAULT_NONPOW2, 
			D3DX_DEFAULT_NONPOW2, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 
			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
Advertisement
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
ah, i remember using GetClientRect in another directx app i made a year or two ago, that could be it indeed!

edit: you're the man, rated

Share this post


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

  • Advertisement