p_dx_Device is a object created by the DirectX function Direct3DCreate9::CreateDevice and is populated properly as well as passed properly.
DrawIndexedPrimitive(
D3DPRIMITIVETYPE Type,
INT BaseVertexIndex,
UINT MinIndex,
UINT NumVertices,
UINT StartIndex,
UINT PrimitiveCount
);
Below is the code where the values are stored for the Vertexs and Indices:
int LoadIndicesAndVerts(HWND han_Window, LPDIRECT3DDEVICE9 p_dx_Device, char *s_fName, LPDIRECT3DVERTEXBUFFER9 &p_VertBuf, LPDIRECT3DINDEXBUFFER9 &p_IndBuf)
{
OCVArray p_verts;
SArray p_Inds;
int i_errorRetruned = LoadVerts(s_fName, p_verts, p_Inds, int_VertCount, int_TotalInd);
int_PrimCount = int_TotalInd/3;
// create the vertex buffer variable
LPDIRECT3DVERTEXBUFFER9 p_dx_VertexBuffer;
// try to initialize the vertexbuffer otherwise pop error
if (FAILED(p_dx_Device->CreateVertexBuffer(int_VertCount*sizeof(OURCUSTOMVERTEX), 0, D3DFVF_XYZ|D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &p_dx_VertexBuffer, NULL)))
{
MessageBox(han_Window, "Error While Creating VertexBuffer.", "FillVertices()", MB_OK);
}
// declare pointer for pointer in memory where vertices will be stored for d3d to find them
// declare pointer for pointer in memory where vertices will be stored for d3d to find them
VOID* p_Vertices;
// try to lock the memory location so other progs cannot access while copying vertices to it or pop error
if(FAILED(p_dx_VertexBuffer->Lock(0, int_VertCount*sizeof(OURCUSTOMVERTEX), (void**)&p_Vertices, 0)))
{
MessageBox(han_Window, "Error while trying to lock memory for Verts.", "FillVertices()", MB_OK);
}
else
{
// copy verts from array to memory and return pointer to location in memory to p_Vertices
memcpy(p_Vertices, &p_verts, int_VertCount*sizeof(OURCUSTOMVERTEX));
// unlock allocated memory area
p_dx_VertexBuffer->Unlock();
}
p_VertBuf = p_dx_VertexBuffer;
// create the index buffer and if it does not work pop an error
LPDIRECT3DINDEXBUFFER9 p_dx_IndexBuffer;
if (FAILED(p_dx_Device->CreateIndexBuffer(int_TotalInd*sizeof(short), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &p_dx_IndexBuffer, NULL)))
{
MessageBox(han_Window, "Error creating the IndexBuffer.", "FillIndices()", MB_OK);
}
// store index buffer in dx managed memory by locking, storing, unlocking for safe copy
VOID* p_Indices;
if(FAILED(p_dx_IndexBuffer->Lock(0, int_TotalInd*sizeof(short), (void**)&p_Indices, 0)))
{
MessageBox(han_Window, "Error while trying to Lock memory for copy.", "FillIndices()", MB_OK);
}
else
{
memcpy(p_Indices, &p_Inds, int_TotalInd*sizeof(short));
p_dx_IndexBuffer->Unlock();
}
p_IndBuf = p_dx_IndexBuffer;
return 0;
}
the LoadVerts function is a function solely for the purpose of extracting the vertex information from my custom file format (which is working properly). The file being loaded is a simple 3 triangle file for testing.... I am befuddled.