Jump to content
  • Advertisement

Archived

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

l99057j

Changing vertex colors on the fly

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

I am finally porting a 2D app to Direct3D. I have a custom window-manager written in DirectDraw7. I am re-writing this to use textured quads and an orthogonal projection because I now need to "host" a 3-D viewport in one of my windows and I want to use DX8 rather than 7 for this. So... on to the question. My window (optionally) has a titlebar. If I set the two vertices'' diffuse color on the left side to a dark blue and the two on the right side to light blue I get a nice gradient... just like Windows 2000/XP. But when the window is deactivated I have to lock the vertex buffer and change the diffuse color to dark and light grey. My question is, is there a better way? I know locking the vertex buffer is not something you want to do a lot. Frankly in my app, doing this only when someone changes focus on a window is not a huge performance penalty but in games like WarCraft III where you have the exact same model (say a Footman) that has to be drawn maybe 10 times in eight different colors (one for each player) it seems that eight locks and unlocks would be out of the question. It also seems wasteful to have to store eight copies of that model when the only thing different about them is the color of a few vertices. So, what is the most efficient approach? What do you gurus do in the "real world?"

Share this post


Link to post
Share on other sites
Advertisement
The way they usually do team colours in games is to just use different textures, as the vertex colours are already calculated through lighting, and setting the material would be inefficient.
For your window, using two copies shouldn''t be a big deal though, the few bytes you lose shouldn''t be cause for any worries.

- JQ
Full Speed Games. Period.

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!