Jump to content
  • Advertisement
Sign in to follow this  

vertex array

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

is there any way I can shorten this array.I am using dx9 and c++.
[font="Consolas"][font="Consolas"]CUSTOMVERTEX vertices[] =

{

{ 0.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },

{ 150.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },

{ 150.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), },

{ 0.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },

{ 150.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },

{ 300.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), },

{ 300.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },

{ 150.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },

{ 300.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), },

{ 450.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },

{ 450.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },

{ 300.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), },

{ 450.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },

{ 600.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },

{ 600.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), },

{ 450.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },

{ 600.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },

{ 750.0f, 0.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), },

{ 750.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },

{ 600.0f, 40.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },



[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
When you say "shorten", what exactly do you mean? The size of the declaration in your code, or do you mean to reduce the memory footprint of the array?

Share this post


Link to post
Share on other sites
Although its pointless, as in a real application you always store such data offline and not in the code:

- Erase all .0f's, no need for them here
- Cache your D3DCOLOR_XRGBs in D3DCOLOR variables

Share this post


Link to post
Share on other sites
No need to use a FLOAT4 if your w is always 1. Use FLOAT3, it will get that one automatically. Since this looks 2D even FLOAT2 could work. Reduces memory footprint, too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!