Original Post
Hi, I search a lot in the MSDN and didnt find anything about that. I was creating 3d for long time with OpenGL. Now for school I have to make a demo in Directx. So for loading texture I'm using this : Thats work fine for texture from file. Now, I want to use my own texture format, that I use in many of my engines :P This file contain Base texture, detail texture, specular texture, normal map, etc. I have my own loader for this, and for each layer I have the following input : So with that I can create easily a texture in opengl. But HOW in directx from this buffer??? The buffer is just an array of all color RGB or RGBA. What I did first is to try this function : Using this function the result it White, thats mean NULL, didnt work ;) So, I found this on MSDN : Hum, this create me a texture, but empty (black) Now, how to put my buffer in it then it will automaticly create my Mipmap or there is a function to create a texture from my buffer?? thanks!
D3DXCreateTextureFromFileEx(
D3DDevice,
"main/textures/textureTest.tga",
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DX_DEFAULT,
0,
D3DFMT_UNKNOWN,
D3DPOOL_MANAGED,
D3DX_DEFAULT,
D3DX_DEFAULT,
0,
NULL,
NULL,
&Texture);
unsigned char *Buffer
int Width
int Height
int BytePerPixel
D3DXCreateTextureFromFileInMemoryEx(
D3DDevice,
Buffer,
BytePerPixel*Width*Height,
Width,
Height,
D3DX_DEFAULT,
0,
(BytePerPixel == 3) ? D3DFMT_R8G8B8 : D3DFMT_A8B8G8R8,
D3DPOOL_MANAGED,
D3DX_DEFAULT,
D3DX_DEFAULT,
0,
NULL,
NULL,
&Texture);
D3DXCreateTexture(
D3DDevice,
Width,
Height,
D3DX_DEFAULT,
0,
(BytePerPixel == 3) ? D3DFMT_R8G8B8 : D3DFMT_A8B8G8R8,
D3DPOOL_MANAGED,
&Texture);