Hello,
for some tests i used D3DX11CreateShaderResourceViewFromFile and everything worked fine.
In the future i want to pack all my images in a container format and preload that file.
Now i want to preload all my images with stb_image.h and use them in D3D11.
MSDN says i can use D3DX11CreateShaderResourceViewFromMemory to do this.
What is the proper way to create a texture from a unsigned char* and use them ?
Loading image data:
object.imageData = stbi_load(imagePath.c_str(), &object.width, &object.height, &object.bit, STBI_rgb_alpha);
Creating texture from image data:
result = D3DX11CreateShaderResourceViewFromMemory(m_pDevice,
(void*)object.imageData,
0,
NULL,
NULL,
&object.texture,
NULL);
I have some problems with the image data size.
I tried various calculations, but even with result = S_OK it's crashing.