Sorry guys, i hate to keep nagging you for help but im moving forward with my project quite rapidly and keep finding problems that i can never find documentation on.
So here goes...
I have written a wrapper for a vertex buffer and it has a pair of write functions that look like this...
A write function for writing a single vertex to the buffer...
template<class T>
void Component_VB<T>::Write(T& v)
{
if (numberWritten < size)
{
void* a;
pV = NULL;
// lock the buffer
Lock(v, (numberWritten * sizeof(v)) );
a = memcpy(pV, &v, sizeof(v));
Unlock();
if (a != NULL)
{
numberWritten++;
}
else
{
assert(0);
}
}
else
{
assert(0);
}
}
A write function for writing an array of vertices to the buffer...
template<class T>
void Component_VB<T>::Write(T v[], unsigned int qty)
{
if (numberWritten < size)
{
T tempVerts[1000]; // <<Used for simple test code
VOID* a;
VOID* vPointer;
vertexBuffer->Lock(0, (qty *sizeof(T)),(void**) &vPointer, 0);
a = memcpy(&tempVerts[0], &v[0], qty*sizeof(T));
a = memcpy(vPointer, &v[0], qty*sizeof(T));
vertexBuffer->Unlock();
if (a != NULL)
{
numberWritten++;
}
else
{
assert(0);
}
}
else
{
assert(0);
}
}
The first one works fine by moving through the array by one vertex every time the function is called. Now this is the function that i am currently using. This function obviously is slow to use because of the Lock() Unlock() which would be called thousands of times.
I want to implement the second function which takes a pointer to an array of vertices and the number to be copied. As a test to see if i was recieving the vertices through the parameter as i wanted i added an internal array to also copy to, using the top memcpy(). Then second memcpy() is to copy to the void* pointing to the VB. Now the vertices do copy correctly from the the parameter to the internal array but they obviously dont copy to the VB correctly since the on-screen object doesnt render.
The on screen object does render if they are written one at a time.
Also i should add that the Lock function is wrappedVB function that does work for simply usage. In the second function i havnt used it. So if you can take that function for granted in the first example.
Can anyone see why this might be the case? I have tried alot of different syntax's to try and solve this but non have worked obviously.
Sorry to take up more of your time,
ace