The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Difference between revisions of "NewAPI/Primitives/VertexBuffer"

From Allegro Wiki
Jump to: navigation, search
(New page: Some mockups for the new expandable vertex buffer struct for the primitives addon. Will add more soon. Suggestions welcome. <highlightSyntax language="cpp"> /* Describe the types of attri...)
 
m
 
Line 38: Line 38:
 
/* The way those are stored */
 
/* The way those are stored */
 
int formats[ALLEGRO_ATTRIB_COUNT];
 
int formats[ALLEGRO_ATTRIB_COUNT];
 +
int flags;
 
/* An array of vertices, or some descriptors for hardware VBO's */
 
/* An array of vertices, or some descriptors for hardware VBO's */
 
void* data;
 
void* data;
Line 57: Line 58:
 
<highlightSyntax language="cpp">
 
<highlightSyntax language="cpp">
 
/*
 
/*
Same here, not sure if this is the best way
+
Same here, not sure if this is the best way. Perhaps have a 'ALLEGRO_VBUFF_DESCRIPTION'?
 
*/
 
*/
  

Latest revision as of 04:14, April 16, 2009

Some mockups for the new expandable vertex buffer struct for the primitives addon. Will add more soon. Suggestions welcome.

<highlightSyntax language="cpp"> /* Describe the types of attributes that a vertex may possibly have

  • /

enum ALLEGRO_ATTRIB_TYPES { ALLEGRO_ATTRIB_POSITION, ALLEGRO_ATTRIB_TEXTURE1, ALLEGRO_ATTRIB_TEXTURE2, ALLEGRO_ATTRIB_TEXTURE3, ALLEGRO_ATTRIB_NORMAL, /* Etc */ ALLEGRO_ATTRIB_COUNT }; </highlightSyntax>

<highlightSyntax language="cpp"> /* Describe how those are stored

  • /

enum ALLEGRO_ATTRIB_TYPES { ALLEGRO_FORMAT_3F, ALLEGRO_ATTRIB_4F, ALLEGRO_ATTRIB_3I /* Etc */ }; </highlightSyntax>

<highlightSyntax language="cpp"> typedef struct { /* The offsets of those types in the vertex struct, -1 or something if the

      type is not present in the vertex */

int offsets[ALLEGRO_ATTRIB_COUNT]; /* The way those are stored */ int formats[ALLEGRO_ATTRIB_COUNT]; int flags; /* An array of vertices, or some descriptors for hardware VBO's */ void* data; } ALLEGRO_VBUFF;

/* No more ALLEGRO_VERTEX

  • /

</highlightSyntax>

<highlightSyntax language="cpp"> /* Any suggestions on how not make a billion _3i vs _3f vs etc functions? Variadic functions?

  • /

al_{get/set}_vbuff_attrib_3i(int attrib_type, int *v1, int *v2, int *v3); al_{get/set}_vbuff_attrib_3f(int attrib_type, float *v1, float *v2, float *v3); </highlightSyntax>

<highlightSyntax language="cpp"> /* Same here, not sure if this is the best way. Perhaps have a 'ALLEGRO_VBUFF_DESCRIPTION'?

  • /

ALLEGRO_VBUFF* al_create_vbuff(int size, int flags, ...) /*

Call it like this
*/

al_create_vbuff(412, ALLEGRO_VBUFF_HARDWARE, ALLEGRO_ATTRIB_POSITION, ALLEGRO_FORMAT_3F, ALLEGRO_ATTRIB_TEXTURE1, ALLEGRO_ATTRIB_4F); </highlightSyntax>