Hello I got this piece of code from codesampler.com. what confuses me is this vertex structure and createvertexbuffer functions. Can you guys tell me how does this work? I only put this in my code but I don't know the details of how this codes works. I hope that you will help me with this one guys. Thanks!
Here are the codes that keeps me wondering:
struct Vertex
{
float x, y, z;
float tu, tv;
};
Vertex g_quadVertices[] =
{
{-1.0f, 1.0f, 0.0f, 0.0f,0.0f },
{ 1.0f, 1.0f, 0.0f, 1.0f,0.0f },
{-1.0f,-1.0f, 0.0f, 0.0f,1.0f },
{ 1.0f,-1.0f, 0.0f, 1.0f,1.0f }
};
g_pd3dDevice->CreateVertexBuffer( 4*sizeof(Vertex), D3DUSAGE_WRITEONLY,
D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT,
&Vertex_Buffer, NULL );
void *pVertices = NULL;
Vertex_Buffer->Lock( 0, sizeof(g_quadVertices), (void**)&pVertices, 0 );
memcpy( pVertices, g_quadVertices, sizeof(g_quadVertices) );
Vertex_Buffer->Unlock();
D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 45.0f ),
640.0f / 480.0f, 0.1f, 100.0f );