History

Fix the bug happening on mac due to order in which parmaeters are evaluated for all of the gl calls, now fixed with an order independant code

Sam Gateau committed 12 years ago

Commit d1328311 parent 057c17f3 files · +260 −129Browse files

Showing the changes to interface/src/gpu/Batch.cpp (1 of 3 files). Show all

Unified · Split

interface/src/gpu/Batch.cpp+215−86
@@ -17,6 +17,8 @@ · 16 unmodified lines
1717 //#define DO_IT_NOW(call, offset) runLastCommand();
1818 #define DO_IT_NOW(call, offset)
1919
20+#define CHECK_GL_ERROR() ::gpu::backend::checkGLError()
21+
2022 using namespace gpu;
2123
2224 Batch::Batch() :
@@ -158,8 +160,9 @@ void Batch::_glEnable(GLenum cap) { · 135 unmodified lines
158160
159161 DO_IT_NOW(_glEnable, 1);
160162 }
161−void Batch::do_glEnable(uint32& paramOffset) {
162− glEnable(_params[paramOffset++]._uint);
163+void Batch::do_glEnable(uint32 paramOffset) {
164+ glEnable(_params[paramOffset]._uint);
165+ CHECK_GL_ERROR();
163166 }
164167
165168 void Batch::_glDisable(GLenum cap) {
@@ -169,8 +172,9 @@ void Batch::_glDisable(GLenum cap) { · 3 unmodified lines
169172
170173 DO_IT_NOW(_glDisable, 1);
171174 }
172−void Batch::do_glDisable(uint32& paramOffset) {
173− glDisable(_params[paramOffset++]._uint);
175+void Batch::do_glDisable(uint32 paramOffset) {
176+ glDisable(_params[paramOffset]._uint);
177+ CHECK_GL_ERROR();
174178 }
175179
176180 void Batch::_glEnableClientState(GLenum array) {
@@ -180,8 +184,9 @@ void Batch::_glEnableClientState(GLenum array) { · 3 unmodified lines
180184
181185 DO_IT_NOW(_glEnableClientState, 1 );
182186 }
183−void Batch::do_glEnableClientState(uint32& paramOffset) {
184− glEnableClientState(_params[paramOffset++]._uint);
187+void Batch::do_glEnableClientState(uint32 paramOffset) {
188+ glEnableClientState(_params[paramOffset]._uint);
189+ CHECK_GL_ERROR();
185190 }
186191
187192 void Batch::_glDisableClientState(GLenum array) {
@@ -191,8 +196,9 @@ void Batch::_glDisableClientState(GLenum array) { · 3 unmodified lines
191196
192197 DO_IT_NOW(_glDisableClientState, 1);
193198 }
194−void Batch::do_glDisableClientState(uint32& paramOffset) {
195− glDisableClientState(_params[paramOffset++]._uint);
199+void Batch::do_glDisableClientState(uint32 paramOffset) {
200+ glDisableClientState(_params[paramOffset]._uint);
201+ CHECK_GL_ERROR();
196202 }
197203
198204 void Batch::_glCullFace(GLenum mode) {
@@ -202,8 +208,9 @@ void Batch::_glCullFace(GLenum mode) { · 3 unmodified lines
202208
203209 DO_IT_NOW(_glCullFace, 1);
204210 }
205−void Batch::do_glCullFace(uint32& paramOffset) {
206− glCullFace(_params[paramOffset++]._uint);
211+void Batch::do_glCullFace(uint32 paramOffset) {
212+ glCullFace(_params[paramOffset]._uint);
213+ CHECK_GL_ERROR();
207214 }
208215
209216 void Batch::_glAlphaFunc(GLenum func, GLclampf ref) {
@@ -214,8 +221,11 @@ void Batch::_glAlphaFunc(GLenum func, GLclampf ref) { · 4 unmodified lines
214221
215222 DO_IT_NOW(_glAlphaFunc, 2);
216223 }
217−void Batch::do_glAlphaFunc(uint32& paramOffset) {
218− glAlphaFunc(_params[paramOffset++]._uint, _params[paramOffset++]._float);
224+void Batch::do_glAlphaFunc(uint32 paramOffset) {
225+ glAlphaFunc(
226+ _params[paramOffset + 1]._uint,
227+ _params[paramOffset + 0]._float);
228+ CHECK_GL_ERROR();
219229 }
220230
221231 void Batch::_glDepthFunc(GLenum func) {
@@ -225,8 +235,9 @@ void Batch::_glDepthFunc(GLenum func) { · 3 unmodified lines
225235
226236 DO_IT_NOW(_glDepthFunc, 1);
227237 }
228−void Batch::do_glDepthFunc(uint32& paramOffset) {
229− glDepthFunc(_params[paramOffset++]._uint);
238+void Batch::do_glDepthFunc(uint32 paramOffset) {
239+ glDepthFunc(_params[paramOffset]._uint);
240+ CHECK_GL_ERROR();
230241 }
231242
232243 void Batch::_glDepthMask(GLboolean flag) {
@@ -236,8 +247,9 @@ void Batch::_glDepthMask(GLboolean flag) { · 3 unmodified lines
236247
237248 DO_IT_NOW(_glDepthMask, 1);
238249 }
239−void Batch::do_glDepthMask(uint32& paramOffset) {
240− glDepthMask(_params[paramOffset++]._uint);
250+void Batch::do_glDepthMask(uint32 paramOffset) {
251+ glDepthMask(_params[paramOffset]._uint);
252+ CHECK_GL_ERROR();
241253 }
242254
243255 void Batch::_glDepthRange(GLclampd zNear, GLclampd zFar) {
@@ -248,8 +260,11 @@ void Batch::_glDepthRange(GLclampd zNear, GLclampd zFar) { · 4 unmodified lines
248260
249261 DO_IT_NOW(_glDepthRange, 2);
250262 }
251−void Batch::do_glDepthRange(uint32& paramOffset) {
252− glDepthRange(_params[paramOffset++]._double, _params[paramOffset++]._double);
263+void Batch::do_glDepthRange(uint32 paramOffset) {
264+ glDepthRange(
265+ _params[paramOffset + 1]._double,
266+ _params[paramOffset + 0]._double);
267+ CHECK_GL_ERROR();
253268 }
254269
255270 void Batch::_glBindBuffer(GLenum target, GLuint buffer) {
@@ -260,8 +275,11 @@ void Batch::_glBindBuffer(GLenum target, GLuint buffer) { · 4 unmodified lines
260275
261276 DO_IT_NOW(_glBindBuffer, 2);
262277 }
263−void Batch::do_glBindBuffer(uint32& paramOffset) {
264− glBindBuffer(_params[paramOffset++]._uint, _params[paramOffset++]._uint);
278+void Batch::do_glBindBuffer(uint32 paramOffset) {
279+ glBindBuffer(
280+ _params[paramOffset + 1]._uint,
281+ _params[paramOffset + 0]._uint);
282+ CHECK_GL_ERROR();
265283 }
266284
267285 void Batch::_glBindTexture(GLenum target, GLuint texture) {
@@ -272,8 +290,11 @@ void Batch::_glBindTexture(GLenum target, GLuint texture) { · 4 unmodified lines
272290
273291 DO_IT_NOW(_glBindTexture, 2);
274292 }
275−void Batch::do_glBindTexture(uint32& paramOffset) {
276− glBindTexture(_params[paramOffset++]._uint, _params[paramOffset++]._uint);
293+void Batch::do_glBindTexture(uint32 paramOffset) {
294+ glBindTexture(
295+ _params[paramOffset + 1]._uint,
296+ _params[paramOffset + 0]._uint);
297+ CHECK_GL_ERROR();
277298 }
278299
279300 void Batch::_glActiveTexture(GLenum texture) {
@@ -283,8 +304,9 @@ void Batch::_glActiveTexture(GLenum texture) { · 3 unmodified lines
283304
284305 DO_IT_NOW(_glActiveTexture, 1);
285306 }
286−void Batch::do_glActiveTexture(uint32& paramOffset) {
287− glActiveTexture(_params[paramOffset++]._uint);
307+void Batch::do_glActiveTexture(uint32 paramOffset) {
308+ glActiveTexture(_params[paramOffset]._uint);
309+ CHECK_GL_ERROR();
288310 }
289311
290312 void Batch::_glDrawBuffers(GLsizei n, const GLenum* bufs) {
@@ -295,8 +317,11 @@ void Batch::_glDrawBuffers(GLsizei n, const GLenum* bufs) { · 4 unmodified lines
295317
296318 DO_IT_NOW(_glDrawBuffers, 2);
297319 }
298−void Batch::do_glDrawBuffers(uint32& paramOffset) {
299− glDrawBuffers(_params[paramOffset++]._uint, (const GLenum*) editData(_params[paramOffset++]._uint));
320+void Batch::do_glDrawBuffers(uint32 paramOffset) {
321+ glDrawBuffers(
322+ _params[paramOffset + 1]._uint,
323+ (const GLenum*) editData(_params[paramOffset + 0]._uint));
324+ CHECK_GL_ERROR();
300325 }
301326
302327 void Batch::_glUseProgram(GLuint program) {
@@ -306,8 +331,9 @@ void Batch::_glUseProgram(GLuint program) { · 3 unmodified lines
306331
307332 DO_IT_NOW(_glUseProgram, 1);
308333 }
309−void Batch::do_glUseProgram(uint32& paramOffset) {
310− glUseProgram(_params[paramOffset++]._uint);
334+void Batch::do_glUseProgram(uint32 paramOffset) {
335+ glUseProgram(_params[paramOffset]._uint);
336+ CHECK_GL_ERROR();
311337 }
312338
313339 void Batch::_glUniform1f(GLint location, GLfloat v0) {
@@ -318,8 +344,11 @@ void Batch::_glUniform1f(GLint location, GLfloat v0) { · 4 unmodified lines
318344
319345 DO_IT_NOW(_glUniform1f, 1);
320346 }
321−void Batch::do_glUniform1f(uint32& paramOffset) {
322− glUniform1f(_params[paramOffset++]._int, _params[paramOffset++]._float);
347+void Batch::do_glUniform1f(uint32 paramOffset) {
348+ glUniform1f(
349+ _params[paramOffset + 1]._int,
350+ _params[paramOffset + 0]._float);
351+ CHECK_GL_ERROR();
323352 }
324353
325354 void Batch::_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
@@ -333,9 +362,13 @@ void Batch::_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpo · 7 unmodified lines
333362
334363 DO_IT_NOW(_glUniformMatrix4fv, 4);
335364 }
336−void Batch::do_glUniformMatrix4fv(uint32& paramOffset) {
337− glUniformMatrix4fv(_params[paramOffset++]._int, _params[paramOffset++]._uint,
338− _params[paramOffset++]._uint, (const GLfloat*) editData(_params[paramOffset++]._uint));
365+void Batch::do_glUniformMatrix4fv(uint32 paramOffset) {
366+ glUniformMatrix4fv(
367+ _params[paramOffset + 3]._int,
368+ _params[paramOffset + 2]._uint,
369+ _params[paramOffset + 1]._uint,
370+ (const GLfloat*) editData(_params[paramOffset + 0]._uint));
371+ CHECK_GL_ERROR();
339372 }
340373
341374 void Batch::_glMatrixMode(GLenum mode) {
@@ -345,8 +378,9 @@ void Batch::_glMatrixMode(GLenum mode) { · 3 unmodified lines
345378
346379 DO_IT_NOW(_glMatrixMode, 1);
347380 }
348−void Batch::do_glMatrixMode(uint32& paramOffset) {
349− glMatrixMode(_params[paramOffset++]._uint);
381+void Batch::do_glMatrixMode(uint32 paramOffset) {
382+ glMatrixMode(_params[paramOffset]._uint);
383+ CHECK_GL_ERROR();
350384 }
351385
352386 void Batch::_glPushMatrix() {
@@ -354,8 +388,9 @@ void Batch::_glPushMatrix() { · 1 unmodified line
354388
355389 DO_IT_NOW(_glPushMatrix, 0);
356390 }
357−void Batch::do_glPushMatrix(uint32& paramOffset) {
391+void Batch::do_glPushMatrix(uint32 paramOffset) {
358392 glPushMatrix();
393+ CHECK_GL_ERROR();
359394 }
360395
361396 void Batch::_glPopMatrix() {
@@ -363,8 +398,9 @@ void Batch::_glPopMatrix() { · 1 unmodified line
363398
364399 DO_IT_NOW(_glPopMatrix, 0);
365400 }
366−void Batch::do_glPopMatrix(uint32& paramOffset) {
401+void Batch::do_glPopMatrix(uint32 paramOffset) {
367402 glPopMatrix();
403+ CHECK_GL_ERROR();
368404 }
369405
370406 void Batch::_glMultMatrixf(const GLfloat *m) {
@@ -375,8 +411,9 @@ void Batch::_glMultMatrixf(const GLfloat *m) { · 4 unmodified lines
375411
376412 DO_IT_NOW(_glMultMatrixf, 1);
377413 }
378−void Batch::do_glMultMatrixf(uint32& paramOffset) {
379− glMultMatrixf((const GLfloat*) editData(_params[paramOffset++]._uint));
414+void Batch::do_glMultMatrixf(uint32 paramOffset) {
415+ glMultMatrixf((const GLfloat*) editData(_params[paramOffset]._uint));
416+ CHECK_GL_ERROR();
380417 }
381418
382419 void Batch::_glLoadMatrixf(const GLfloat *m) {
@@ -387,8 +424,9 @@ void Batch::_glLoadMatrixf(const GLfloat *m) { · 4 unmodified lines
387424
388425 DO_IT_NOW(_glLoadMatrixf, 1);
389426 }
390−void Batch::do_glLoadMatrixf(uint32& paramOffset) {
391− glLoadMatrixf((const GLfloat*)editData(_params[paramOffset++]._uint));
427+void Batch::do_glLoadMatrixf(uint32 paramOffset) {
428+ glLoadMatrixf((const GLfloat*)editData(_params[paramOffset]._uint));
429+ CHECK_GL_ERROR();
392430 }
393431
394432 void Batch::_glLoadIdentity(void) {
@@ -396,8 +434,9 @@ void Batch::_glLoadIdentity(void) { · 1 unmodified line
396434
397435 DO_IT_NOW(_glLoadIdentity, 0);
398436 }
399−void Batch::do_glLoadIdentity(uint32& paramOffset) {
437+void Batch::do_glLoadIdentity(uint32 paramOffset) {
400438 glLoadIdentity();
439+ CHECK_GL_ERROR();
401440 }
402441
403442 void Batch::_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
@@ -410,8 +449,13 @@ void Batch::_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { · 6 unmodified lines
410449
411450 DO_IT_NOW(_glRotatef, 4);
412451 }
413−void Batch::do_glRotatef(uint32& paramOffset) {
414− glRotatef(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float);
452+void Batch::do_glRotatef(uint32 paramOffset) {
453+ glRotatef(
454+ _params[paramOffset + 3]._float,
455+ _params[paramOffset + 2]._float,
456+ _params[paramOffset + 1]._float,
457+ _params[paramOffset + 0]._float);
458+ CHECK_GL_ERROR();
415459 }
416460
417461 void Batch::_glScalef(GLfloat x, GLfloat y, GLfloat z) {
@@ -423,8 +467,12 @@ void Batch::_glScalef(GLfloat x, GLfloat y, GLfloat z) { · 5 unmodified lines
423467
424468 DO_IT_NOW(_glScalef, 3);
425469 }
426−void Batch::do_glScalef(uint32& paramOffset) {
427− glScalef(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float);
470+void Batch::do_glScalef(uint32 paramOffset) {
471+ glScalef(
472+ _params[paramOffset + 2]._float,
473+ _params[paramOffset + 1]._float,
474+ _params[paramOffset + 0]._float);
475+ CHECK_GL_ERROR();
428476 }
429477
430478 void Batch::_glTranslatef(GLfloat x, GLfloat y, GLfloat z) {
@@ -436,8 +484,12 @@ void Batch::_glTranslatef(GLfloat x, GLfloat y, GLfloat z) { · 5 unmodified lines
436484
437485 DO_IT_NOW(_glTranslatef, 3);
438486 }
439−void Batch::do_glTranslatef(uint32& paramOffset) {
440− glTranslatef(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float);
487+void Batch::do_glTranslatef(uint32 paramOffset) {
488+ glTranslatef(
489+ _params[paramOffset + 2]._float,
490+ _params[paramOffset + 1]._float,
491+ _params[paramOffset + 0]._float);
492+ CHECK_GL_ERROR();
441493 }
442494
443495 void Batch::_glDrawArrays(GLenum mode, GLint first, GLsizei count) {
@@ -449,8 +501,12 @@ void Batch::_glDrawArrays(GLenum mode, GLint first, GLsizei count) { · 5 unmodified lines
449501
450502 DO_IT_NOW(_glDrawArrays, 3);
451503 }
452−void Batch::do_glDrawArrays(uint32& paramOffset) {
453− glDrawArrays(_params[paramOffset++]._uint, _params[paramOffset++]._int, _params[paramOffset++]._int);
504+void Batch::do_glDrawArrays(uint32 paramOffset) {
505+ glDrawArrays(
506+ _params[paramOffset + 2]._uint,
507+ _params[paramOffset + 1]._int,
508+ _params[paramOffset + 0]._int);
509+ CHECK_GL_ERROR();
454510 }
455511
456512 void Batch::_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices) {
@@ -463,14 +519,17 @@ void Batch::_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei · 6 unmodified lines
463519 _params.push_back(start);
464520 _params.push_back(mode);
465521
466− //do_glDrawRangeElements(_commandOffsets.back());
467− // runCommand(_commands.size() - 1);
468522 DO_IT_NOW(_glDrawRangeElements, 6);
469523 }
470−void Batch::do_glDrawRangeElements(uint32& paramOffset) {
471− glDrawRangeElements(_params[paramOffset++]._uint, _params[paramOffset++]._uint,
472− _params[paramOffset++]._uint, _params[paramOffset++]._int,
473− _params[paramOffset++]._uint, editResource(_params[paramOffset++]._uint)->_pointer);
524+void Batch::do_glDrawRangeElements(uint32 paramOffset) {
525+ glDrawRangeElements(
526+ _params[paramOffset + 5]._uint,
527+ _params[paramOffset + 4]._uint,
528+ _params[paramOffset + 3]._uint,
529+ _params[paramOffset + 2]._int,
530+ _params[paramOffset + 1]._uint,
531+ editResource(_params[paramOffset + 0]._uint)->_pointer);
532+ CHECK_GL_ERROR();
474533 }
475534
476535 void Batch::_glColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) {
@@ -483,9 +542,13 @@ void Batch::_glColorPointer(GLint size, GLenum type, GLsizei stride, const void · 6 unmodified lines
483542
484543 DO_IT_NOW(_glColorPointer, 4);
485544 }
486−void Batch::do_glColorPointer(uint32& paramOffset) {
487− glColorPointer(_params[paramOffset++]._int, _params[paramOffset++]._uint,
488− _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer);
545+void Batch::do_glColorPointer(uint32 paramOffset) {
546+ glColorPointer(
547+ _params[paramOffset + 3]._int,
548+ _params[paramOffset + 2]._uint,
549+ _params[paramOffset + 1]._int,
550+ editResource(_params[paramOffset + 0]._uint)->_pointer);
551+ CHECK_GL_ERROR();
489552 }
490553
491554 void Batch::_glNormalPointer(GLenum type, GLsizei stride, const void *pointer) {
@@ -497,9 +560,12 @@ void Batch::_glNormalPointer(GLenum type, GLsizei stride, const void *pointer) { · 5 unmodified lines
497560
498561 DO_IT_NOW(_glNormalPointer, 3);
499562 }
500−void Batch::do_glNormalPointer(uint32& paramOffset) {
501− glNormalPointer(_params[paramOffset++]._uint, _params[paramOffset++]._int,
502− editResource(_params[paramOffset++]._uint)->_pointer);
563+void Batch::do_glNormalPointer(uint32 paramOffset) {
564+ glNormalPointer(
565+ _params[paramOffset + 2]._uint,
566+ _params[paramOffset + 1]._int,
567+ editResource(_params[paramOffset + 0]._uint)->_pointer);
568+ CHECK_GL_ERROR();
503569 }
504570
505571 void Batch::_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) {
@@ -512,9 +578,13 @@ void Batch::_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const vo · 6 unmodified lines
512578
513579 DO_IT_NOW(_glTexCoordPointer, 4);
514580 }
515−void Batch::do_glTexCoordPointer(uint32& paramOffset) {
516− glTexCoordPointer(_params[paramOffset++]._int, _params[paramOffset++]._uint,
517− _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer);
581+void Batch::do_glTexCoordPointer(uint32 paramOffset) {
582+ glTexCoordPointer(
583+ _params[paramOffset + 3]._int,
584+ _params[paramOffset + 2]._uint,
585+ _params[paramOffset + 1]._int,
586+ editResource(_params[paramOffset + 0]._uint)->_pointer);
587+ CHECK_GL_ERROR();
518588 }
519589
520590 void Batch::_glVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) {
@@ -527,9 +597,13 @@ void Batch::_glVertexPointer(GLint size, GLenum type, GLsizei stride, const voi · 6 unmodified lines
527597
528598 DO_IT_NOW(_glVertexPointer, 4);
529599 }
530−void Batch::do_glVertexPointer(uint32& paramOffset) {
531− glVertexPointer(_params[paramOffset++]._int, _params[paramOffset++]._uint,
532− _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer);
600+void Batch::do_glVertexPointer(uint32 paramOffset) {
601+ glVertexPointer(
602+ _params[paramOffset + 3]._int,
603+ _params[paramOffset + 2]._uint,
604+ _params[paramOffset + 1]._int,
605+ editResource(_params[paramOffset + 0]._uint)->_pointer);
606+ CHECK_GL_ERROR();
533607 }
534608
535609
@@ -545,14 +619,17 @@ void Batch::_glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbool · 9 unmodified lines
545619
546620 DO_IT_NOW(_glVertexAttribPointer, 6);
547621 }
548−void Batch::do_glVertexAttribPointer(uint32& paramOffset) {
549− glVertexAttribPointer(_params[paramOffset++]._uint, _params[paramOffset++]._int,
550− _params[paramOffset++]._uint, _params[paramOffset++]._uint,
551− _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer);
622+void Batch::do_glVertexAttribPointer(uint32 paramOffset) {
623+ glVertexAttribPointer(
624+ _params[paramOffset + 5]._uint,
625+ _params[paramOffset + 4]._int,
626+ _params[paramOffset + 3]._uint,
627+ _params[paramOffset + 2]._uint,
628+ _params[paramOffset + 1]._int,
629+ editResource(_params[paramOffset + 0]._uint)->_pointer);
630+ CHECK_GL_ERROR();
552631 }
553632
554−
555−
556633 void Batch::_glEnableVertexAttribArray(GLint location) {
557634 ADD_COMMAND(glEnableVertexAttribArray);
558635
@@ -560,8 +637,9 @@ void Batch::_glEnableVertexAttribArray(GLint location) { · 1 unmodified line
560637
561638 DO_IT_NOW(_glEnableVertexAttribArray, 1);
562639 }
563−void Batch::do_glEnableVertexAttribArray(uint32& paramOffset) {
564− glEnableVertexAttribArray(_params[paramOffset++]._uint);
640+void Batch::do_glEnableVertexAttribArray(uint32 paramOffset) {
641+ glEnableVertexAttribArray(_params[paramOffset]._uint);
642+ CHECK_GL_ERROR();
565643 }
566644
567645 void Batch::_glDisableVertexAttribArray(GLint location) {
@@ -571,8 +649,9 @@ void Batch::_glDisableVertexAttribArray(GLint location) { · 3 unmodified lines
571649
572650 DO_IT_NOW(_glDisableVertexAttribArray, 1);
573651 }
574−void Batch::do_glDisableVertexAttribArray(uint32& paramOffset) {
575− glDisableVertexAttribArray(_params[paramOffset++]._uint);
652+void Batch::do_glDisableVertexAttribArray(uint32 paramOffset) {
653+ glDisableVertexAttribArray(_params[paramOffset]._uint);
654+ CHECK_GL_ERROR();
576655 }
577656
578657 void Batch::_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
@@ -585,8 +664,13 @@ void Batch::_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) · 6 unmodified lines
585664
586665 DO_IT_NOW(_glColor4f, 4);
587666 }
588−void Batch::do_glColor4f(uint32& paramOffset) {
589− glColor4f(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float);
667+void Batch::do_glColor4f(uint32 paramOffset) {
668+ glColor4f(
669+ _params[paramOffset + 3]._float,
670+ _params[paramOffset + 2]._float,
671+ _params[paramOffset + 1]._float,
672+ _params[paramOffset + 0]._float);
673+ CHECK_GL_ERROR();
590674 }
591675
592676 void Batch::_glMaterialf(GLenum face, GLenum pname, GLfloat param) {
@@ -598,8 +682,12 @@ void Batch::_glMaterialf(GLenum face, GLenum pname, GLfloat param) { · 5 unmodified lines
598682
599683 DO_IT_NOW(_glMaterialf, 3);
600684 }
601−void Batch::do_glMaterialf(uint32& paramOffset) {
602− glMaterialf(_params[paramOffset++]._uint, _params[paramOffset++]._uint, _params[paramOffset++]._float);
685+void Batch::do_glMaterialf(uint32 paramOffset) {
686+ glMaterialf(
687+ _params[paramOffset + 2]._uint,
688+ _params[paramOffset + 1]._uint,
689+ _params[paramOffset + 0]._float);
690+ CHECK_GL_ERROR();
603691 }
604692
605693 void Batch::_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) {
@@ -611,14 +699,55 @@ void Batch::_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) { · 5 unmodified lines
611699
612700 DO_IT_NOW(_glMaterialfv, 3);
613701 }
614−void Batch::do_glMaterialfv(uint32& paramOffset) {
615− glMaterialfv(_params[paramOffset++]._uint, _params[paramOffset++]._uint, (const GLfloat*) editData(_params[paramOffset++]._uint));
702+void Batch::do_glMaterialfv(uint32 paramOffset) {
703+ glMaterialfv(
704+ _params[paramOffset + 2]._uint,
705+ _params[paramOffset + 1]._uint,
706+ (const GLfloat*) editData(_params[paramOffset + 0]._uint));
707+ CHECK_GL_ERROR();
616708 }
617709
618710
619711
620712 void backend::renderBatch(Batch& batch) {
621− for (int i = 0; i < batch._commands.size(); i++) {
622− batch.runCommand(i);
713+ uint32 numCommands = batch._commands.size();
714+ Batch::CommandCall* call = batch._commandCalls.data();
715+ Batch::CommandOffsets::value_type* offset = batch._commandOffsets.data();
716+
717+ for (int i = 0; i < numCommands; i++) {
718+ (batch.*(*call))(*offset);
719+ call++;
720+ offset++;
623721 }
624722 }
723+
724+void backend::checkGLError() {
725+ GLenum error = glGetError();
726+ if (!error) {
727+ return;
728+ } else {
729+ switch (error) {
730+ case GL_INVALID_ENUM:
731+ qDebug() << "An unacceptable value is specified for an enumerated argument.The offending command is ignored and has no other side effect than to set the error flag.";
732+ break;
733+ case GL_INVALID_VALUE:
734+ qDebug() << "A numeric argument is out of range.The offending command is ignored and has no other side effect than to set the error flag";
735+ break;
736+ case GL_INVALID_OPERATION:
737+ qDebug() << "The specified operation is not allowed in the current state.The offending command is ignored and has no other side effect than to set the error flag..";
738+ break;
739+ case GL_INVALID_FRAMEBUFFER_OPERATION:
740+ qDebug() << "The framebuffer object is not complete.The offending command is ignored and has no other side effect than to set the error flag.";
741+ break;
742+ case GL_OUT_OF_MEMORY:
743+ qDebug() << "There is not enough memory left to execute the command.The state of the GL is undefined, except for the state of the error flags, after this error is recorded.";
744+ break;
745+ case GL_STACK_UNDERFLOW:
746+ qDebug() << "An attempt has been made to perform an operation that would cause an internal stack to underflow.";
747+ break;
748+ case GL_STACK_OVERFLOW:
749+ qDebug() << "An attempt has been made to perform an operation that would cause an internal stack to overflow.";
750+ break;
751+ }
752+ }
753+}