Showing the changes to interface/src/gpu/Batch.cpp (1 of 3 files). Show all
Unified · Split
| @@ -17,6 +17,8 @@ · 16 unmodified lines | |||
| 17 | //#define DO_IT_NOW(call, offset) runLastCommand(); | 17 | //#define DO_IT_NOW(call, offset) runLastCommand(); |
| 18 | #define DO_IT_NOW(call, offset) | 18 | #define DO_IT_NOW(call, offset) |
| 19 | 19 | ||
| 20 | #define CHECK_GL_ERROR() ::gpu::backend::checkGLError() | ||
| 21 | |||
| 20 | using namespace gpu; | 22 | using namespace gpu; |
| 21 | 23 | ||
| 22 | Batch::Batch() : | 24 | Batch::Batch() : |
| @@ -158,8 +160,9 @@ void Batch::_glEnable(GLenum cap) { · 135 unmodified lines | |||
| 158 | 160 | ||
| 159 | DO_IT_NOW(_glEnable, 1); | 161 | DO_IT_NOW(_glEnable, 1); |
| 160 | } | 162 | } |
| 161 | void Batch::do_glEnable(uint32& paramOffset) { | 163 | void Batch::do_glEnable(uint32 paramOffset) { |
| 162 | glEnable(_params[paramOffset++]._uint); | 164 | glEnable(_params[paramOffset]._uint); |
| 165 | CHECK_GL_ERROR(); | ||
| 163 | } | 166 | } |
| 164 | 167 | ||
| 165 | void Batch::_glDisable(GLenum cap) { | 168 | void Batch::_glDisable(GLenum cap) { |
| @@ -169,8 +172,9 @@ void Batch::_glDisable(GLenum cap) { · 3 unmodified lines | |||
| 169 | 172 | ||
| 170 | DO_IT_NOW(_glDisable, 1); | 173 | DO_IT_NOW(_glDisable, 1); |
| 171 | } | 174 | } |
| 172 | void Batch::do_glDisable(uint32& paramOffset) { | 175 | void Batch::do_glDisable(uint32 paramOffset) { |
| 173 | glDisable(_params[paramOffset++]._uint); | 176 | glDisable(_params[paramOffset]._uint); |
| 177 | CHECK_GL_ERROR(); | ||
| 174 | } | 178 | } |
| 175 | 179 | ||
| 176 | void Batch::_glEnableClientState(GLenum array) { | 180 | void Batch::_glEnableClientState(GLenum array) { |
| @@ -180,8 +184,9 @@ void Batch::_glEnableClientState(GLenum array) { · 3 unmodified lines | |||
| 180 | 184 | ||
| 181 | DO_IT_NOW(_glEnableClientState, 1 ); | 185 | DO_IT_NOW(_glEnableClientState, 1 ); |
| 182 | } | 186 | } |
| 183 | void Batch::do_glEnableClientState(uint32& paramOffset) { | 187 | void Batch::do_glEnableClientState(uint32 paramOffset) { |
| 184 | glEnableClientState(_params[paramOffset++]._uint); | 188 | glEnableClientState(_params[paramOffset]._uint); |
| 189 | CHECK_GL_ERROR(); | ||
| 185 | } | 190 | } |
| 186 | 191 | ||
| 187 | void Batch::_glDisableClientState(GLenum array) { | 192 | void Batch::_glDisableClientState(GLenum array) { |
| @@ -191,8 +196,9 @@ void Batch::_glDisableClientState(GLenum array) { · 3 unmodified lines | |||
| 191 | 196 | ||
| 192 | DO_IT_NOW(_glDisableClientState, 1); | 197 | DO_IT_NOW(_glDisableClientState, 1); |
| 193 | } | 198 | } |
| 194 | void Batch::do_glDisableClientState(uint32& paramOffset) { | 199 | void Batch::do_glDisableClientState(uint32 paramOffset) { |
| 195 | glDisableClientState(_params[paramOffset++]._uint); | 200 | glDisableClientState(_params[paramOffset]._uint); |
| 201 | CHECK_GL_ERROR(); | ||
| 196 | } | 202 | } |
| 197 | 203 | ||
| 198 | void Batch::_glCullFace(GLenum mode) { | 204 | void Batch::_glCullFace(GLenum mode) { |
| @@ -202,8 +208,9 @@ void Batch::_glCullFace(GLenum mode) { · 3 unmodified lines | |||
| 202 | 208 | ||
| 203 | DO_IT_NOW(_glCullFace, 1); | 209 | DO_IT_NOW(_glCullFace, 1); |
| 204 | } | 210 | } |
| 205 | void Batch::do_glCullFace(uint32& paramOffset) { | 211 | void Batch::do_glCullFace(uint32 paramOffset) { |
| 206 | glCullFace(_params[paramOffset++]._uint); | 212 | glCullFace(_params[paramOffset]._uint); |
| 213 | CHECK_GL_ERROR(); | ||
| 207 | } | 214 | } |
| 208 | 215 | ||
| 209 | void Batch::_glAlphaFunc(GLenum func, GLclampf ref) { | 216 | void Batch::_glAlphaFunc(GLenum func, GLclampf ref) { |
| @@ -214,8 +221,11 @@ void Batch::_glAlphaFunc(GLenum func, GLclampf ref) { · 4 unmodified lines | |||
| 214 | 221 | ||
| 215 | DO_IT_NOW(_glAlphaFunc, 2); | 222 | DO_IT_NOW(_glAlphaFunc, 2); |
| 216 | } | 223 | } |
| 217 | void Batch::do_glAlphaFunc(uint32& paramOffset) { | 224 | void Batch::do_glAlphaFunc(uint32 paramOffset) { |
| 218 | glAlphaFunc(_params[paramOffset++]._uint, _params[paramOffset++]._float); | 225 | glAlphaFunc( |
| 226 | _params[paramOffset + 1]._uint, | ||
| 227 | _params[paramOffset + 0]._float); | ||
| 228 | CHECK_GL_ERROR(); | ||
| 219 | } | 229 | } |
| 220 | 230 | ||
| 221 | void Batch::_glDepthFunc(GLenum func) { | 231 | void Batch::_glDepthFunc(GLenum func) { |
| @@ -225,8 +235,9 @@ void Batch::_glDepthFunc(GLenum func) { · 3 unmodified lines | |||
| 225 | 235 | ||
| 226 | DO_IT_NOW(_glDepthFunc, 1); | 236 | DO_IT_NOW(_glDepthFunc, 1); |
| 227 | } | 237 | } |
| 228 | void Batch::do_glDepthFunc(uint32& paramOffset) { | 238 | void Batch::do_glDepthFunc(uint32 paramOffset) { |
| 229 | glDepthFunc(_params[paramOffset++]._uint); | 239 | glDepthFunc(_params[paramOffset]._uint); |
| 240 | CHECK_GL_ERROR(); | ||
| 230 | } | 241 | } |
| 231 | 242 | ||
| 232 | void Batch::_glDepthMask(GLboolean flag) { | 243 | void Batch::_glDepthMask(GLboolean flag) { |
| @@ -236,8 +247,9 @@ void Batch::_glDepthMask(GLboolean flag) { · 3 unmodified lines | |||
| 236 | 247 | ||
| 237 | DO_IT_NOW(_glDepthMask, 1); | 248 | DO_IT_NOW(_glDepthMask, 1); |
| 238 | } | 249 | } |
| 239 | void Batch::do_glDepthMask(uint32& paramOffset) { | 250 | void Batch::do_glDepthMask(uint32 paramOffset) { |
| 240 | glDepthMask(_params[paramOffset++]._uint); | 251 | glDepthMask(_params[paramOffset]._uint); |
| 252 | CHECK_GL_ERROR(); | ||
| 241 | } | 253 | } |
| 242 | 254 | ||
| 243 | void Batch::_glDepthRange(GLclampd zNear, GLclampd zFar) { | 255 | void Batch::_glDepthRange(GLclampd zNear, GLclampd zFar) { |
| @@ -248,8 +260,11 @@ void Batch::_glDepthRange(GLclampd zNear, GLclampd zFar) { · 4 unmodified lines | |||
| 248 | 260 | ||
| 249 | DO_IT_NOW(_glDepthRange, 2); | 261 | DO_IT_NOW(_glDepthRange, 2); |
| 250 | } | 262 | } |
| 251 | void Batch::do_glDepthRange(uint32& paramOffset) { | 263 | void Batch::do_glDepthRange(uint32 paramOffset) { |
| 252 | glDepthRange(_params[paramOffset++]._double, _params[paramOffset++]._double); | 264 | glDepthRange( |
| 265 | _params[paramOffset + 1]._double, | ||
| 266 | _params[paramOffset + 0]._double); | ||
| 267 | CHECK_GL_ERROR(); | ||
| 253 | } | 268 | } |
| 254 | 269 | ||
| 255 | void Batch::_glBindBuffer(GLenum target, GLuint buffer) { | 270 | void Batch::_glBindBuffer(GLenum target, GLuint buffer) { |
| @@ -260,8 +275,11 @@ void Batch::_glBindBuffer(GLenum target, GLuint buffer) { · 4 unmodified lines | |||
| 260 | 275 | ||
| 261 | DO_IT_NOW(_glBindBuffer, 2); | 276 | DO_IT_NOW(_glBindBuffer, 2); |
| 262 | } | 277 | } |
| 263 | void Batch::do_glBindBuffer(uint32& paramOffset) { | 278 | void Batch::do_glBindBuffer(uint32 paramOffset) { |
| 264 | glBindBuffer(_params[paramOffset++]._uint, _params[paramOffset++]._uint); | 279 | glBindBuffer( |
| 280 | _params[paramOffset + 1]._uint, | ||
| 281 | _params[paramOffset + 0]._uint); | ||
| 282 | CHECK_GL_ERROR(); | ||
| 265 | } | 283 | } |
| 266 | 284 | ||
| 267 | void Batch::_glBindTexture(GLenum target, GLuint texture) { | 285 | void Batch::_glBindTexture(GLenum target, GLuint texture) { |
| @@ -272,8 +290,11 @@ void Batch::_glBindTexture(GLenum target, GLuint texture) { · 4 unmodified lines | |||
| 272 | 290 | ||
| 273 | DO_IT_NOW(_glBindTexture, 2); | 291 | DO_IT_NOW(_glBindTexture, 2); |
| 274 | } | 292 | } |
| 275 | void Batch::do_glBindTexture(uint32& paramOffset) { | 293 | void Batch::do_glBindTexture(uint32 paramOffset) { |
| 276 | glBindTexture(_params[paramOffset++]._uint, _params[paramOffset++]._uint); | 294 | glBindTexture( |
| 295 | _params[paramOffset + 1]._uint, | ||
| 296 | _params[paramOffset + 0]._uint); | ||
| 297 | CHECK_GL_ERROR(); | ||
| 277 | } | 298 | } |
| 278 | 299 | ||
| 279 | void Batch::_glActiveTexture(GLenum texture) { | 300 | void Batch::_glActiveTexture(GLenum texture) { |
| @@ -283,8 +304,9 @@ void Batch::_glActiveTexture(GLenum texture) { · 3 unmodified lines | |||
| 283 | 304 | ||
| 284 | DO_IT_NOW(_glActiveTexture, 1); | 305 | DO_IT_NOW(_glActiveTexture, 1); |
| 285 | } | 306 | } |
| 286 | void Batch::do_glActiveTexture(uint32& paramOffset) { | 307 | void Batch::do_glActiveTexture(uint32 paramOffset) { |
| 287 | glActiveTexture(_params[paramOffset++]._uint); | 308 | glActiveTexture(_params[paramOffset]._uint); |
| 309 | CHECK_GL_ERROR(); | ||
| 288 | } | 310 | } |
| 289 | 311 | ||
| 290 | void Batch::_glDrawBuffers(GLsizei n, const GLenum* bufs) { | 312 | void Batch::_glDrawBuffers(GLsizei n, const GLenum* bufs) { |
| @@ -295,8 +317,11 @@ void Batch::_glDrawBuffers(GLsizei n, const GLenum* bufs) { · 4 unmodified lines | |||
| 295 | 317 | ||
| 296 | DO_IT_NOW(_glDrawBuffers, 2); | 318 | DO_IT_NOW(_glDrawBuffers, 2); |
| 297 | } | 319 | } |
| 298 | void Batch::do_glDrawBuffers(uint32& paramOffset) { | 320 | void Batch::do_glDrawBuffers(uint32 paramOffset) { |
| 299 | glDrawBuffers(_params[paramOffset++]._uint, (const GLenum*) editData(_params[paramOffset++]._uint)); | 321 | glDrawBuffers( |
| 322 | _params[paramOffset + 1]._uint, | ||
| 323 | (const GLenum*) editData(_params[paramOffset + 0]._uint)); | ||
| 324 | CHECK_GL_ERROR(); | ||
| 300 | } | 325 | } |
| 301 | 326 | ||
| 302 | void Batch::_glUseProgram(GLuint program) { | 327 | void Batch::_glUseProgram(GLuint program) { |
| @@ -306,8 +331,9 @@ void Batch::_glUseProgram(GLuint program) { · 3 unmodified lines | |||
| 306 | 331 | ||
| 307 | DO_IT_NOW(_glUseProgram, 1); | 332 | DO_IT_NOW(_glUseProgram, 1); |
| 308 | } | 333 | } |
| 309 | void Batch::do_glUseProgram(uint32& paramOffset) { | 334 | void Batch::do_glUseProgram(uint32 paramOffset) { |
| 310 | glUseProgram(_params[paramOffset++]._uint); | 335 | glUseProgram(_params[paramOffset]._uint); |
| 336 | CHECK_GL_ERROR(); | ||
| 311 | } | 337 | } |
| 312 | 338 | ||
| 313 | void Batch::_glUniform1f(GLint location, GLfloat v0) { | 339 | void Batch::_glUniform1f(GLint location, GLfloat v0) { |
| @@ -318,8 +344,11 @@ void Batch::_glUniform1f(GLint location, GLfloat v0) { · 4 unmodified lines | |||
| 318 | 344 | ||
| 319 | DO_IT_NOW(_glUniform1f, 1); | 345 | DO_IT_NOW(_glUniform1f, 1); |
| 320 | } | 346 | } |
| 321 | void Batch::do_glUniform1f(uint32& paramOffset) { | 347 | void Batch::do_glUniform1f(uint32 paramOffset) { |
| 322 | glUniform1f(_params[paramOffset++]._int, _params[paramOffset++]._float); | 348 | glUniform1f( |
| 349 | _params[paramOffset + 1]._int, | ||
| 350 | _params[paramOffset + 0]._float); | ||
| 351 | CHECK_GL_ERROR(); | ||
| 323 | } | 352 | } |
| 324 | 353 | ||
| 325 | void Batch::_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { | 354 | 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 | |||
| 333 | 362 | ||
| 334 | DO_IT_NOW(_glUniformMatrix4fv, 4); | 363 | DO_IT_NOW(_glUniformMatrix4fv, 4); |
| 335 | } | 364 | } |
| 336 | void Batch::do_glUniformMatrix4fv(uint32& paramOffset) { | 365 | void Batch::do_glUniformMatrix4fv(uint32 paramOffset) { |
| 337 | glUniformMatrix4fv(_params[paramOffset++]._int, _params[paramOffset++]._uint, | 366 | glUniformMatrix4fv( |
| 338 | _params[paramOffset++]._uint, (const GLfloat*) editData(_params[paramOffset++]._uint)); | 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(); | ||
| 339 | } | 372 | } |
| 340 | 373 | ||
| 341 | void Batch::_glMatrixMode(GLenum mode) { | 374 | void Batch::_glMatrixMode(GLenum mode) { |
| @@ -345,8 +378,9 @@ void Batch::_glMatrixMode(GLenum mode) { · 3 unmodified lines | |||
| 345 | 378 | ||
| 346 | DO_IT_NOW(_glMatrixMode, 1); | 379 | DO_IT_NOW(_glMatrixMode, 1); |
| 347 | } | 380 | } |
| 348 | void Batch::do_glMatrixMode(uint32& paramOffset) { | 381 | void Batch::do_glMatrixMode(uint32 paramOffset) { |
| 349 | glMatrixMode(_params[paramOffset++]._uint); | 382 | glMatrixMode(_params[paramOffset]._uint); |
| 383 | CHECK_GL_ERROR(); | ||
| 350 | } | 384 | } |
| 351 | 385 | ||
| 352 | void Batch::_glPushMatrix() { | 386 | void Batch::_glPushMatrix() { |
| @@ -354,8 +388,9 @@ void Batch::_glPushMatrix() { · 1 unmodified line | |||
| 354 | 388 | ||
| 355 | DO_IT_NOW(_glPushMatrix, 0); | 389 | DO_IT_NOW(_glPushMatrix, 0); |
| 356 | } | 390 | } |
| 357 | void Batch::do_glPushMatrix(uint32& paramOffset) { | 391 | void Batch::do_glPushMatrix(uint32 paramOffset) { |
| 358 | glPushMatrix(); | 392 | glPushMatrix(); |
| 393 | CHECK_GL_ERROR(); | ||
| 359 | } | 394 | } |
| 360 | 395 | ||
| 361 | void Batch::_glPopMatrix() { | 396 | void Batch::_glPopMatrix() { |
| @@ -363,8 +398,9 @@ void Batch::_glPopMatrix() { · 1 unmodified line | |||
| 363 | 398 | ||
| 364 | DO_IT_NOW(_glPopMatrix, 0); | 399 | DO_IT_NOW(_glPopMatrix, 0); |
| 365 | } | 400 | } |
| 366 | void Batch::do_glPopMatrix(uint32& paramOffset) { | 401 | void Batch::do_glPopMatrix(uint32 paramOffset) { |
| 367 | glPopMatrix(); | 402 | glPopMatrix(); |
| 403 | CHECK_GL_ERROR(); | ||
| 368 | } | 404 | } |
| 369 | 405 | ||
| 370 | void Batch::_glMultMatrixf(const GLfloat *m) { | 406 | void Batch::_glMultMatrixf(const GLfloat *m) { |
| @@ -375,8 +411,9 @@ void Batch::_glMultMatrixf(const GLfloat *m) { · 4 unmodified lines | |||
| 375 | 411 | ||
| 376 | DO_IT_NOW(_glMultMatrixf, 1); | 412 | DO_IT_NOW(_glMultMatrixf, 1); |
| 377 | } | 413 | } |
| 378 | void Batch::do_glMultMatrixf(uint32& paramOffset) { | 414 | void Batch::do_glMultMatrixf(uint32 paramOffset) { |
| 379 | glMultMatrixf((const GLfloat*) editData(_params[paramOffset++]._uint)); | 415 | glMultMatrixf((const GLfloat*) editData(_params[paramOffset]._uint)); |
| 416 | CHECK_GL_ERROR(); | ||
| 380 | } | 417 | } |
| 381 | 418 | ||
| 382 | void Batch::_glLoadMatrixf(const GLfloat *m) { | 419 | void Batch::_glLoadMatrixf(const GLfloat *m) { |
| @@ -387,8 +424,9 @@ void Batch::_glLoadMatrixf(const GLfloat *m) { · 4 unmodified lines | |||
| 387 | 424 | ||
| 388 | DO_IT_NOW(_glLoadMatrixf, 1); | 425 | DO_IT_NOW(_glLoadMatrixf, 1); |
| 389 | } | 426 | } |
| 390 | void Batch::do_glLoadMatrixf(uint32& paramOffset) { | 427 | void Batch::do_glLoadMatrixf(uint32 paramOffset) { |
| 391 | glLoadMatrixf((const GLfloat*)editData(_params[paramOffset++]._uint)); | 428 | glLoadMatrixf((const GLfloat*)editData(_params[paramOffset]._uint)); |
| 429 | CHECK_GL_ERROR(); | ||
| 392 | } | 430 | } |
| 393 | 431 | ||
| 394 | void Batch::_glLoadIdentity(void) { | 432 | void Batch::_glLoadIdentity(void) { |
| @@ -396,8 +434,9 @@ void Batch::_glLoadIdentity(void) { · 1 unmodified line | |||
| 396 | 434 | ||
| 397 | DO_IT_NOW(_glLoadIdentity, 0); | 435 | DO_IT_NOW(_glLoadIdentity, 0); |
| 398 | } | 436 | } |
| 399 | void Batch::do_glLoadIdentity(uint32& paramOffset) { | 437 | void Batch::do_glLoadIdentity(uint32 paramOffset) { |
| 400 | glLoadIdentity(); | 438 | glLoadIdentity(); |
| 439 | CHECK_GL_ERROR(); | ||
| 401 | } | 440 | } |
| 402 | 441 | ||
| 403 | void Batch::_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { | 442 | 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 | |||
| 410 | 449 | ||
| 411 | DO_IT_NOW(_glRotatef, 4); | 450 | DO_IT_NOW(_glRotatef, 4); |
| 412 | } | 451 | } |
| 413 | void Batch::do_glRotatef(uint32& paramOffset) { | 452 | void Batch::do_glRotatef(uint32 paramOffset) { |
| 414 | glRotatef(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float); | 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(); | ||
| 415 | } | 459 | } |
| 416 | 460 | ||
| 417 | void Batch::_glScalef(GLfloat x, GLfloat y, GLfloat z) { | 461 | 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 | |||
| 423 | 467 | ||
| 424 | DO_IT_NOW(_glScalef, 3); | 468 | DO_IT_NOW(_glScalef, 3); |
| 425 | } | 469 | } |
| 426 | void Batch::do_glScalef(uint32& paramOffset) { | 470 | void Batch::do_glScalef(uint32 paramOffset) { |
| 427 | glScalef(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float); | 471 | glScalef( |
| 472 | _params[paramOffset + 2]._float, | ||
| 473 | _params[paramOffset + 1]._float, | ||
| 474 | _params[paramOffset + 0]._float); | ||
| 475 | CHECK_GL_ERROR(); | ||
| 428 | } | 476 | } |
| 429 | 477 | ||
| 430 | void Batch::_glTranslatef(GLfloat x, GLfloat y, GLfloat z) { | 478 | 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 | |||
| 436 | 484 | ||
| 437 | DO_IT_NOW(_glTranslatef, 3); | 485 | DO_IT_NOW(_glTranslatef, 3); |
| 438 | } | 486 | } |
| 439 | void Batch::do_glTranslatef(uint32& paramOffset) { | 487 | void Batch::do_glTranslatef(uint32 paramOffset) { |
| 440 | glTranslatef(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float); | 488 | glTranslatef( |
| 489 | _params[paramOffset + 2]._float, | ||
| 490 | _params[paramOffset + 1]._float, | ||
| 491 | _params[paramOffset + 0]._float); | ||
| 492 | CHECK_GL_ERROR(); | ||
| 441 | } | 493 | } |
| 442 | 494 | ||
| 443 | void Batch::_glDrawArrays(GLenum mode, GLint first, GLsizei count) { | 495 | 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 | |||
| 449 | 501 | ||
| 450 | DO_IT_NOW(_glDrawArrays, 3); | 502 | DO_IT_NOW(_glDrawArrays, 3); |
| 451 | } | 503 | } |
| 452 | void Batch::do_glDrawArrays(uint32& paramOffset) { | 504 | void Batch::do_glDrawArrays(uint32 paramOffset) { |
| 453 | glDrawArrays(_params[paramOffset++]._uint, _params[paramOffset++]._int, _params[paramOffset++]._int); | 505 | glDrawArrays( |
| 506 | _params[paramOffset + 2]._uint, | ||
| 507 | _params[paramOffset + 1]._int, | ||
| 508 | _params[paramOffset + 0]._int); | ||
| 509 | CHECK_GL_ERROR(); | ||
| 454 | } | 510 | } |
| 455 | 511 | ||
| 456 | void Batch::_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices) { | 512 | 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 | |||
| 463 | _params.push_back(start); | 519 | _params.push_back(start); |
| 464 | _params.push_back(mode); | 520 | _params.push_back(mode); |
| 465 | 521 | ||
| 466 | //do_glDrawRangeElements(_commandOffsets.back()); | ||
| 467 | // runCommand(_commands.size() - 1); | ||
| 468 | DO_IT_NOW(_glDrawRangeElements, 6); | 522 | DO_IT_NOW(_glDrawRangeElements, 6); |
| 469 | } | 523 | } |
| 470 | void Batch::do_glDrawRangeElements(uint32& paramOffset) { | 524 | void Batch::do_glDrawRangeElements(uint32 paramOffset) { |
| 471 | glDrawRangeElements(_params[paramOffset++]._uint, _params[paramOffset++]._uint, | 525 | glDrawRangeElements( |
| 472 | _params[paramOffset++]._uint, _params[paramOffset++]._int, | 526 | _params[paramOffset + 5]._uint, |
| 473 | _params[paramOffset++]._uint, editResource(_params[paramOffset++]._uint)->_pointer); | 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(); | ||
| 474 | } | 533 | } |
| 475 | 534 | ||
| 476 | void Batch::_glColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) { | 535 | 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 | |||
| 483 | 542 | ||
| 484 | DO_IT_NOW(_glColorPointer, 4); | 543 | DO_IT_NOW(_glColorPointer, 4); |
| 485 | } | 544 | } |
| 486 | void Batch::do_glColorPointer(uint32& paramOffset) { | 545 | void Batch::do_glColorPointer(uint32 paramOffset) { |
| 487 | glColorPointer(_params[paramOffset++]._int, _params[paramOffset++]._uint, | 546 | glColorPointer( |
| 488 | _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer); | 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(); | ||
| 489 | } | 552 | } |
| 490 | 553 | ||
| 491 | void Batch::_glNormalPointer(GLenum type, GLsizei stride, const void *pointer) { | 554 | 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 | |||
| 497 | 560 | ||
| 498 | DO_IT_NOW(_glNormalPointer, 3); | 561 | DO_IT_NOW(_glNormalPointer, 3); |
| 499 | } | 562 | } |
| 500 | void Batch::do_glNormalPointer(uint32& paramOffset) { | 563 | void Batch::do_glNormalPointer(uint32 paramOffset) { |
| 501 | glNormalPointer(_params[paramOffset++]._uint, _params[paramOffset++]._int, | 564 | glNormalPointer( |
| 502 | editResource(_params[paramOffset++]._uint)->_pointer); | 565 | _params[paramOffset + 2]._uint, |
| 566 | _params[paramOffset + 1]._int, | ||
| 567 | editResource(_params[paramOffset + 0]._uint)->_pointer); | ||
| 568 | CHECK_GL_ERROR(); | ||
| 503 | } | 569 | } |
| 504 | 570 | ||
| 505 | void Batch::_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) { | 571 | 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 | |||
| 512 | 578 | ||
| 513 | DO_IT_NOW(_glTexCoordPointer, 4); | 579 | DO_IT_NOW(_glTexCoordPointer, 4); |
| 514 | } | 580 | } |
| 515 | void Batch::do_glTexCoordPointer(uint32& paramOffset) { | 581 | void Batch::do_glTexCoordPointer(uint32 paramOffset) { |
| 516 | glTexCoordPointer(_params[paramOffset++]._int, _params[paramOffset++]._uint, | 582 | glTexCoordPointer( |
| 517 | _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer); | 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(); | ||
| 518 | } | 588 | } |
| 519 | 589 | ||
| 520 | void Batch::_glVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) { | 590 | 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 | |||
| 527 | 597 | ||
| 528 | DO_IT_NOW(_glVertexPointer, 4); | 598 | DO_IT_NOW(_glVertexPointer, 4); |
| 529 | } | 599 | } |
| 530 | void Batch::do_glVertexPointer(uint32& paramOffset) { | 600 | void Batch::do_glVertexPointer(uint32 paramOffset) { |
| 531 | glVertexPointer(_params[paramOffset++]._int, _params[paramOffset++]._uint, | 601 | glVertexPointer( |
| 532 | _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer); | 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(); | ||
| 533 | } | 607 | } |
| 534 | 608 | ||
| 535 | 609 | ||
| @@ -545,14 +619,17 @@ void Batch::_glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbool · 9 unmodified lines | |||
| 545 | 619 | ||
| 546 | DO_IT_NOW(_glVertexAttribPointer, 6); | 620 | DO_IT_NOW(_glVertexAttribPointer, 6); |
| 547 | } | 621 | } |
| 548 | void Batch::do_glVertexAttribPointer(uint32& paramOffset) { | 622 | void Batch::do_glVertexAttribPointer(uint32 paramOffset) { |
| 549 | glVertexAttribPointer(_params[paramOffset++]._uint, _params[paramOffset++]._int, | 623 | glVertexAttribPointer( |
| 550 | _params[paramOffset++]._uint, _params[paramOffset++]._uint, | 624 | _params[paramOffset + 5]._uint, |
| 551 | _params[paramOffset++]._int, editResource(_params[paramOffset++]._uint)->_pointer); | 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(); | ||
| 552 | } | 631 | } |
| 553 | 632 | ||
| 554 | |||
| 555 | |||
| 556 | void Batch::_glEnableVertexAttribArray(GLint location) { | 633 | void Batch::_glEnableVertexAttribArray(GLint location) { |
| 557 | ADD_COMMAND(glEnableVertexAttribArray); | 634 | ADD_COMMAND(glEnableVertexAttribArray); |
| 558 | 635 | ||
| @@ -560,8 +637,9 @@ void Batch::_glEnableVertexAttribArray(GLint location) { · 1 unmodified line | |||
| 560 | 637 | ||
| 561 | DO_IT_NOW(_glEnableVertexAttribArray, 1); | 638 | DO_IT_NOW(_glEnableVertexAttribArray, 1); |
| 562 | } | 639 | } |
| 563 | void Batch::do_glEnableVertexAttribArray(uint32& paramOffset) { | 640 | void Batch::do_glEnableVertexAttribArray(uint32 paramOffset) { |
| 564 | glEnableVertexAttribArray(_params[paramOffset++]._uint); | 641 | glEnableVertexAttribArray(_params[paramOffset]._uint); |
| 642 | CHECK_GL_ERROR(); | ||
| 565 | } | 643 | } |
| 566 | 644 | ||
| 567 | void Batch::_glDisableVertexAttribArray(GLint location) { | 645 | void Batch::_glDisableVertexAttribArray(GLint location) { |
| @@ -571,8 +649,9 @@ void Batch::_glDisableVertexAttribArray(GLint location) { · 3 unmodified lines | |||
| 571 | 649 | ||
| 572 | DO_IT_NOW(_glDisableVertexAttribArray, 1); | 650 | DO_IT_NOW(_glDisableVertexAttribArray, 1); |
| 573 | } | 651 | } |
| 574 | void Batch::do_glDisableVertexAttribArray(uint32& paramOffset) { | 652 | void Batch::do_glDisableVertexAttribArray(uint32 paramOffset) { |
| 575 | glDisableVertexAttribArray(_params[paramOffset++]._uint); | 653 | glDisableVertexAttribArray(_params[paramOffset]._uint); |
| 654 | CHECK_GL_ERROR(); | ||
| 576 | } | 655 | } |
| 577 | 656 | ||
| 578 | void Batch::_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { | 657 | 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 | |||
| 585 | 664 | ||
| 586 | DO_IT_NOW(_glColor4f, 4); | 665 | DO_IT_NOW(_glColor4f, 4); |
| 587 | } | 666 | } |
| 588 | void Batch::do_glColor4f(uint32& paramOffset) { | 667 | void Batch::do_glColor4f(uint32 paramOffset) { |
| 589 | glColor4f(_params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float, _params[paramOffset++]._float); | 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(); | ||
| 590 | } | 674 | } |
| 591 | 675 | ||
| 592 | void Batch::_glMaterialf(GLenum face, GLenum pname, GLfloat param) { | 676 | 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 | |||
| 598 | 682 | ||
| 599 | DO_IT_NOW(_glMaterialf, 3); | 683 | DO_IT_NOW(_glMaterialf, 3); |
| 600 | } | 684 | } |
| 601 | void Batch::do_glMaterialf(uint32& paramOffset) { | 685 | void Batch::do_glMaterialf(uint32 paramOffset) { |
| 602 | glMaterialf(_params[paramOffset++]._uint, _params[paramOffset++]._uint, _params[paramOffset++]._float); | 686 | glMaterialf( |
| 687 | _params[paramOffset + 2]._uint, | ||
| 688 | _params[paramOffset + 1]._uint, | ||
| 689 | _params[paramOffset + 0]._float); | ||
| 690 | CHECK_GL_ERROR(); | ||
| 603 | } | 691 | } |
| 604 | 692 | ||
| 605 | void Batch::_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) { | 693 | 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 | |||
| 611 | 699 | ||
| 612 | DO_IT_NOW(_glMaterialfv, 3); | 700 | DO_IT_NOW(_glMaterialfv, 3); |
| 613 | } | 701 | } |
| 614 | void Batch::do_glMaterialfv(uint32& paramOffset) { | 702 | void Batch::do_glMaterialfv(uint32 paramOffset) { |
| 615 | glMaterialfv(_params[paramOffset++]._uint, _params[paramOffset++]._uint, (const GLfloat*) editData(_params[paramOffset++]._uint)); | 703 | glMaterialfv( |
| 704 | _params[paramOffset + 2]._uint, | ||
| 705 | _params[paramOffset + 1]._uint, | ||
| 706 | (const GLfloat*) editData(_params[paramOffset + 0]._uint)); | ||
| 707 | CHECK_GL_ERROR(); | ||
| 616 | } | 708 | } |
| 617 | 709 | ||
| 618 | 710 | ||
| 619 | 711 | ||
| 620 | void backend::renderBatch(Batch& batch) { | 712 | void backend::renderBatch(Batch& batch) { |
| 621 | for (int i = 0; i < batch._commands.size(); i++) { | 713 | uint32 numCommands = batch._commands.size(); |
| 622 | batch.runCommand(i); | 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++; | ||
| 623 | } | 721 | } |
| 624 | } | 722 | } |
| 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 | } | ||