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);
Problems displaying triangles properly
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]
Your comments suggest you're using transformed and lit (which are specified in screen-space/2D) but your code suggests regular 3D.
e.g:
{ 5.0f, 20.0f, 0.5f,0xffff0000, }, // x, y, z, rhw, color
Your comment lists 5 fields, but your code is only providing 4 [smile]
What is D3DFVF_CUSTOMVERTEX defined as? Does it use D3DFVF_XYZRHW or D3DFVF_XYZ?
Cheers,
Jack
e.g:
{ 5.0f, 20.0f, 0.5f,0xffff0000, }, // x, y, z, rhw, color
Your comment lists 5 fields, but your code is only providing 4 [smile]
What is D3DFVF_CUSTOMVERTEX defined as? Does it use D3DFVF_XYZRHW or D3DFVF_XYZ?
Cheers,
Jack
How come each vertex only take four parameters? If they're supposed to be transformed, where's RHW?
Edit: Blasted "high speed" internet.
Edit: Blasted "high speed" internet.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement