CopyMemory doesn't work w/ my vertices

Started by
6 comments, last by Saandman 20 years, 6 months ago

// 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 ?
________________________________pro.gram.mer - an organism that turns caffeine into code
Advertisement
because you locked it?
Of course it''s locked!
Do you take into account that the CopyMemory''s third parameter is the number of _bytes_ to copy?

-Nik

Niko Suni

Wooops, why thanks nik. I never learn!
________________________________pro.gram.mer - an organism that turns caffeine into code
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

Niko Suni

All it takes is a quick glance at MSDN. Especially if the function isn''t working, that''s the first place you go.
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

Niko Suni

This topic is closed to new replies.

Advertisement