Jump to content

  • Log In with Google      Sign In   
  • Create Account


vertex array


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 phil67rpg   Members   -  Reputation: 766

Like
0Likes
Like

Posted 29 October 2011 - 04:55 PM

is there any way I can shorten this array.I am using dx9 and c++.
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), },





Sponsor:

#2 Daniel Saska   Members   -  Reputation: 103

Like
1Likes
Like

Posted 29 October 2011 - 05:04 PM

Learn about Index buffers. You can do so here: http://www.toymaker....ml/buffers.html for example

#3 Jason Z   Crossbones+   -  Reputation: 4553

Like
0Likes
Like

Posted 30 October 2011 - 12:15 AM

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?

#4 phil67rpg   Members   -  Reputation: 766

Like
0Likes
Like

Posted 30 October 2011 - 01:26 PM

the size of my code, its declaration

#5 link102   Members   -  Reputation: 249

Like
0Likes
Like

Posted 30 October 2011 - 02:00 PM

Alternate tutorial for index buffers: http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B7.aspx

#6 Juliean   GDNet+   -  Reputation: 2206

Like
1Likes
Like

Posted 30 October 2011 - 02:24 PM

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

#7 unbird   Crossbones+   -  Reputation: 4703

Like
0Likes
Like

Posted 30 October 2011 - 07:03 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS