1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#ifndef VERTEXARRAY_H
#define VERTEXARRAY_H
#include "myGL.h"
#include "Platform/errorhandler.h"
// VertexArray.h: interface for the CVertexArray class.
//
//////////////////////////////////////////////////////////////////////
#define VA_INIT_VERTEXES 1000 // please don't change this, some files rely on specific initial sizes
#define VA_INIT_STRIPS 100
#define VA_SIZE_2D0 2
#define VA_SIZE_0 3
#define VA_SIZE_C 4
#define VA_SIZE_T 5
#define VA_SIZE_TN 8
#define VA_SIZE_TC 6
#define VA_SIZE_2DT 4
class CVertexArray
{
public:
typedef void (*StripCallback)(void* data);
public:
CVertexArray();
~CVertexArray();
void Initialize();
inline void CheckInitSize(const unsigned int vertexes, const unsigned int strips=0);
inline void AddVertex0(const float3& pos);
inline void AddVertex0(const float x, const float y, const float z);
inline void AddVertex2d0(float x, float z);
inline void AddVertexN(const float3& pos, const float3& normal);
inline void AddVertexT(const float3& pos,const float tx,const float ty);
inline void AddVertexC(const float3& pos,const unsigned char* color);
inline void AddVertexTC(const float3 &pos,const float tx,const float ty,const unsigned char* color);
inline void AddVertexTN(const float3 &pos,const float tx,const float ty,const float3& norm);
inline void AddVertexT2(const float3& pos,const float t1x,const float t1y,const float t2x,const float t2y);
inline void AddVertex2dT(const float x,const float y,const float tx,const float ty);
void DrawArray0(const int drawType, unsigned int stride = 12);
void DrawArray2d0(const int drawType, unsigned int stride = 8);
void DrawArrayN(const int drawType, unsigned int stride = 24);
void DrawArrayT(const int drawType, unsigned int stride = 20);
void DrawArrayC(const int drawType, unsigned int stride = 16);
void DrawArrayTC(const int drawType, unsigned int stride = 24);
void DrawArrayTN(const int drawType, unsigned int stride = 32);
void DrawArrayT2(const int drawType, unsigned int stride = 28);
void DrawArray2dT(const int drawType, unsigned int stride = 16);
void DrawArray2dT(const int drawType, StripCallback callback, void* data, unsigned int stride=16);
//! same as the AddVertex... functions just without automated CheckEnlargeDrawArray
inline void AddVertexQ0(const float x, const float y, const float z);
inline void AddVertexQ0(const float3& f3) { AddVertexQ0(f3.x, f3.y, f3.z); }
inline void AddVertex2dQ0(const float x, const float z);
inline void AddVertexQN(const float3& pos, const float3& normal);
inline void AddVertexQC(const float3& pos,const unsigned char* color);
inline void AddVertexQT(const float3& pos,const float tx,const float ty);
inline void AddVertex2dQT(const float x,const float y,const float tx,const float ty);
inline void AddVertexQTN(const float3 &pos,const float tx,const float ty,const float3& norm);
inline void AddVertexQTC(const float3 &pos,const float tx,const float ty,const unsigned char* color);
//! same as EndStrip, but without automated EnlargeStripArray
inline void EndStripQ();
bool IsReady();
inline unsigned int drawIndex() const;
void EndStrip();
inline void EnlargeArrays(const unsigned int vertexes, const unsigned int strips, const unsigned int stripsize=VA_SIZE_0);
float* drawArray;
float* drawArrayPos;
float* drawArraySize;
unsigned int* stripArray;
unsigned int* stripArrayPos;
unsigned int* stripArraySize;
static unsigned int maxVertices;
protected:
void DrawArrays(const GLenum mode, const unsigned int stride);
void DrawArraysCallback(const GLenum mode, const unsigned int stride, StripCallback callback, void* data);
inline void CheckEnlargeDrawArray();
void EnlargeStripArray();
void EnlargeDrawArray();
inline void CheckEndStrip();
};
#include "VertexArray.inl"
#endif /* VERTEXARRAY_H */
|