im trying to set up a vertex cache, i have a function
void StartCache()
{
//lock buffers
if( FAILED( indexCache->Lock(0, 0, (void**)&index, 0) ))
{
systemLog.WriteLog("Lock Cache Index buffer [FAILED]");
return;
}
if( FAILED( vertexCache->Lock(0, 0, (void**)&vertex, 0) ))
{
systemLog.WriteLog("Lock Cache Vertex buffer [FAILED]");
return;
}
}
which loks the buffers so i can write to them through out the scene, the problem is with the "index" and "vertex" variables
which are defined as:
WORD* index;
STANDARD_VERTEX* vertex;
now when i use the sample code:
index[ 0 ] = 0;
index[ 1 ] = 1;
index[ 2 ] = 2;
STANDARD_VERTEX temp;
temp.p = D3DXVECTOR3(0,0,0);
vertex[ 0 ] = temp;
vertex[ 1 ] = temp;
vertex[ 2 ] = temp;
and i put that code after i lock the buffers (in the same function), then it works fine, but if i goto use that same peice of code any where else (before locking the buffers, and in the same file so they have access to "index" and "vertex", it causes my app to crash.
any ideas on what is acuasing this?