Sign in to follow this  
Uphoreum

OpenGL [D3D] Write to Texture

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

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