Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kylotan

How to use vertex buffers?

This topic is 6737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

After a bizarre problem where moving the data for my objects from an array of 24 vertices to a list of 6 sides with 4 vertices each caused the frame rate to drop to less than 1 per second when viewing that object, I decided to try again with a vertex buffer for each object, 24 vertices in size to hold all the corners of a cube/cuboid. (Note: I do know this is not very efficient at all, but I figured it would do until I was used to vertex buffers). However, it seems to inexplicably crash when I call 'lock' on the buffer to write the data into the buffer. Here's the code:
// Make our vertex buffer
D3DVERTEXBUFFERDESC vbdesc;
    
DX_INIT_STRUCT(vbdesc); // clears it and sets dwSize
vbdesc.dwCaps        = 0L;
vbdesc.dwFVF         = D3DFVF_VERTEX;
vbdesc.dwNumVertices = 24;
// I have tried both with and without the following line,
//   but it makes no difference
//vbdesc.dwCaps /= D3DVBCAPS_SYSTEMMEMORY;
    
// Create a clipping-capable vertex buffer.
if (FAILED(DirectDraw.GetlpD3D()->CreateVertexBuffer(&vbdesc,
                                  &vbuffer, 0, NULL)))
    throw "CreateVertexBuffer() failed.";

D3DVERTEX* bufferMemory;

if (FAILED(vbuffer->Lock(DDLOCK_WAIT, (VOID**)&bufferMemory, NULL)))
    throw "Lock failed";

 
If one of the calls failed, my exception handling should log the error message to my logfile. However, I am getting some other type of crash, cos it drops through to the (...) catch handler. If I comment out the lock (and the corresponding unlock, not shown above) line, it 'works' fine (of course, it doesn't render a thing ) What am I missing? Something obvious, I'm sure. Any ideas would be appreciated. Also, advice on a good way to store object vertex info while maintaining some sort of object-orientation would be handy. I'm using DX6.1, MSVC5, and an original Voodoo (ick, I know), for what it's worth. Edited by - Kylotan on 3/9/00 8:57:31 PM

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!