Sign in to follow this  
mk1x86

D3DXCreateTextureFromFileEx

Recommended Posts

For my GUI I'm using bitmaps that are not power of 2 size. Actually the engine shall use pow2-textures but to save space on my hard disk I'd like to save my bitmaps in any size I like. D3DXCreateTextureFromFileEx does a good job in resizing the bitmap to the nearest power of 2 height/width but it stretches my bitmap. I'd like to have a black (transparent if required) bitmap with power of 2 size and my original bitmap blitted in the top left corner (without resizing the pixel of the original bitmap). Any ideas how to do that?

Share this post


Link to post
Share on other sites
Set the Filter parameter to D3DX_FILTER_NONE. This will get you black/transparent black in the unused parts of the texture. Pass a pointer to an info structure to the load call. It will return the texture size of the texture on disk (ie: 100x90). You can then call GetLevelDesc(0, ...) on the texture to get the size of the texture created (128x128). These two bits of info can be used to generate your UV coordinates.

You really should put all these small textures onto a single texture page (or a few pages), allowing you to render many objects in one draw call.

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