case 1:
I create the texture by
D3DXCreateTexture(device, width, height, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture)
and update the texture with white color.
D3DLOCKED_RECT lr;
HRESULT hr = texture->LockRect(0, &lr, NULL, 0);
ConvertRGB2RGBA(width, height, pixels, stride, (unsigned char*)(lr.pBits), lr.Pitch);
texture->UnlockRect(0);
the render result shows as:
What I want is pure white on the surface.
The z value of all the vertexes equals to 0.0f.
case 2:
If I create the texture by
D3DXCreateTextureFromFile(device, "e:\\test.bmp", &texture);
and do not update the texture, it shows absolutly correct.
case 3:
If I create the texture from file as case 2, and update the texture as case 1, the result is incorrect, there is test.bmp content remains slightly.
conclusion:
There must be something wrong with updating texture. What's wrong???
SOLVED!!!
Change the levels param to 1, then it works.
D3DXCreateTexture(device, width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture)
Change the levels param to 1, then it works.
Congratulations. When the mipmap level argument of D3DXCreateTexture is set to 0, full mipmapped texture will be created. If you want to use mipmaps, your function ConvertRGB2RGBA should cover not only the top level texture, but also lower level textures.