[D3D] Write to Texture
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!
Look at ID3DXSprite. It allows you to specify a source rect to draw from so only what you want shown from your source texture will be displayed.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement