Vertex Buffers
I am trying to make a function that returns a vertex buffer when you pass an array full of vertex info. WHen i call trhe function and try to render the vb nothing happens.
here is the code
LPDIRECT3DVERTEXBUFFER8 POLY::CreateVertexBuffer( int numVerts, CUSTOMVERTEX * cstm)
{
LPDIRECT3DVERTEXBUFFER8 VtxB;
if( FAILED( D3D_DEVICE->CreateVertexBuffer( numVerts*sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &VtxB ) ) )
{
MessageBox(hwnd,"Couldn''t create vb","Error",MB_OK | MB_ICONERROR);
return NULL ;
}
// Fill the vertex buffer.
VOID* pVertices;
if( FAILED( VtxB->Lock( 0, sizeof(cstm), (BYTE**)&pVertices, 0 ) ) )
{
MessageBox(hwnd,"Couldn''t create vb","Error",MB_OK | MB_ICONERROR);
return NULL ;
}
memcpy( pVertices, cstm, sizeof(cstm) );
VtxB->Unlock();
//MessageBox(hwnd,"vb created successfully","Error",MB_OK | MB_ICONERROR);
return VtxB ;
}
here is how i call the function
fff=d3d_obj.poly_obj.CreateVertexBuffer(3,verts);
does n e 1 see what the prob could be.
"Computers are only as smart as their programers"
My Site-> Still working on it.
quote:Original post by tHiSiSbOb
memcpy( pVertices, cstm, sizeof(cstm) );
should be:
memcpy(pVertices, cstm, (CUSTOMVERTEX)* numVerts);</pre>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement