I'm hoping i can pick someones brain for this without having to post a whole whack of code.
I've got a 3D enviroment set up and i can display billboards and Meshs to it just fine. The textures come out exactly right. But i have need to display certain things on screen-relative coords (like my mouse cursor) so i used these flags D3DFVF_XYZRHW | D3DFVF_TEX1 when creating my vertex buffer, which looks like this:
Code:
struct vertex
{
float x, y, z, rhw;
float u, v;
};
vertex target[4];
IDirect3DVertexBuffer8 * g_VBuffer;
//displayed like this:
//lock up VBuffer and memcopy it on in
unsigned char *vb_vertices;
if (FAILED( g_VBuffer->Lock(0, 0, &vb_vertices, 0) ))
{
MessageBox(hWnd, "Lock() failed!", "Function Error", MB_OK);
return E_FAIL;
}
memcpy(vb_vertices, target, sizeof(target));
g_VBuffer->Unlock();
g_pDevice->SetVertexShader(D3D_CUSTOMVERTEX);
g_pDevice->SetStreamSource(0, g_VBuffer, sizeof(vertex));
g_pDevice->SetTexture(0, pTexture);
g_pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
The Buffer appears exactly wher it should and the texture is also displayed... but! Its all grey (which is the colour of my text incidentally). I know the texture is there because i alpha blended out the background colours on it and they disapeared leaving only a grey mouse-cursor shape without any of the textures colours on it.
Oh, in case its relevant i've got the following RenderStates set:
Code:
//*** DISPLAY TYPE STUFF ***
//Z-Level? Yes. Of course.
g_pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
//Noramlize Normals?
g_pDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
//Cull Counter-Clockwise
g_pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
//*** LIGHTING ***
//Set lighting OFF
g_pDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
//*** TEXTURE HANDLING ***
//Texture stretching filter types (Option for D3DTEXF_LINEAR???)
g_pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT );
g_pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT );
//Dither textures?
g_pDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
//Turned off because we dont use Coloured Vertexs
g_pDevice->SetRenderState( D3DRS_COLORVERTEX, FALSE );
//Alpha Blending used in some textures for CVertexBuffer calls
g_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
//*** PIXEL HANDLING ***
//Defines the method of determining pixel color
g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
//Take color only from texture instead of vertex colors (or which we have none)
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
//Defines the method of determining pixel alpha
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
//Alpha value for each pixel comes from the textures alpha value
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
//Source/Destination blending
g_pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
g_pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );