2 #include "oxygine-include.h" 3 #include "math/Vector2.h" 9 VERTEX_POSITION = 0x0001,
10 VERTEX_COLOR = 0x0002,
14 USER_DATA_SIZE_BIT = VERTEX_LAST_BIT + 4,
15 NUM_TEX_COORD_BIT = VERTEX_LAST_BIT + 7,
16 TEX_COORD_SIZE_BIT = VERTEX_LAST_BIT + 10,
18 USER_DATA_SIZE_MASK = (0x7 << USER_DATA_SIZE_BIT),
19 NUM_TEX_COORD_MASK = (0x7 << NUM_TEX_COORD_BIT),
20 TEX_COORD_SIZE_MASK = (0x7 << TEX_COORD_SIZE_BIT),
23 #define VERTEX_USERDATA_SIZE(_n) ((_n) << USER_DATA_SIZE_BIT) 24 #define VERTEX_NUM_TEXCOORDS(_n) ((_n) << NUM_TEX_COORD_BIT) 25 #define VERTEX_TEXCOORD_SIZE(_stage, _n) ((_n) << (TEX_COORD_SIZE_BIT + (3*_stage))) 27 typedef unsigned int bvertex_format;
29 inline int vertexFlags(bvertex_format vertexFormat)
31 return vertexFormat & ((1 << (VERTEX_LAST_BIT + 1)) - 1);
34 inline int numTextureCoordinates(bvertex_format vertexFormat)
36 return (vertexFormat >> NUM_TEX_COORD_BIT) & 0x7;
39 inline int userDataSize(bvertex_format vertexFormat)
41 return (vertexFormat >> USER_DATA_SIZE_BIT) & 0x7;
44 inline int texCoordSize(
int stage, bvertex_format vertexFormat)
46 return (vertexFormat >> (TEX_COORD_SIZE_BIT + 3 * stage)) & 0x7;
51 inline unsigned int getVertexSize(bvertex_format fmt)
55 if (fmt & VERTEX_POSITION)
57 offset +=
sizeof(float) * 3;
60 if (fmt & VERTEX_COLOR)
65 int numTexCoords = numTextureCoordinates(fmt);
66 for (
int j = 0; j < numTexCoords; ++j)
68 int coordSize = texCoordSize(j, fmt);
69 offset +=
sizeof(float) * coordSize;
72 int ds = userDataSize(fmt);
75 offset +=
sizeof(float) * ds;
82 enum { FORMAT = VERTEX_POSITION | VERTEX_NUM_TEXCOORDS(1) | VERTEX_TEXCOORD_SIZE(0, 2) };
97 enum { FORMAT = VERTEX_POSITION | VERTEX_COLOR | VERTEX_NUM_TEXCOORDS(1) | VERTEX_TEXCOORD_SIZE(0, 2) };
105 enum { FORMAT = VERTEX_POSITION | VERTEX_COLOR | VERTEX_NUM_TEXCOORDS(2) | VERTEX_TEXCOORD_SIZE(0, 2) | VERTEX_TEXCOORD_SIZE(1, 2) };
111 enum { FORMAT = VERTEX_POSITION | VERTEX_COLOR | VERTEX_NUM_TEXCOORDS(3) | VERTEX_TEXCOORD_SIZE(0, 2) | VERTEX_TEXCOORD_SIZE(1, 2) | VERTEX_TEXCOORD_SIZE(2, 2) };
115 #define VERTEX_PCT2 vertexPCT2::FORMAT 116 #define VERTEX_PCT2T2 vertexPCT2T2::FORMAT
–oxgl-end–!
Definition: Actor.h:14