Jump to content
  • Advertisement


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


VertexBuffer question

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

Sya i have a LPDIRECT3DVERTEXBUFFER8 lpVertexBuffer. I have created it and copied in my vertices of type VERTEX: struct VERTEX { FLOAT x, y, z; FLOAT nx, ny, nz; D3DCOLOR color; FLOAT tx, ty; }; Now i want to change the color of individual vertices on a frame to frame basis. What is the most efficient way of doing this. I dought relocking vertex buffer and copying in all vertices again is the way to go. Any ideas? -CProgrammer

Share this post

Link to post
Share on other sites
I did something similar in my game, for simple home-cooked lighting effects. For my (non T&L) card, the fastest way I could manage to do it was to create a vertex buffer using the DYNAMIC creation flag, then lock it and change the colors each frame. Don''t recopy in the whole set of vertices. Cast the pointer they give you from the Lock operation to a VERTEX* and use it like an array; loop through each one and set the color.

~BenDilts( void );

Share this post

Link to post
Share on other sites
Thanks guys it seems that if i want faster than locking and unlocking i''ll need to use VertexShaders. However i think i''ll use BeanDog''s method as long as the performance remains sufficient for my needs.

Lock operation to a VERTEX*

Until now i locked to a void* and copyd all the vertices
using memcpy between lock and unlock.
Do you mean i can lock to VERTEX* instead and then must i use
memcpy or can i just set the values of my VERTEX arrays
after locking? And can i then keep my VERTEX pointer to the vertexbuffer memory and alter it per frame?


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!