Original Post
Right, I have just started delving into Direct 3D and I have a lot of it ahead of me but at the moment I am very new.
I have Special Effects game programming for DirectX 8 and have been looking at some of the samples. One fo them very simply rotates a triangle. I am trying to add another vertex to the triangle to make it into a quanrangle but I still get a triangle. The relevant bit of code (I think) is:
struct CUSTOMVERTEX
{
FLOAT x, y, z; // The untransformed, 3D position for the vertex
DWORD color; // The vertex color
};
HRESULT InitGeometry()
{
// Initialize three vertices for rendering a triangle
CUSTOMVERTEX g_Vertices[] =
{
{ -1.0f,-1.0f, 0.0f, 0xffff0000, },
{ 1.0f,-1.0f, 0.0f, 0xff0000ff, },
{ 0.0f, 1.0f, 0.0f, 0xffffffff, },
{ 2.0f, 1.0f, 0.0f, 0xffffffff, },
};
// Create the vertex buffer.
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &g_pVB ) ) )
{
return E_FAIL;
}
// Fill the vertex buffer.
VOID* pVertices;
if( FAILED( g_pVB->Lock( 0, sizeof(g_Vertices), (BYTE**)&pVertices, 0 ) ) )
return E_FAIL;
memcpy( pVertices, g_Vertices, sizeof(g_Vertices) );
g_pVB->Unlock();
return S_OK;
}
I added the extra vertex and changed the size of the buffer that is creted from 3*sizeof(CUSTOMVERTEX) to 4.
Why am I still getting a triangle?
Thanks for your help.
Giles Roadnight
giles.roadnight.name