Jump to content
  • Advertisement
Sign in to follow this  
Flyrun

Textures, SPRITES, etc...

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

When I load a textured bitmap, it changes size when I draw it to the backbuffer. I don't understand. Does anyone know anythinga about this? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
If the images dimensions are not powers of two (256x256, 512x512, etc.), then DX will resize it to the next closest power of two. This will cause your image to stretch in one or both dimensions.

Share this post


Link to post
Share on other sites
I will defiently try that. Here is some of the code that might help you understand the problem better.

//set Direct3D presentation parameters
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = (!fullscreen);
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_R5G6B5;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight= height;
d3dpp.hDeviceWindow = hWnd;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

....

//creat the new texture by loading a btimap image file
D3DXCreateTextureFromFileEx(
d3ddev, //Direct 3d device object
filename, //bitmap filename
info.Width, //bitmap image width
info.Height, //bitmap image height
1, //mip-map levles (1 for no chain)
D3DPOOL_DEFAULT, //the type of surface (standard)
D3DFMT_UNKNOWN, //surface format (default)
D3DPOOL_DEFAULT, //memory class for the texture
D3DX_DEFAULT, //image filter
D3DX_DEFAULT, //mip filter
transcolor, //color key for transparency
&info, //bitmap file info (from loaded file)
NULL, //color palette
&texture); //destination texture

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks fellas. I changed the dimensions of the bitmap and it totally worked! like you had mentioned, DirectX must have been streteching the bitmap out since it wasn't a power of 2 bitmap!

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!