Original Post
Basically, I am drawing 3 triangles on the screen. As I understand it, the vertices are transformed already, so they should be in a "stuck" place in the 3d world. When I move the camera, however, the triangles actually move position. I can't figure out why this is happening. Thanks for any help! edit: ok, I see that the vertices being transformed means that they are in 2d screen space. How do I get them to be in 3d? I'm a little confused ;) Here's the code i'm using: [Edited by - ktuluorion on October 8, 2006 3:36:35 PM]
CUSTOMVERTEX vertices[] =
{
{ 5.0f, 20.0f, 0.5f,0xffff0000, }, // x, y, z, rhw, color
{ 10.0f, 20.0f, -5.0f, 0xffff0000, },
{ 5.0f, 20.0f, -5.0f, 0xffff0000, },
{ 5.0f, 5.0f, 0.5f, 0xff00ff00, }, // x, y, z, rhw, color
{ 10.0f, 50.0f, 0.5f, 0xff00ff00, },
{ 10.0f, 10.0f, 0.5f, 0xff00ff00, },
{ 25.0f, 25.0f, 0.5f, 0xff00ffff, },
{ 5.0f, 25.0f, 0.5f, 0xff00ffff, },
{ 5.0f, 5.0f, 0.5f, 0xff00ffff, }, // x, y, z, rhw, color
};
if( FAILED( d3ddevice->CreateVertexBuffer( sizeof(vertices),
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &batch, NULL ) ) )
return 0;
VOID* pVertices;
if( FAILED( batch->Lock( 0, sizeof(vertices), (void**)&pVertices, 0 ) ) )
return E_FAIL;
memcpy( pVertices, vertices, sizeof(vertices) );
batch->Unlock();
d3ddevice->SetRenderState(D3DRS_LIGHTING,
FALSE);
d3ddevice->SetStreamSource( 0, batch, 0,sizeof(CUSTOMVERTEX) );
d3ddevice->SetFVF( D3DFVF_CUSTOMVERTEX );
d3ddevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 3);