• Advertisement

Archived

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

CopyMemory doesn't work w/ my vertices

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

// say i''ve locked my static vertex buffer and claimed a buffer pointer (_pVertices) and pVertices contain the vertices I want to copy


// now this line here won''t work

CopyMemory((void *)&_pVertices[iOffset], (void *)pVertices, iOffset + _iBufferPosition);

// this does! 

for (int i = 0; i < (iOffset + _iBufferPosition); i++)
{
_pVertices[i]._vPosition = pVertices[i]._vPosition;
_pVertices[i]._d3dColor = pVertices[i]._d3dColor;
_pVertices[i]._vNormals = pVertices[i]._vNormals;
_pVertices[i]._vTexCoords = pVertices[i]._vTexCoords;
}
whyyyyyyyy ?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
because you locked it?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Of course it''s locked!

Share this post


Link to post
Share on other sites
Do you take into account that the CopyMemory''s third parameter is the number of _bytes_ to copy?

-Nik

Share this post


Link to post
Share on other sites
I used to make the same mistake often, when i started c++ programming.
I learned the hard way, when blue screens showed up at every second build
I copied past vid card mem boundaries, though...

-Nik

Share this post


Link to post
Share on other sites
MSDN wasn''t available when i started to learn c++, only Borland''s badly organized man pages

Besides, in this particular function, i found that it''s easy enough to forget that it''s not type safe.

-Nik

Share this post


Link to post
Share on other sites

  • Advertisement