• Advertisement
Sign in to follow this  

Locking the verrtex buffer

This topic is 4485 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

Hi I was just looking for a bit of help. I'm trying to lock the vertex buffer so I can compute the bounding box for my mesh using the code below:
        BYTE* vertices=NULL;
        mesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)vertices);

      //bounds of the model
      D3DXVECTOR3 min, //lower left coordinate
                  max; //upper right coordinate

      //Compute a coordinate-axis oriented bounding box
       D3DXComputeBoundingBox((D3DXVECTOR3*)vertices, 
                               mesh->GetNumVertices(),    
                               D3DXGetFVFVertexSize(mesh->GetFVF()), 
                               &min, &max);

      mesh->UnlockVertexBuffer();


DirectX debug output is telling me: Direct3D9: (ERROR) :Bad parameter passed for ppbData for locking a vertexbuffer Direct3D9: (ERROR) :Unlock failed on a buffer; vertex buffer wasn't locked. Does anybody know what I'm doing wrong? Any help would be very much appreciated.

Share this post


Link to post
Share on other sites
Advertisement
mesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)vertices);

should be

mesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*) &vertices);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement