Sign in to follow this  
XVincentX

Load a texture without d3dx

Recommended Posts

IDirect3DDevice9::CreateTexture() or D3DXCreateTexture() to create the texture. IDirect3DTexture9::LockRect to get a pointer to update the data, then IDirect3DTexture9::UnlockRect when you're done.

You can get data to put in the texture however you want, such as libPNG, or your own loading code for a particular format (TGA is pretty simple), or having Win32 load a BMP and copying that data over, or generating a texture in code.

Share this post


Link to post
Share on other sites
You can also create the texture, retrieve the underlying IDirect3DSurface9 interface (GetSurfaceLevel), then get the associated GDI device context (GetDC) and use GDI's BitBlt or StretchBlt to copy from another GDI DC to initialize the texture.

While BitBlt/StretchBlt will do color-conversion to the target format, it doesn't know anything about alpha channels (or at least didn't the last time I wrote a texture loader some 5 years ago).

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