Commit 4938dc418e0c7abe3443aedb6aee3ff583893da7
- Diff rendering mode:
- inline
- side by side
|   | |||
| 265 | 265 | #if defined(QT_OPENGL_ES_2) | |
| 266 | 266 | #define QGL_NO_MATRIX_FETCH 1 | |
| 267 | 267 | #define QGL_NO_MATRIX_RESET 1 | |
| 268 | #elif defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) | ||
| 269 | #define QGL_NO_MATRIX_FETCH 1 | ||
| 270 | #define QGL_MATRIX_RESET_TO_IDENTITY 1 | ||
| 271 | 268 | #endif | |
| 272 | 269 | ||
| 273 | 270 | #ifndef QGL_NO_MATRIX_FETCH | |
| … | … | ||
| 320 | 320 | #endif | |
| 321 | 321 | ||
| 322 | 322 | // OpenGL/ES 2.0 does not have server-side matrices. | |
| 323 | // OpenGL/ES 1.0 cannot fetch the server-side matrices. | ||
| 324 | // For these platforms, we stub out the checks and just hope that they work. | ||
| 323 | // For such platforms, we stub out the checks and just hope that they work. | ||
| 325 | 324 | static void clearGLMatrix(GLenum) {} | |
| 326 | 325 | static bool checkGLMatrix(GLenum, const QMatrix4x4&) { return true; } | |
| 327 | 326 | static void setGLMatrix(GLenum, const QMatrix4x4&) {} | |
| … | … | ||
| 364 | 364 | // Read back the explicitly set value from the GL server. | |
| 365 | 365 | #if defined(QGL_NO_MATRIX_RESET) // OpenGL/ES 2.0 | |
| 366 | 366 | QVERIFY(qFuzzyCompare(m, painter.projectionMatrix().top())); | |
| 367 | #elif defined(QGL_MATRIX_RESET_TO_IDENTITY) // OpenGL/ES 1.0 | ||
| 368 | QVERIFY(qFuzzyCompare(QMatrix4x4(), painter.projectionMatrix().top())); | ||
| 369 | 367 | #else | |
| 370 | 368 | QVERIFY(qFuzzyCompare(m2, painter.projectionMatrix().top())); | |
| 371 | 369 | #endif | |
| … | … | ||
| 410 | 410 | // Read back the explicitly set value from the GL server. | |
| 411 | 411 | #if defined(QGL_NO_MATRIX_RESET) // OpenGL/ES 2.0 | |
| 412 | 412 | QVERIFY(qFuzzyCompare(m, painter.modelViewMatrix().top())); | |
| 413 | #elif defined(QGL_MATRIX_RESET_TO_IDENTITY) // OpenGL/ES 1.0 | ||
| 414 | QVERIFY(qFuzzyCompare(QMatrix4x4(), painter.modelViewMatrix().top())); | ||
| 415 | 413 | #else | |
| 416 | 414 | QVERIFY(qFuzzyCompare(m2, painter.modelViewMatrix().top())); | |
| 417 | 415 | #endif |
|   | |||
| 131 | 131 | QMatrix4x4 matrix; | |
| 132 | 132 | #if !defined(QT_OPENGL_ES_2) | |
| 133 | 133 | GLenum glType; | |
| 134 | #if !defined(GL_OES_VERSION_1_0) || defined(GL_OES_VERSION_1_1) | ||
| 135 | 134 | GLenum glFetchType; | |
| 136 | #endif | ||
| 137 | 135 | QList<bool> serverStack; | |
| 138 | 136 | #endif | |
| 139 | 137 | QList<QMatrix4x4> stack; | |
| … | … | ||
| 142 | 142 | QGLMatrixStackPrivate::QGLMatrixStackPrivate(QGLMatrixStack::Type t) | |
| 143 | 143 | { | |
| 144 | 144 | type = t; | |
| 145 | #if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) | ||
| 145 | #if !defined(QT_OPENGL_ES_2) | ||
| 146 | 146 | switch (t) { | |
| 147 | 147 | case QGLMatrixStack::ModelViewMatrix: | |
| 148 | 148 | glType = GL_MODELVIEW; | |
| 149 | haveMatrix = false; | ||
| 150 | break; | ||
| 151 | case QGLMatrixStack::ProjectionMatrix: | ||
| 152 | glType = GL_PROJECTION; | ||
| 153 | haveMatrix = false; | ||
| 154 | break; | ||
| 155 | default: | ||
| 156 | glType = 0; | ||
| 157 | haveMatrix = true; // We always have a user-defined matrix. | ||
| 158 | break; | ||
| 159 | } | ||
| 160 | haveMatrix = (t == QGLMatrixStack::UserMatrix); | ||
| 161 | #elif !defined(QT_OPENGL_ES_2) | ||
| 162 | switch (t) { | ||
| 163 | case QGLMatrixStack::ModelViewMatrix: | ||
| 164 | glType = GL_MODELVIEW; | ||
| 165 | 149 | glFetchType = GL_MODELVIEW_MATRIX; | |
| 166 | 150 | haveMatrix = false; | |
| 167 | 151 | break; | |
| … | … | ||
| 310 | 310 | avoided by calling operator=() or setToIdentity() to set the GL server's | |
| 311 | 311 | matrix to a known value. | |
| 312 | 312 | ||
| 313 | Note: OpenGL/ES 1.0 does not have a mechanism to fetch the | ||
| 314 | current matrix. On that platform, this function will forcibly set | ||
| 315 | the matrix to the identity if it has not been set previously | ||
| 316 | with operator=() or setToIdentity(). | ||
| 317 | |||
| 318 | 313 | Matrix stacks of type UserMatrix never need to perform a round-trip | |
| 319 | 314 | to the GL server because they are implemented purely client-side. | |
| 320 | 315 | ||
| … | … | ||
| 322 | 322 | // We need to retrieve the current matrix from the GL server | |
| 323 | 323 | // because we have no way to know what state it is currently in. | |
| 324 | 324 | d->haveMatrix = true; | |
| 325 | #if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) | ||
| 326 | // OpenGL/ES 1.0 does not have glGetFloatv, so we forcibly | ||
| 327 | // set the matrix to the identity so that it is in a known state. | ||
| 328 | glMatrixMode(d->glType); | ||
| 329 | glLoadIdentity(); | ||
| 330 | d->matrix.setToIdentity(); | ||
| 331 | #else | ||
| 332 | 325 | if (sizeof(qreal) == sizeof(GLfloat)) { | |
| 333 | 326 | glGetFloatv(d->glFetchType, reinterpret_cast<GLfloat *> | |
| 334 | 327 | (d->matrix.data())); | |
| … | … | ||
| 334 | 334 | m[index] = mat[index]; | |
| 335 | 335 | d->matrix.optimize(); | |
| 336 | 336 | } | |
| 337 | #endif | ||
| 338 | 337 | } | |
| 339 | 338 | #endif | |
| 340 | 339 | return d->matrix; |
threed/painting/qglpainter.cpp
(0 / 12)
|   | |||
| 635 | 635 | to the GL server to get the scissor rectangle. This round-trip | |
| 636 | 636 | can be avoided by calling setScissorRect() before scissorRect(). | |
| 637 | 637 | ||
| 638 | Note: OpenGL/ES 1.0 does not have a mechanism to fetch the | ||
| 639 | scissor rectangle. On that platform, this function will forcibly | ||
| 640 | disable scissoring if it has not been set previously with | ||
| 641 | setScissorRect(). | ||
| 642 | |||
| 643 | 638 | \sa setScissorRect(), resetScissorRect() | |
| 644 | 639 | */ | |
| 645 | 640 | QRect QGLPainter::scissorRect() const | |
| … | … | ||
| 642 | 642 | Q_D(QGLPainter); | |
| 643 | 643 | QGLPAINTER_CHECK_PRIVATE_RETURN(QRect(0, 0, 0, 0)); | |
| 644 | 644 | if (d->scissorRect.isNull()) { | |
| 645 | #if !defined(GL_OES_VERSION_1_0) || defined(GL_OES_VERSION_1_1) | ||
| 646 | 645 | if (glIsEnabled(GL_SCISSOR_TEST)) { | |
| 647 | 646 | GLint scissor[4]; | |
| 648 | 647 | glGetIntegerv(GL_SCISSOR_BOX, scissor); | |
| … | … | ||
| 650 | 650 | } else { | |
| 651 | 651 | d->scissorRect = QRect(0, 0, 0, 0); | |
| 652 | 652 | } | |
| 653 | #else | ||
| 654 | // OpenGL/ES 1.0 does not have glIsEnabled() or GL_SCISSOR_BOX, | ||
| 655 | // so force the scissor setting to a known state. | ||
| 656 | d->scissorRect = QRect(0, 0, 0, 0); | ||
| 657 | glDisable(GL_SCISSOR_TEST); | ||
| 658 | #endif | ||
| 659 | 653 | } | |
| 660 | 654 | return d->scissorRect; | |
| 661 | 655 | } |
|   | |||
| 103 | 103 | ||
| 104 | 104 | typedef void (APIENTRY *q_glVertexAttribPointer) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); | |
| 105 | 105 | ||
| 106 | // We can call the buffer functions directly in OpenGL/ES 1.1 or higher, | ||
| 106 | // We can call the buffer functions directly in OpenGL/ES, | ||
| 107 | 107 | // but all other platforms need to resolve the extensions. | |
| 108 | #if defined(QT_OPENGL_ES) | ||
| 109 | #if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) | ||
| 110 | #define QGL_RESOLVE_BUFFER_FUNCS 1 | ||
| 111 | #endif | ||
| 112 | #else | ||
| 108 | #if !defined(QT_OPENGL_ES) | ||
| 113 | 109 | #define QGL_RESOLVE_BUFFER_FUNCS 1 | |
| 114 | 110 | #endif | |
| 115 | 111 |

