I am trying to apply textures to a cube in DirectX 9, so far I have made it to draw it with vertex colors and light as well as with a material and light, but now with the texture I get a blank cube, in my application it renders white, in PIX it renders black. I know the texture is loaded correctly as I can see it from PIX and as I have made sure I can detect any error the loading function may return (through the HResult
) Edit: it was the same image on a surface, but with a breakpoint I see the texture has an address, and thus exists, whether it is right or not I cannot tell, should I be able to see it in PIX? I also know that I've got the UV's right as they appear right in PIX as I select the vertices, and they are indeed in clockwise order (at least one face is, but that should be enough to draw something).
I have removed the light code so the code is:
pd3dDevice->BeginScene();
setMatrices();
pd3dDevice->SetTexture(0, tex);
//pd3dDevice->SetRenderState(D3DRS_WRAP0, D3DWRAPCOORD_0);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
//pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
// select which vertex format we are using
pd3dDevice->SetFVF(CUSTOMFVF);
// select the vertex buffer to display
pd3dDevice->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
pd3dDevice->SetIndices(i_buffer);
// copy the vertex buffer to the back buffer
pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
0,
0,
8,
0,
12);
pd3dDevice->EndScene();
setMatrices()
does the transformations, it worked well before I added lights so it should be fine. I commented out the call to the light handling function, so it shouldn't meddle with the current code.
I notice that if I remove pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
I get a black unshaded but transformed cube, which to me seems reasonable.
The commented out lines of code, I have tried with and without them, they do not seem to effect the situation as far as I can see. I have tried a couple more render state settings but no luck - after all they were mostly educated guesses and not something that was supposed to work.
The FVF has XYZ, normal vector and UV.
Again, PIX shows the cube as black, I have it white in the application. Perhaps there's a hint there?
Thank you for any attempt to help out, much obliged.