32 char WordsPerVertex, WordsPerNormal, WordsPerTexCoord, WordsPerColor;
33 char NumVertsToRestartStrip, NumVertsPerPrim;
34 bool StripsCanBeMerged;
35 bool AreVerticesValid, AreNormalsValid, AreTexCoordsValid, AreColorsValid;
38 ArrayType::tArrayType ArrayType;
40 static const int kMaxNumStrips = 40;
41 static const unsigned int kContinueFlag = 0x80000000;
42 unsigned char NumStrips;
43 unsigned int StripLengths[kMaxNumStrips];
44 const void* IStripLengths[kMaxNumStrips];
45 const void* Indices[kMaxNumStrips];
46 const void* Vertices[kMaxNumStrips];
47 const void* Normals[kMaxNumStrips];
48 const void* TexCoords[kMaxNumStrips];
49 const void* Colors[kMaxNumStrips];
50 unsigned char NumIndices[kMaxNumStrips];
55 ArrayType::tArrayType NewArrayType;
57 const void *NewVertices, *NewNormals, *NewTexCoords, *NewColors;
58 const void *NewIndices, *NewIStripLengths;
59 int NumNewVertices, NumNewNormals, NumNewTexCoords, NumNewColors, NumNewIndices;
60 char WordsPerNewVertex, WordsPerNewNormal;
61 char WordsPerNewTexCoord, WordsPerNewColor;
62 bool AreNewVerticesValid, AreNewNormalsValid;
63 bool AreNewTexCoordsValid, AreNewColorsValid;
65 void CommitPrimType();
66 bool SameDataFormat();
68 bool MergeNewLinear();
69 bool MergeNewIndexed();
76 inline void SetVerticesAreValid(
bool valid) { AreNewVerticesValid = valid; }
77 inline void SetNormalsAreValid(
bool valid) { AreNewNormalsValid = valid; }
78 inline void SetTexCoordsAreValid(
bool valid) { AreNewTexCoordsValid = valid; }
79 inline void SetColorsAreValid(
bool valid) { AreNewColorsValid = valid; }
81 inline bool GetVerticesAreValid()
const {
return AreVerticesValid; }
82 inline bool GetNormalsAreValid()
const {
return AreNormalsValid; }
83 inline bool GetTexCoordsAreValid()
const {
return AreTexCoordsValid; }
84 inline bool GetColorsAreValid()
const {
return AreColorsValid; }
86 inline int GetWordsPerVertex()
const {
return WordsPerVertex; }
87 inline int GetWordsPerNormal()
const {
return WordsPerNormal; }
88 inline int GetWordsPerTexCoord()
const {
return WordsPerTexCoord; }
89 inline int GetWordsPerColor()
const {
return WordsPerColor; }
91 inline void SetWordsPerVertex(
char num) { WordsPerNewVertex = num; }
92 inline void SetWordsPerNormal(
char num) { WordsPerNewNormal = num; }
93 inline void SetWordsPerTexCoord(
char num) { WordsPerNewTexCoord = num; }
94 inline void SetWordsPerColor(
char num) { WordsPerNewColor = num; }
96 inline void SetArrayType(ArrayType::tArrayType type) { NewArrayType = type; }
97 inline ArrayType::tArrayType GetNewArrayType()
const {
return NewArrayType; }
98 inline ArrayType::tArrayType GetArrayType()
const {
return ArrayType; }
100 inline void SetNumIndices(
unsigned int num) { NumNewIndices = num; }
101 inline void SetIndices(
const void* indices) { NewIndices = indices; }
102 inline void SetIStripLengths(
const void* strips) { NewIStripLengths = strips; }
104 inline const void* GetVertices(
int strip = 0)
106 mErrorIf(strip >= NumStrips,
"Strip num is out of bounds");
107 return Vertices[strip];
109 inline const void* GetNormals(
int strip = 0)
111 mErrorIf(strip >= NumStrips,
"Strip num is out of bounds");
112 return Normals[strip];
114 inline const void* GetTexCoords(
int strip = 0)
116 mErrorIf(strip >= NumStrips,
"Strip num is out of bounds");
117 return TexCoords[strip];
119 inline const void* GetColors(
int strip = 0)
121 mErrorIf(strip >= NumStrips,
"Strip num is out of bounds");
122 return Colors[strip];
124 inline const void* GetIndices(
int array)
126 mErrorIf(array >= NumStrips,
"Strip num is out of bounds");
127 return Indices[array];
129 inline const void* GetIStripLengths(
int array)
131 mErrorIf(array >= NumStrips,
"Strip num is out of bounds");
132 return IStripLengths[array];
135 inline void SetVertices(
const void* verts) { NewVertices = verts; }
136 inline void SetNormals(
const void* norms) { NewNormals = norms; }
137 inline void SetTexCoords(
const void* texcoords) { NewTexCoords = texcoords; }
138 inline void SetColors(
const void* colors) { NewColors = colors; }
140 GLenum GetPrimType()
const {
return PrimType; }
141 void SetPrimType(GLenum type) { NewPrimType = type; }
143 inline int GetNumNewVertices()
const {
return NumNewVertices; }
144 inline int GetNumNewNormals()
const {
return NumNewNormals; }
145 inline int GetNumNewTexCoords()
const {
return NumNewTexCoords; }
146 inline int GetNumNewColors()
const {
return NumNewColors; }
148 inline int GetTotalVertices()
const {
return TotalVertices; }
152 inline void AddVertices(
int num = 1) { NumNewVertices += num; }
153 inline void AddNormals(
int num = 1) { NumNewNormals += num; }
154 inline void AddTexCoords(
int num = 1) { NumNewTexCoords += num; }
155 inline void AddColors(
int num = 1) { NumNewColors += num; }
160 inline void SetNumVertsPerPrim(
int num) { NumVertsPerPrim = num; }
161 inline int GetNumVertsPerPrim() {
return NumVertsPerPrim; }
166 inline void SetNumVertsToRestartStrip(
int num) { NumVertsToRestartStrip = num; }
167 inline void SetStripsCanBeMerged(
bool merge) { StripsCanBeMerged = merge; }
169 inline int GetNumStrips()
const {
return NumStrips; }
174 inline bool GetStripsCanBeMerged()
const {
return StripsCanBeMerged; }
175 inline int GetStripLength(
int num)
const
177 mErrorIf(num >= NumStrips,
"Strip num is out of bounds");
178 return (
int)(StripLengths[num] & ~kContinueFlag);
180 inline bool StripIsContinued(
int num)
const
182 mErrorIf(num >= NumStrips,
"Strip num is out of bounds");
183 return StripLengths[num] & kContinueFlag;
188 inline int GetNumArrays()
const {
return NumStrips; }
189 inline int GetArrayLength(
int array)
const
191 return GetStripLength(array);
193 inline int GetNumIndices(
int array)
const
195 mErrorIf(array >= NumStrips,
"Strip num is out of bounds");
196 return NumIndices[array];
201 void ResetCurStrip();
207 bool IsPending()
const {
return (PrimType != GL_INVALID_VALUE); }
209 void MakeNewValuesCurrent();
210 void AdjustNewGeomPtrs(
int offset)
212 if (AreNewVerticesValid)
213 NewVertices = (
float*)NewVertices + offset * WordsPerNewVertex;
214 if (AreNewNormalsValid)
215 NewNormals = (
float*)NewNormals + offset * WordsPerNewNormal;
216 if (AreNewTexCoordsValid)
217 NewTexCoords = (
float*)NewTexCoords + offset * WordsPerNewTexCoord;
218 if (AreNewColorsValid)
219 NewColors = (
float*)NewColors + offset * WordsPerNewColor;