Archived

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

Changing the color of a vertex in the buffer.

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

This may be a dumb question, but I don''t know where to look for this one. Say I create a vertex buffer with 4 vertices (a color, D3DXVECTOR3 holding the position, and the tu and tv for texture positioning). How do I access each individual vertex once I do this, so that I can change their colors? Thanks --Vic--

Share this post


Link to post
Share on other sites
You have to "lock" the vertex buffer (vb). Look up the Lock function in the SDK help. You supply a pointer which ends up pointing to the vertices:

MYVERTEX *pVertices;

vertex_buffer->Lock(..... (BYTE **)pVertices .....);

loop i
pVertices-i-.colour = D3DCOLOR(255,255,255);
end loop

vertex_buffer->Unlock();


There we go. Hope you enjoyed my pseudo-C.

Edited by - freshya on February 19, 2002 9:56:03 PM

Share this post


Link to post
Share on other sites