Showing the changes to interface/src/gpu/GLBackend.cpp (1 of 9 files). Show all
Unified · Split
| @@ -18,6 +18,14 @@ using namespace gpu; · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = |
| 20 | 20 | { |
| 21 | + (&::gpu::GLBackend::do_draw), | |
| 22 | + (&::gpu::GLBackend::do_drawIndexed), | |
| 23 | + (&::gpu::GLBackend::do_drawInstanced), | |
| 24 | + (&::gpu::GLBackend::do_drawIndexedInstanced), | |
| 25 | + | |
| 26 | + (&::gpu::GLBackend::do_setInputStream), | |
| 27 | + (&::gpu::GLBackend::do_setInputFormat), | |
| 28 | + | |
| 21 | 29 | (&::gpu::GLBackend::do_glEnable), |
| 22 | 30 | (&::gpu::GLBackend::do_glDisable), |
| 23 | 31 | |
| @@ -70,8 +78,42 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = · 46 unmodified lines | ||
| 70 | 78 | (&::gpu::GLBackend::do_glMaterialfv), |
| 71 | 79 | }; |
| 72 | 80 | |
| 81 | +const GLenum GLBackend::_primitiveToGLmode[NUM_PRIMITIVES] = { | |
| 82 | + GL_POINTS, | |
| 83 | + GL_LINES, | |
| 84 | + GL_LINE_STRIP, | |
| 85 | + GL_TRIANGLES, | |
| 86 | + GL_TRIANGLE_STRIP, | |
| 87 | + GL_QUADS, | |
| 88 | +}; | |
| 73 | 89 | |
| 74 | −GLBackend::GLBackend() { | |
| 90 | +static const GLenum _elementTypeToGLType[Element::NUM_TYPES]= { | |
| 91 | + GL_FLOAT, | |
| 92 | + GL_INT, | |
| 93 | + GL_UNSIGNED_INT, | |
| 94 | + GL_HALF_FLOAT, | |
| 95 | + GL_SHORT, | |
| 96 | + GL_UNSIGNED_SHORT, | |
| 97 | + GL_BYTE, | |
| 98 | + GL_UNSIGNED_BYTE, | |
| 99 | + GL_FLOAT, | |
| 100 | + GL_INT, | |
| 101 | + GL_UNSIGNED_INT, | |
| 102 | + GL_HALF_FLOAT, | |
| 103 | + GL_SHORT, | |
| 104 | + GL_UNSIGNED_SHORT, | |
| 105 | + GL_BYTE, | |
| 106 | + GL_UNSIGNED_BYTE | |
| 107 | +}; | |
| 108 | + | |
| 109 | + | |
| 110 | +GLBackend::GLBackend() : | |
| 111 | + _inputFormat(0), | |
| 112 | + _inputStream(0), | |
| 113 | + _needInputFormatUpdate(true), | |
| 114 | + _needInputStreamUpdate(true), | |
| 115 | + _inputAttributeActivation(0) | |
| 116 | +{ | |
| 75 | 117 | |
| 76 | 118 | } |
| 77 | 119 | |
| @@ -87,7 +129,7 @@ void GLBackend::renderBatch(Batch& batch) { · 9 unmodified lines | ||
| 87 | 129 | GLBackend backend; |
| 88 | 130 | |
| 89 | 131 | for (int i = 0; i < numCommands; i++) { |
| 90 | − CommandCall call = _commandCalls[((*command) - Batch::COMMAND_glEnable)]; | |
| 132 | + CommandCall call = _commandCalls[(*command)]; | |
| 91 | 133 | (backend.*(call))(batch, *offset); |
| 92 | 134 | command++; |
| 93 | 135 | offset++; |
| @@ -126,24 +168,239 @@ void GLBackend::checkGLError() { · 32 unmodified lines | ||
| 126 | 168 | } |
| 127 | 169 | } |
| 128 | 170 | |
| 171 | +#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError() | |
| 172 | +//#define CHECK_GL_ERROR() | |
| 173 | + | |
| 174 | +void GLBackend::do_draw(Batch& batch, uint32 paramOffset) { | |
| 175 | + updateInput(); | |
| 176 | + | |
| 177 | + Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint; | |
| 178 | + GLenum mode = _primitiveToGLmode[primitiveType]; | |
| 179 | + uint32 numVertices = batch._params[paramOffset + 1]._uint; | |
| 180 | + uint32 startVertex = batch._params[paramOffset + 0]._uint; | |
| 181 | + | |
| 182 | + glDrawArrays(mode, startVertex, numVertices); | |
| 183 | + CHECK_GL_ERROR(); | |
| 184 | +} | |
| 185 | + | |
| 186 | +void GLBackend::do_drawIndexed(Batch& batch, uint32 paramOffset) { | |
| 187 | + updateInput(); | |
| 188 | + | |
| 189 | + Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint; | |
| 190 | + GLenum mode = _primitiveToGLmode[primitiveType]; | |
| 191 | + uint32 numIndices = batch._params[paramOffset + 1]._uint; | |
| 192 | + uint32 startIndex = batch._params[paramOffset + 0]._uint; | |
| 193 | + | |
| 194 | + glDrawElements(mode, numIndices, GL_UNSIGNED_INT, (GLvoid*) startIndex); | |
| 195 | + CHECK_GL_ERROR(); | |
| 196 | +} | |
| 197 | + | |
| 198 | +void GLBackend::do_drawInstanced(Batch& batch, uint32 paramOffset) { | |
| 199 | + CHECK_GL_ERROR(); | |
| 200 | +} | |
| 201 | + | |
| 202 | +void GLBackend::do_drawIndexedInstanced(Batch& batch, uint32 paramOffset) { | |
| 203 | + CHECK_GL_ERROR(); | |
| 204 | +} | |
| 205 | + | |
| 206 | + | |
| 207 | +void GLBackend::do_setInputStream(Batch& batch, uint32 paramOffset) { | |
| 208 | + const Stream* stream = reinterpret_cast<const Stream*>(batch.editResource(batch._params[paramOffset]._uint)->_pointer); | |
| 209 | + | |
| 210 | + if (stream != _inputStream) { | |
| 211 | + _inputStream = stream; | |
| 212 | + _needInputStreamUpdate = true; | |
| 213 | + } | |
| 214 | +} | |
| 215 | + | |
| 216 | +void GLBackend::do_setInputFormat(Batch& batch, uint32 paramOffset) { | |
| 217 | + const StreamFormat* format = reinterpret_cast<const StreamFormat*>(batch.editResource(batch._params[paramOffset]._uint)->_pointer); | |
| 218 | + | |
| 219 | + if (format != _inputFormat) { | |
| 220 | + _inputFormat = format; | |
| 221 | + _needInputFormatUpdate = true; | |
| 222 | + } | |
| 223 | +} | |
| 224 | + | |
| 225 | +#define SUPPORT_LEGACY_OPENGL | |
| 226 | +#if defined(SUPPORT_LEGACY_OPENGL) | |
| 227 | +static const int NUM_CLASSIC_ATTRIBS = StreamFormat::SLOT_TANGENT; | |
| 228 | +static const GLenum attributeSlotToClassicAttribName[NUM_CLASSIC_ATTRIBS] = { | |
| 229 | + GL_VERTEX_ARRAY, | |
| 230 | + GL_NORMAL_ARRAY, | |
| 231 | + GL_TEXTURE_COORD_ARRAY, | |
| 232 | + GL_COLOR_ARRAY | |
| 233 | +}; | |
| 234 | +#endif | |
| 235 | + | |
| 236 | +void GLBackend::updateInput() { | |
| 237 | + if (_needInputFormatUpdate || _needInputStreamUpdate) { | |
| 238 | + | |
| 239 | + if (_needInputFormatUpdate) { | |
| 240 | + InputActivationCache newActivation; | |
| 241 | + | |
| 242 | + // Check expected activation | |
| 243 | + if (_inputFormat) { | |
| 244 | + const StreamFormat::AttributeMap& attributes = _inputFormat->getAttributes(); | |
| 245 | + for (StreamFormat::AttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++) { | |
| 246 | + const StreamFormat::Attribute& attrib = (*it).second; | |
| 247 | + newActivation.set(attrib._slot); | |
| 248 | + } | |
| 249 | + } | |
| 250 | + | |
| 251 | + // Manage Activation what was and what is expected now | |
| 252 | + for (int i = 0; i < newActivation.size(); i++) { | |
| 253 | + bool newState = newActivation[i]; | |
| 254 | + if (newState != _inputAttributeActivation[i]) { | |
| 255 | +#if defined(SUPPORT_LEGACY_OPENGL) | |
| 256 | + if (i < NUM_CLASSIC_ATTRIBS) { | |
| 257 | + if (newState) { | |
| 258 | + glEnableClientState(attributeSlotToClassicAttribName[i]); | |
| 259 | + } | |
| 260 | + else { | |
| 261 | + glDisableClientState(attributeSlotToClassicAttribName[i]); | |
| 262 | + } | |
| 263 | + } else { | |
| 264 | +#else | |
| 265 | + { | |
| 266 | +#endif | |
| 267 | + if (newState) { | |
| 268 | + glEnableVertexAttribArray(i); | |
| 269 | + } else { | |
| 270 | + glDisableVertexAttribArray(i); | |
| 271 | + } | |
| 272 | + } | |
| 273 | + CHECK_GL_ERROR(); | |
| 274 | + | |
| 275 | + _inputAttributeActivation.flip(i); | |
| 276 | + } | |
| 277 | + } | |
| 278 | + } | |
| 279 | + | |
| 280 | + // now we need to bind the buffers and assign the attrib pointers | |
| 281 | + if (_inputStream && _inputFormat) { | |
| 282 | + const Stream::Buffers& buffers = _inputStream->getBuffers(); | |
| 283 | + const Stream::Offsets& offsets = _inputStream->getOffsets(); | |
| 284 | + const Stream::Strides& strides = _inputStream->getStrides(); | |
| 285 | + | |
| 286 | + const StreamFormat::AttributeMap& attributes = _inputFormat->getAttributes(); | |
| 287 | + | |
| 288 | + for (StreamFormat::ChannelMap::const_iterator channelIt = _inputFormat->getChannels().begin(); | |
| 289 | + channelIt != _inputFormat->getChannels().end(); | |
| 290 | + channelIt++) { | |
| 291 | + const StreamFormat::ChannelMap::value_type::second_type& channel = (*channelIt).second; | |
| 292 | + if ((*channelIt).first < buffers.size()) { | |
| 293 | + int bufferNum = (*channelIt).first; | |
| 294 | + GLuint vbo = gpu::GLBackend::getBufferID((*buffers[bufferNum])); | |
| 295 | + glBindBuffer(GL_ARRAY_BUFFER, vbo); | |
| 296 | + CHECK_GL_ERROR(); | |
| 297 | + | |
| 298 | + for (int i = 0; i < channel._slots.size(); i++) { | |
| 299 | + const StreamFormat::Attribute& attrib = attributes.at(channel._slots[i]); | |
| 300 | + GLuint count = attrib._element.getDimensionCount(); | |
| 301 | + GLenum type = _elementTypeToGLType[attrib._element.getType()]; | |
| 302 | + GLuint stride = strides[bufferNum]; | |
| 303 | + GLuint pointer = attrib._offset + offsets[bufferNum]; | |
| 304 | +#if defined(SUPPORT_LEGACY_OPENGL) | |
| 305 | + if (attrib._slot < NUM_CLASSIC_ATTRIBS) { | |
| 306 | + switch (attrib._slot) { | |
| 307 | + case StreamFormat::SLOT_POSITION: | |
| 308 | + glVertexPointer(count, type, stride, (GLvoid*)pointer); | |
| 309 | + break; | |
| 310 | + case StreamFormat::SLOT_COLOR: | |
| 311 | + glColorPointer(count, type, stride, (GLvoid*)pointer); | |
| 312 | + break; | |
| 313 | + case StreamFormat::SLOT_TEXCOORD: | |
| 314 | + glTexCoordPointer(count, type, stride, (GLvoid*)pointer); | |
| 315 | + break; | |
| 316 | + case StreamFormat::SLOT_NORMAL: | |
| 317 | + glNormalPointer(type, stride, (GLvoid*)pointer); | |
| 318 | + break; | |
| 319 | + }; | |
| 320 | + } else { | |
| 321 | +#else | |
| 322 | + { | |
| 323 | +#endif | |
| 324 | + glVertexAttribPointer(attrib._slot, count, type, attrib._element.isNormalized(), stride, (GLvoid*)pointer); | |
| 325 | + } | |
| 326 | + CHECK_GL_ERROR(); | |
| 327 | + } | |
| 328 | + } | |
| 329 | + } | |
| 330 | + } | |
| 331 | + | |
| 332 | + _needInputStreamUpdate = false; | |
| 333 | + _needInputFormatUpdate = false; | |
| 334 | + } | |
| 335 | + | |
| 336 | +/* Fancy version GL4.4 | |
| 337 | + if (_needInputFormatUpdate) { | |
| 338 | + | |
| 339 | + InputActivationCache newActivation; | |
| 340 | + | |
| 341 | + // Assign the vertex format required | |
| 342 | + if (_inputFormat) { | |
| 343 | + const StreamFormat::AttributeMap& attributes = _inputFormat->getAttributes(); | |
| 344 | + for (StreamFormat::AttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++) { | |
| 345 | + const StreamFormat::Attribute& attrib = (*it).second; | |
| 346 | + newActivation.set(attrib._slot); | |
| 347 | + glVertexAttribFormat( | |
| 348 | + attrib._slot, | |
| 349 | + attrib._element.getDimensionCount(), | |
| 350 | + _elementTypeToGLType[attrib._element.getType()], | |
| 351 | + attrib._element.isNormalized(), | |
| 352 | + attrib._stride); | |
| 353 | + } | |
| 354 | + CHECK_GL_ERROR(); | |
| 355 | + } | |
| 356 | + | |
| 357 | + // Manage Activation what was and what is expected now | |
| 358 | + for (int i = 0; i < newActivation.size(); i++) { | |
| 359 | + bool newState = newActivation[i]; | |
| 360 | + if (newState != _inputAttributeActivation[i]) { | |
| 361 | + if (newState) { | |
| 362 | + glEnableVertexAttribArray(i); | |
| 363 | + } else { | |
| 364 | + glDisableVertexAttribArray(i); | |
| 365 | + } | |
| 366 | + _inputAttributeActivation.flip(i); | |
| 367 | + } | |
| 368 | + } | |
| 369 | + CHECK_GL_ERROR(); | |
| 370 | + | |
| 371 | + _needInputFormatUpdate = false; | |
| 372 | + } | |
| 373 | + | |
| 374 | + if (_needInputStreamUpdate) { | |
| 375 | + if (_inputStream) { | |
| 376 | + const Stream::Buffers& buffers = _inputStream->getBuffers(); | |
| 377 | + const Stream::Offsets& offsets = _inputStream->getOffsets(); | |
| 378 | + const Stream::Strides& strides = _inputStream->getStrides(); | |
| 379 | + | |
| 380 | + for (int i = 0; i < buffers.size(); i++) { | |
| 381 | + GLuint vbo = gpu::GLBackend::getBufferID((*buffers[i])); | |
| 382 | + glBindVertexBuffer(i, vbo, offsets[i], strides[i]); | |
| 383 | + } | |
| 384 | + | |
| 385 | + CHECK_GL_ERROR(); | |
| 386 | + } | |
| 387 | + _needInputStreamUpdate = false; | |
| 388 | + } | |
| 389 | +*/ | |
| 390 | +} | |
| 129 | 391 | |
| 130 | 392 | // TODO: As long as we have gl calls explicitely issued from interface |
| 131 | 393 | // code, we need to be able to record and batch these calls. THe long |
| 132 | 394 | // term strategy is to get rid of any GL calls in favor of the HIFI GPU API |
| 133 | 395 | |
| 134 | −//#define ADD_COMMAND(call) _commands.push_back(COMMAND_##call); _commandCalls.push_back(&gpu::Batch::do_##call); _commandOffsets.push_back(_params.size()); | |
| 135 | −#define ADD_COMMAND(call) _commands.push_back(COMMAND_##call); _commandOffsets.push_back(_params.size()); | |
| 136 | −//#define ADD_COMMAND_GL(call) _commands.push_back(COMMAND_##call); _commandCalls.push_back(&gpu::GLBackend::do_##call); _commandOffsets.push_back(_params.size()); | |
| 137 | 396 | #define ADD_COMMAND_GL(call) _commands.push_back(COMMAND_##call); _commandOffsets.push_back(_params.size()); |
| 138 | 397 | |
| 139 | 398 | //#define DO_IT_NOW(call, offset) runLastCommand(); |
| 140 | 399 | #define DO_IT_NOW(call, offset) |
| 141 | 400 | |
| 142 | −//#define CHECK_GL_ERROR() ::gpu::backend::checkGLError() | |
| 143 | −#define CHECK_GL_ERROR() | |
| 144 | 401 | |
| 145 | 402 | void Batch::_glEnable(GLenum cap) { |
| 146 | − ADD_COMMAND(glEnable); | |
| 403 | + ADD_COMMAND_GL(glEnable); | |
| 147 | 404 | |
| 148 | 405 | _params.push_back(cap); |
| 149 | 406 | |
| @@ -155,7 +412,7 @@ void GLBackend::do_glEnable(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 155 | 412 | } |
| 156 | 413 | |
| 157 | 414 | void Batch::_glDisable(GLenum cap) { |
| 158 | − ADD_COMMAND(glDisable); | |
| 415 | + ADD_COMMAND_GL(glDisable); | |
| 159 | 416 | |
| 160 | 417 | _params.push_back(cap); |
| 161 | 418 | |
| @@ -167,7 +424,7 @@ void GLBackend::do_glDisable(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 167 | 424 | } |
| 168 | 425 | |
| 169 | 426 | void Batch::_glEnableClientState(GLenum array) { |
| 170 | − ADD_COMMAND(glEnableClientState); | |
| 427 | + ADD_COMMAND_GL(glEnableClientState); | |
| 171 | 428 | |
| 172 | 429 | _params.push_back(array); |
| 173 | 430 | |
| @@ -179,7 +436,7 @@ void GLBackend::do_glEnableClientState(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 179 | 436 | } |
| 180 | 437 | |
| 181 | 438 | void Batch::_glDisableClientState(GLenum array) { |
| 182 | − ADD_COMMAND(glDisableClientState); | |
| 439 | + ADD_COMMAND_GL(glDisableClientState); | |
| 183 | 440 | |
| 184 | 441 | _params.push_back(array); |
| 185 | 442 | |
| @@ -191,7 +448,7 @@ void GLBackend::do_glDisableClientState(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 191 | 448 | } |
| 192 | 449 | |
| 193 | 450 | void Batch::_glCullFace(GLenum mode) { |
| 194 | − ADD_COMMAND(glCullFace); | |
| 451 | + ADD_COMMAND_GL(glCullFace); | |
| 195 | 452 | |
| 196 | 453 | _params.push_back(mode); |
| 197 | 454 | |
| @@ -203,7 +460,7 @@ void GLBackend::do_glCullFace(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 203 | 460 | } |
| 204 | 461 | |
| 205 | 462 | void Batch::_glAlphaFunc(GLenum func, GLclampf ref) { |
| 206 | − ADD_COMMAND(glAlphaFunc); | |
| 463 | + ADD_COMMAND_GL(glAlphaFunc); | |
| 207 | 464 | |
| 208 | 465 | _params.push_back(ref); |
| 209 | 466 | _params.push_back(func); |
| @@ -218,7 +475,7 @@ void GLBackend::do_glAlphaFunc(Batch& batch, uint32 paramOffset) { · 8 unmodified lines | ||
| 218 | 475 | } |
| 219 | 476 | |
| 220 | 477 | void Batch::_glDepthFunc(GLenum func) { |
| 221 | − ADD_COMMAND(glDepthFunc); | |
| 478 | + ADD_COMMAND_GL(glDepthFunc); | |
| 222 | 479 | |
| 223 | 480 | _params.push_back(func); |
| 224 | 481 | |
| @@ -230,7 +487,7 @@ void GLBackend::do_glDepthFunc(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 230 | 487 | } |
| 231 | 488 | |
| 232 | 489 | void Batch::_glDepthMask(GLboolean flag) { |
| 233 | − ADD_COMMAND(glDepthMask); | |
| 490 | + ADD_COMMAND_GL(glDepthMask); | |
| 234 | 491 | |
| 235 | 492 | _params.push_back(flag); |
| 236 | 493 | |
| @@ -242,7 +499,7 @@ void GLBackend::do_glDepthMask(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 242 | 499 | } |
| 243 | 500 | |
| 244 | 501 | void Batch::_glDepthRange(GLclampd zNear, GLclampd zFar) { |
| 245 | − ADD_COMMAND(glDepthRange); | |
| 502 | + ADD_COMMAND_GL(glDepthRange); | |
| 246 | 503 | |
| 247 | 504 | _params.push_back(zFar); |
| 248 | 505 | _params.push_back(zNear); |
| @@ -257,7 +514,7 @@ void GLBackend::do_glDepthRange(Batch& batch, uint32 paramOffset) { · 8 unmodified lines | ||
| 257 | 514 | } |
| 258 | 515 | |
| 259 | 516 | void Batch::_glBindBuffer(GLenum target, GLuint buffer) { |
| 260 | − ADD_COMMAND(glBindBuffer); | |
| 517 | + ADD_COMMAND_GL(glBindBuffer); | |
| 261 | 518 | |
| 262 | 519 | _params.push_back(buffer); |
| 263 | 520 | _params.push_back(target); |
| @@ -272,7 +529,7 @@ void GLBackend::do_glBindBuffer(Batch& batch, uint32 paramOffset) { · 8 unmodified lines | ||
| 272 | 529 | } |
| 273 | 530 | |
| 274 | 531 | void Batch::_glBindTexture(GLenum target, GLuint texture) { |
| 275 | − ADD_COMMAND(glBindTexture); | |
| 532 | + ADD_COMMAND_GL(glBindTexture); | |
| 276 | 533 | |
| 277 | 534 | _params.push_back(texture); |
| 278 | 535 | _params.push_back(target); |
| @@ -287,7 +544,7 @@ void GLBackend::do_glBindTexture(Batch& batch, uint32 paramOffset) { · 8 unmodified lines | ||
| 287 | 544 | } |
| 288 | 545 | |
| 289 | 546 | void Batch::_glActiveTexture(GLenum texture) { |
| 290 | − ADD_COMMAND(glActiveTexture); | |
| 547 | + ADD_COMMAND_GL(glActiveTexture); | |
| 291 | 548 | |
| 292 | 549 | _params.push_back(texture); |
| 293 | 550 | |
| @@ -299,7 +556,7 @@ void GLBackend::do_glActiveTexture(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 299 | 556 | } |
| 300 | 557 | |
| 301 | 558 | void Batch::_glDrawBuffers(GLsizei n, const GLenum* bufs) { |
| 302 | − ADD_COMMAND(glDrawBuffers); | |
| 559 | + ADD_COMMAND_GL(glDrawBuffers); | |
| 303 | 560 | |
| 304 | 561 | _params.push_back(cacheData(n * sizeof(GLenum), bufs)); |
| 305 | 562 | _params.push_back(n); |
| @@ -314,7 +571,7 @@ void GLBackend::do_glDrawBuffers(Batch& batch, uint32 paramOffset) { · 8 unmodified lines | ||
| 314 | 571 | } |
| 315 | 572 | |
| 316 | 573 | void Batch::_glUseProgram(GLuint program) { |
| 317 | − ADD_COMMAND(glUseProgram); | |
| 574 | + ADD_COMMAND_GL(glUseProgram); | |
| 318 | 575 | |
| 319 | 576 | _params.push_back(program); |
| 320 | 577 | |
| @@ -326,7 +583,7 @@ void GLBackend::do_glUseProgram(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 326 | 583 | } |
| 327 | 584 | |
| 328 | 585 | void Batch::_glUniform1f(GLint location, GLfloat v0) { |
| 329 | − ADD_COMMAND(glUniform1f); | |
| 586 | + ADD_COMMAND_GL(glUniform1f); | |
| 330 | 587 | |
| 331 | 588 | _params.push_back(v0); |
| 332 | 589 | _params.push_back(location); |
| @@ -341,7 +598,7 @@ void GLBackend::do_glUniform1f(Batch& batch, uint32 paramOffset) { · 8 unmodified lines | ||
| 341 | 598 | } |
| 342 | 599 | |
| 343 | 600 | void Batch::_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { |
| 344 | − ADD_COMMAND(glUniformMatrix4fv); | |
| 601 | + ADD_COMMAND_GL(glUniformMatrix4fv); | |
| 345 | 602 | |
| 346 | 603 | const int MATRIX4_SIZE = 16 * sizeof(float); |
| 347 | 604 | _params.push_back(cacheData(count * MATRIX4_SIZE, value)); |
| @@ -361,7 +618,7 @@ void GLBackend::do_glUniformMatrix4fv(Batch& batch, uint32 paramOffset) { · 13 unmodified lines | ||
| 361 | 618 | } |
| 362 | 619 | |
| 363 | 620 | void Batch::_glMatrixMode(GLenum mode) { |
| 364 | − ADD_COMMAND(glMatrixMode); | |
| 621 | + ADD_COMMAND_GL(glMatrixMode); | |
| 365 | 622 | |
| 366 | 623 | _params.push_back(mode); |
| 367 | 624 | |
| @@ -373,7 +630,7 @@ void GLBackend::do_glMatrixMode(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 373 | 630 | } |
| 374 | 631 | |
| 375 | 632 | void Batch::_glPushMatrix() { |
| 376 | − ADD_COMMAND(glPushMatrix); | |
| 633 | + ADD_COMMAND_GL(glPushMatrix); | |
| 377 | 634 | |
| 378 | 635 | DO_IT_NOW(_glPushMatrix, 0); |
| 379 | 636 | } |
| @@ -383,7 +640,7 @@ void GLBackend::do_glPushMatrix(Batch& batch, uint32 paramOffset) { · 3 unmodified lines | ||
| 383 | 640 | } |
| 384 | 641 | |
| 385 | 642 | void Batch::_glPopMatrix() { |
| 386 | − ADD_COMMAND(glPopMatrix); | |
| 643 | + ADD_COMMAND_GL(glPopMatrix); | |
| 387 | 644 | |
| 388 | 645 | DO_IT_NOW(_glPopMatrix, 0); |
| 389 | 646 | } |
| @@ -393,7 +650,7 @@ void GLBackend::do_glPopMatrix(Batch& batch, uint32 paramOffset) { · 3 unmodified lines | ||
| 393 | 650 | } |
| 394 | 651 | |
| 395 | 652 | void Batch::_glMultMatrixf(const GLfloat *m) { |
| 396 | − ADD_COMMAND(glMultMatrixf); | |
| 653 | + ADD_COMMAND_GL(glMultMatrixf); | |
| 397 | 654 | |
| 398 | 655 | const int MATRIX4_SIZE = 16 * sizeof(float); |
| 399 | 656 | _params.push_back(cacheData(MATRIX4_SIZE, m)); |
| @@ -406,7 +663,7 @@ void GLBackend::do_glMultMatrixf(Batch& batch, uint32 paramOffset) { · 6 unmodified lines | ||
| 406 | 663 | } |
| 407 | 664 | |
| 408 | 665 | void Batch::_glLoadMatrixf(const GLfloat *m) { |
| 409 | − ADD_COMMAND(glLoadMatrixf); | |
| 666 | + ADD_COMMAND_GL(glLoadMatrixf); | |
| 410 | 667 | |
| 411 | 668 | const int MATRIX4_SIZE = 16 * sizeof(float); |
| 412 | 669 | _params.push_back(cacheData(MATRIX4_SIZE, m)); |
| @@ -419,7 +676,7 @@ void GLBackend::do_glLoadMatrixf(Batch& batch, uint32 paramOffset) { · 6 unmodified lines | ||
| 419 | 676 | } |
| 420 | 677 | |
| 421 | 678 | void Batch::_glLoadIdentity(void) { |
| 422 | − ADD_COMMAND(glLoadIdentity); | |
| 679 | + ADD_COMMAND_GL(glLoadIdentity); | |
| 423 | 680 | |
| 424 | 681 | DO_IT_NOW(_glLoadIdentity, 0); |
| 425 | 682 | } |
| @@ -429,7 +686,7 @@ void GLBackend::do_glLoadIdentity(Batch& batch, uint32 paramOffset) { · 3 unmodified lines | ||
| 429 | 686 | } |
| 430 | 687 | |
| 431 | 688 | void Batch::_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { |
| 432 | − ADD_COMMAND(glRotatef); | |
| 689 | + ADD_COMMAND_GL(glRotatef); | |
| 433 | 690 | |
| 434 | 691 | _params.push_back(z); |
| 435 | 692 | _params.push_back(y); |
| @@ -448,7 +705,7 @@ void GLBackend::do_glRotatef(Batch& batch, uint32 paramOffset) { · 12 unmodified lines | ||
| 448 | 705 | } |
| 449 | 706 | |
| 450 | 707 | void Batch::_glScalef(GLfloat x, GLfloat y, GLfloat z) { |
| 451 | − ADD_COMMAND(glScalef); | |
| 708 | + ADD_COMMAND_GL(glScalef); | |
| 452 | 709 | |
| 453 | 710 | _params.push_back(z); |
| 454 | 711 | _params.push_back(y); |
| @@ -465,7 +722,7 @@ void GLBackend::do_glScalef(Batch& batch, uint32 paramOffset) { · 10 unmodified lines | ||
| 465 | 722 | } |
| 466 | 723 | |
| 467 | 724 | void Batch::_glTranslatef(GLfloat x, GLfloat y, GLfloat z) { |
| 468 | − ADD_COMMAND(glTranslatef); | |
| 725 | + ADD_COMMAND_GL(glTranslatef); | |
| 469 | 726 | |
| 470 | 727 | _params.push_back(z); |
| 471 | 728 | _params.push_back(y); |
| @@ -482,7 +739,7 @@ void GLBackend::do_glTranslatef(Batch& batch, uint32 paramOffset) { · 10 unmodified lines | ||
| 482 | 739 | } |
| 483 | 740 | |
| 484 | 741 | void Batch::_glDrawArrays(GLenum mode, GLint first, GLsizei count) { |
| 485 | − ADD_COMMAND(glDrawArrays); | |
| 742 | + ADD_COMMAND_GL(glDrawArrays); | |
| 486 | 743 | |
| 487 | 744 | _params.push_back(count); |
| 488 | 745 | _params.push_back(first); |
| @@ -499,7 +756,7 @@ void GLBackend::do_glDrawArrays(Batch& batch, uint32 paramOffset) { · 10 unmodified lines | ||
| 499 | 756 | } |
| 500 | 757 | |
| 501 | 758 | void Batch::_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices) { |
| 502 | − ADD_COMMAND(glDrawRangeElements); | |
| 759 | + ADD_COMMAND_GL(glDrawRangeElements); | |
| 503 | 760 | |
| 504 | 761 | _params.push_back(cacheResource(indices)); |
| 505 | 762 | _params.push_back(type); |
| @@ -522,7 +779,7 @@ void GLBackend::do_glDrawRangeElements(Batch& batch, uint32 paramOffset) { · 16 unmodified lines | ||
| 522 | 779 | } |
| 523 | 780 | |
| 524 | 781 | void Batch::_glColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) { |
| 525 | − ADD_COMMAND(glColorPointer); | |
| 782 | + ADD_COMMAND_GL(glColorPointer); | |
| 526 | 783 | |
| 527 | 784 | _params.push_back(cacheResource(pointer)); |
| 528 | 785 | _params.push_back(stride); |
| @@ -541,7 +798,7 @@ void GLBackend::do_glColorPointer(Batch& batch, uint32 paramOffset) { · 12 unmodified lines | ||
| 541 | 798 | } |
| 542 | 799 | |
| 543 | 800 | void Batch::_glNormalPointer(GLenum type, GLsizei stride, const void *pointer) { |
| 544 | − ADD_COMMAND(glNormalPointer); | |
| 801 | + ADD_COMMAND_GL(glNormalPointer); | |
| 545 | 802 | |
| 546 | 803 | _params.push_back(cacheResource(pointer)); |
| 547 | 804 | _params.push_back(stride); |
| @@ -558,7 +815,7 @@ void GLBackend::do_glNormalPointer(Batch& batch, uint32 paramOffset) { · 10 unmodified lines | ||
| 558 | 815 | } |
| 559 | 816 | |
| 560 | 817 | void Batch::_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) { |
| 561 | − ADD_COMMAND(glTexCoordPointer); | |
| 818 | + ADD_COMMAND_GL(glTexCoordPointer); | |
| 562 | 819 | |
| 563 | 820 | _params.push_back(cacheResource(pointer)); |
| 564 | 821 | _params.push_back(stride); |
| @@ -577,7 +834,7 @@ void GLBackend::do_glTexCoordPointer(Batch& batch, uint32 paramOffset) { · 12 unmodified lines | ||
| 577 | 834 | } |
| 578 | 835 | |
| 579 | 836 | void Batch::_glVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) { |
| 580 | − ADD_COMMAND(glVertexPointer); | |
| 837 | + ADD_COMMAND_GL(glVertexPointer); | |
| 581 | 838 | |
| 582 | 839 | _params.push_back(cacheResource(pointer)); |
| 583 | 840 | _params.push_back(stride); |
| @@ -597,7 +854,7 @@ void GLBackend::do_glVertexPointer(Batch& batch, uint32 paramOffset) { · 13 unmodified lines | ||
| 597 | 854 | |
| 598 | 855 | |
| 599 | 856 | void Batch::_glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer) { |
| 600 | − ADD_COMMAND(glVertexAttribPointer); | |
| 857 | + ADD_COMMAND_GL(glVertexAttribPointer); | |
| 601 | 858 | |
| 602 | 859 | _params.push_back(cacheResource(pointer)); |
| 603 | 860 | _params.push_back(stride); |
| @@ -620,7 +877,7 @@ void GLBackend::do_glVertexAttribPointer(Batch& batch, uint32 paramOffset) { · 16 unmodified lines | ||
| 620 | 877 | } |
| 621 | 878 | |
| 622 | 879 | void Batch::_glEnableVertexAttribArray(GLint location) { |
| 623 | − ADD_COMMAND(glEnableVertexAttribArray); | |
| 880 | + ADD_COMMAND_GL(glEnableVertexAttribArray); | |
| 624 | 881 | |
| 625 | 882 | _params.push_back(location); |
| 626 | 883 | |
| @@ -632,7 +889,7 @@ void GLBackend::do_glEnableVertexAttribArray(Batch& batch, uint32 paramOffset) { · 5 unmodified lines | ||
| 632 | 889 | } |
| 633 | 890 | |
| 634 | 891 | void Batch::_glDisableVertexAttribArray(GLint location) { |
| 635 | − ADD_COMMAND(glDisableVertexAttribArray); | |
| 892 | + ADD_COMMAND_GL(glDisableVertexAttribArray); | |
| 636 | 893 | |
| 637 | 894 | _params.push_back(location); |
| 638 | 895 | |
| @@ -644,7 +901,7 @@ void GLBackend::do_glDisableVertexAttribArray(Batch& batch, uint32 paramOffset) · 5 unmodified lines | ||
| 644 | 901 | } |
| 645 | 902 | |
| 646 | 903 | void Batch::_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { |
| 647 | − ADD_COMMAND(glColor4f); | |
| 904 | + ADD_COMMAND_GL(glColor4f); | |
| 648 | 905 | |
| 649 | 906 | _params.push_back(alpha); |
| 650 | 907 | _params.push_back(blue); |
| @@ -663,7 +920,7 @@ void GLBackend::do_glColor4f(Batch& batch, uint32 paramOffset) { · 12 unmodified lines | ||
| 663 | 920 | } |
| 664 | 921 | |
| 665 | 922 | void Batch::_glMaterialf(GLenum face, GLenum pname, GLfloat param) { |
| 666 | − ADD_COMMAND(glMaterialf); | |
| 923 | + ADD_COMMAND_GL(glMaterialf); | |
| 667 | 924 | |
| 668 | 925 | _params.push_back(param); |
| 669 | 926 | _params.push_back(pname); |
| @@ -680,7 +937,7 @@ void GLBackend::do_glMaterialf(Batch& batch, uint32 paramOffset) { · 10 unmodified lines | ||
| 680 | 937 | } |
| 681 | 938 | |
| 682 | 939 | void Batch::_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) { |
| 683 | − ADD_COMMAND(glMaterialfv); | |
| 940 | + ADD_COMMAND_GL(glMaterialfv); | |
| 684 | 941 | |
| 685 | 942 | _params.push_back(cacheData(4 * sizeof(float), params)); |
| 686 | 943 | _params.push_back(pname); |