diff options
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 112 |
1 files changed, 67 insertions, 45 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index b7139a2..e9ca4c4 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -67,7 +67,7 @@ #include "qimage.h" #include "qgl_p.h" -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) +#if !defined(QT_OPENGL_ES_1) #include "gl2paintengineex/qpaintengineex_opengl2_p.h" #endif @@ -95,11 +95,6 @@ QT_BEGIN_NAMESPACE -#ifdef QT_OPENGL_ES_1_CL -#include "qgl_cl_p.h" -#endif - - #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; #endif @@ -1085,8 +1080,9 @@ int QGLFormat::stencilBufferSize() const /*! \since 4.7 - Set the OpenGL version. If a context compatible with the requested OpenGL version - cannot be created, a context compatible with version 1.x is created instead. + Set the OpenGL version to the \a major and \a minor numbers. If a + context compatible with the requested OpenGL version cannot be + created, a context compatible with version 1.x is created instead. \sa majorVersion(), minorVersion() */ @@ -1129,8 +1125,9 @@ int QGLFormat::minorVersion() const \enum QGLFormat::OpenGLContextProfile \since 4.7 - This enum describes the OpenGL context profiles that can be specified for contexts implementing - OpenGL version 3.2 or higher. These profiles are different from OpenGL ES profiles. + This enum describes the OpenGL context profiles that can be + specified for contexts implementing OpenGL version 3.2 or + higher. These profiles are different from OpenGL ES profiles. \value NoProfile OpenGL version is lower than 3.2. \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available. @@ -1140,8 +1137,8 @@ int QGLFormat::minorVersion() const /*! \since 4.7 - Set the OpenGL context profile. The profile is ignored if the requested OpenGL - version is less than 3.2. + Set the OpenGL context profile to \a profile. The \a profile is + ignored if the requested OpenGL version is less than 3.2. \sa profile() */ @@ -1655,7 +1652,7 @@ QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alp QImage img(size, alpha_format ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); int w = size.width(); int h = size.height(); -#if !defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) +#if !defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_ES_1) //### glGetTexImage not in GL ES 2.0, need to do something else here! glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); #endif @@ -2433,7 +2430,7 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, { Q_Q(QGLContext); QPixmapData *pd = pixmap.pixmapData(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) +#if !defined(QT_OPENGL_ES_1) if (target == GL_TEXTURE_2D && pd->classId() == QPixmapData::OpenGLClass) { const QGLPixmapData *data = static_cast<const QGLPixmapData *>(pd); @@ -2680,41 +2677,41 @@ void QGLContext::deleteTexture(QMacCompatGLuint id) } #endif -void qt_add_rect_to_array(const QRectF &r, q_vertexType *array) +void qt_add_rect_to_array(const QRectF &r, GLfloat *array) { qreal left = r.left(); qreal right = r.right(); qreal top = r.top(); qreal bottom = r.bottom(); - array[0] = f2vt(left); - array[1] = f2vt(top); - array[2] = f2vt(right); - array[3] = f2vt(top); - array[4] = f2vt(right); - array[5] = f2vt(bottom); - array[6] = f2vt(left); - array[7] = f2vt(bottom); + array[0] = left; + array[1] = top; + array[2] = right; + array[3] = top; + array[4] = right; + array[5] = bottom; + array[6] = left; + array[7] = bottom; } -void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, q_vertexType *array) +void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, GLfloat *array) { - array[0] = f2vt(x1); - array[1] = f2vt(y1); - array[2] = f2vt(x2); - array[3] = f2vt(y1); - array[4] = f2vt(x2); - array[5] = f2vt(y2); - array[6] = f2vt(x1); - array[7] = f2vt(y2); + array[0] = x1; + array[1] = y1; + array[2] = x2; + array[3] = y1; + array[4] = x2; + array[5] = y2; + array[6] = x1; + array[7] = y2; } #if !defined(QT_OPENGL_ES_2) static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint textureHeight, GLenum textureTarget) { - q_vertexType tx = f2vt(1); - q_vertexType ty = f2vt(1); + GLfloat tx = 1.0f; + GLfloat ty = 1.0f; #ifdef QT_OPENGL_ES Q_UNUSED(textureWidth); @@ -2727,20 +2724,20 @@ static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint tex glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); } - tx = f2vt(textureWidth); - ty = f2vt(textureHeight); + tx = GLfloat(textureWidth); + ty = GLfloat(textureHeight); } #endif - q_vertexType texCoordArray[4*2] = { + GLfloat texCoordArray[4*2] = { 0, ty, tx, ty, tx, 0, 0, 0 }; - q_vertexType vertexArray[4*2]; + GLfloat vertexArray[4*2]; qt_add_rect_to_array(target, vertexArray); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); - glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); + glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -4494,6 +4491,13 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, \note This function temporarily disables depth-testing when the text is drawn. + \note This function can only be used inside a + QPainter::beginNativePainting()/QPainter::endNativePainting() block + if the default OpenGL paint engine is QPaintEngine::OpenGL. To make + QPaintEngine::OpenGL the default GL engine, call + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL) before the + QApplication constructor. + \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. */ @@ -4513,8 +4517,17 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, bool auto_swap = autoBufferSwap(); QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); - qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + QPaintEngine *engine = paintEngine(); + if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" + " active on the same device is not allowed."); + return; + } + + // this changes what paintEngine() returns + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + engine = paintEngine(); QPainter *p; bool reuse_painter = false; if (engine->isActive()) { @@ -4607,8 +4620,17 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con win_y = height - win_y; // y is inverted QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); - qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); QPaintEngine *engine = paintEngine(); + + if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" + " active on the same device is not allowed."); + return; + } + + // this changes what paintEngine() returns + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + engine = paintEngine(); QPainter *p; bool reuse_painter = false; bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); @@ -4877,7 +4899,7 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) +#if !defined(QT_OPENGL_ES_1) Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine) #endif @@ -4887,7 +4909,7 @@ Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_engine) Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() { -#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) +#if defined(QT_OPENGL_ES_1) return qt_gl_engine(); #elif defined(QT_OPENGL_ES_2) return qt_gl_2_engine(); @@ -5010,7 +5032,7 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions() glExtensions |= GenerateMipmap; glExtensions |= FragmentShader; #endif -#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) +#if defined(QT_OPENGL_ES_1) if (extensions.match("GL_OES_framebuffer_object")) glExtensions |= FramebufferObject; #endif |