Jump to content
  • Advertisement
Sign in to follow this  
Uphoreum

OpenGL [D3D] Write to Texture

This topic is 3554 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 want to add "padding" to my textures to compensate for any that don't have power-of-2 dimensions. I did this same thing with SDL/OpenGL by copying the original surface to a larger surface and cropping out the "padding" when drawing the texture. So, I have two questions: #1: Is this the best way to deal with non-power-of-2 textures? (These are for sprites by the way, not to be applied to meshes) #2: If so, how can I do the above with Direct3D? (I'm using D3DXCreateTextureFromFileEx to load the textures) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
1. The best thing to do is make sure your images are power-of-2 sizes to start with.
2. Yup. Just pass D3DX_FILTER_NONE as the Filter parameter to D3DXCreateTextureFromFileEx to have the image not resized, and loaded into the top left of the image. You'll need to pass non-NULL for the pSrcInfo parameter, so you can tell the original size of the image, and then use GetLevelDesc() on the created texture to get the created size and work out the texture coordinates to use.

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!