Hi All
I am having a little trouble with my index buffer and I'm not really sure why
I currently have declared 2 buffer lock holders in a class header file, one for my vertices and one for my indices:
vertex *vertices;
short *indices;
And they are set to NULL in my class constructor
vertices = NULL;
indices = NULL;
But what baffles me is when I write to my vertex buffer lock using:
vertices[currentVertexBufferPosition] = (*i).verts[0];
vertices[currentVertexBufferPosition + 1] = (*i).verts[1];
vertices[currentVertexBufferPosition + 2] = (*i).verts[2];
vertices[currentVertexBufferPosition + 3] = (*i).verts[3];
Everything works and I can get all my expected values back using
//12 because we can hold at most 12 vertices (Max buffer size of 3 quads for testing)
for(int i = 0; i < 12; i++)
{
std::cout<<"I["<<i<<"]: X "<<vertices[i].x<<std::endl;
}
BUT using the same method for my index buffer lock
indices[currentIndexBufferPosition] = currentVertexBufferPosition;
indices[currentIndexBufferPosition + 1] = currentVertexBufferPosition + 1;
indices[currentIndexBufferPosition + 2] = currentVertexBufferPosition + 2;
indices[currentIndexBufferPosition + 3] = currentVertexBufferPosition + 3;
indices[currentIndexBufferPosition + 4] = currentVertexBufferPosition;
indices[currentIndexBufferPosition + 5] = currentVertexBufferPosition + 2;
And same method to get my data
//18 because we can hold at most 18 vertices (Max buffer size of 3 quads for testing)
for(int i = 0; i < 18; i++)
{
std::cout<<"I["<<i<<"]: Indices = "<<indices[i]<<std::endl;
}
I always get 0 back
when I step through, it seems like all of my indices are getting the value of 0.
Like the program is only accepting the first value assigned as the value to use all the time.
I know it is not a position issue as I always increase there values at the end of my run
currentIndexBufferPosition += 6;
currentVertexBufferPosition += 4;
Also just in case this is how I am locking, where the bufferLockFlag is set to NOOVERWRITE by default
vBuffer->Lock(0, 0, (void**) &vertices, bufferLockFlag);
iBuffer->Lock(0, 0, (void**) &indices, bufferLockFlag);
/* Code for drawing all loading the vertices / indices in the buffers. If the vertex buffer is full, unlock the buffers and change
the lock flag to DISCARD. Lock the buffers again and change the lokc flag back to NOOVERWRITE*/
vBuffer->Unlock();
iBuffer->Unlock();
Anyone have any ideas why this is happening?