Locking VBuffer and passing the data to fill out

Started by
3 comments, last by Funkymunky 19 years, 10 months ago
Alright, I have two separate classes, a loader and an object (because there are multiple objects). So the loader holds the vertex buffer, and needs to obtain the vertices from 3 different objects. After I lock the vertex buffer, how do I take that ppbData parameter that I normally fill out with the vertex data and pass it to the other classes function which can then fill it out? right now it crashes after the three fill it out, on the drawindexedprimitive call (invalid data i guess).
Advertisement
1) Are you sure you unlocked it before rendering?
2) Do you use something like ptr++?

--
You''re Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net''s DirectX FAQ. (not as cool as the Graphics and Theory FAQ)
First I lock both the vertex buffer and index buffer,
(vbuffer->Lock(0, sizeof(MyVertex)*numverts, (BYTE**)&pVertices, 0),
then I passit to a function who has a parameter of (MyVertex *verts), then I try to access it like a normal array in the function using the left and right brackets.
Next I (A) unlock the index and vertex buffer

so (B) in the function I'm using

void AddVerts(MyVertex *verts, int numverts){    for(int i=0; i<numberobjectverts; i++)    {        verts[i+numverts]=objectverts[i];        ...



The thing that seems strange to me is the I'm using the BYTE** pVertices which I return from vbuffer->Lock( so should I be passing a pointer to a pointer of an array or something? It's been referenced to a memory address or something from the Lock call maybe?

[edited by - Funkymunky on June 5, 2004 11:44:21 AM]
Ok as far as I can tell it''s filling out the vertices and indices properly, but it crashes the program on the DrawIndexedPrimitive call. I can''t get an HRESULT out of it...any ideas?
did you call SetStreamSource() first?

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

This topic is closed to new replies.

Advertisement