diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-05-14 08:51:46 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-05-14 08:51:46 (GMT) |
commit | 521c5cc3910bffe566e0fb653041f159ecb5b6d5 (patch) | |
tree | 70b703fa82b7e5f2e07105fb37ff5dc9353e6598 /src/opengl | |
parent | f15352c51625688ec445c73125a2e25327377d49 (diff) | |
download | Qt-521c5cc3910bffe566e0fb653041f159ecb5b6d5.zip Qt-521c5cc3910bffe566e0fb653041f159ecb5b6d5.tar.gz Qt-521c5cc3910bffe566e0fb653041f159ecb5b6d5.tar.bz2 |
Make QtOpenGL compile on OpenGL ES 1.1 again
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 | ||||
-rw-r--r-- | src/opengl/opengl.pro | 41 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 65 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 17 | ||||
-rw-r--r-- | src/opengl/qglextensions_p.h | 5 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 10 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer.cpp | 10 | ||||
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 9 |
8 files changed, 116 insertions, 45 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 9f2384d..caf744a 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1331,10 +1331,10 @@ void QGL2PaintEngineExPrivate::updateDepthClip() return; } - glClearDepthf(0x0); + glClearDepth(0x0); glDepthMask(true); glClear(GL_DEPTH_BUFFER_BIT); - glClearDepthf(0x1); + glClearDepth(0x1); glEnable(GL_SCISSOR_TEST); for (int i = 0; i < rects.size(); ++i) { diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 7eb2503..73af174 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -13,20 +13,14 @@ include(../qbase.pri) !win32:!embedded:!mac:CONFIG += x11 contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles1):CONFIG += opengles1 +contains(QT_CONFIG, opengles1):CONFIG += opengles1cl contains(QT_CONFIG, opengles2):CONFIG += opengles2 -#!contains(QT_CONFIG, opengles2) { - HEADERS += qgraphicssystem_gl_p.h qwindowsurface_gl_p.h qpixmapdata_gl_p.h - SOURCES += qgraphicssystem_gl.cpp qwindowsurface_gl.cpp qpixmapdata_gl.cpp -#} - HEADERS += qgl.h \ qgl_p.h \ qglcolormap.h \ qglpixelbuffer.h \ qglframebufferobject.h \ - qglpixmapfilter_p.h \ - qglshaderprogram.h \ qglextensions_p.h SOURCES += qgl.cpp \ @@ -34,24 +28,35 @@ SOURCES += qgl.cpp \ qglpixelbuffer.cpp \ qglframebufferobject.cpp \ qglextensions.cpp \ - qglpixmapfilter.cpp \ - qglshaderprogram.cpp !contains(QT_CONFIG, opengles2) { HEADERS += qpaintengine_opengl_p.h SOURCES += qpaintengine_opengl.cpp } -SOURCES += gl2paintengineex/qglgradientcache.cpp \ - gl2paintengineex/qglengineshadermanager.cpp \ - gl2paintengineex/qgl2pexvertexarray.cpp \ - gl2paintengineex/qpaintengineex_opengl2.cpp +!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles1cl) { + HEADERS += qglshaderprogram.h \ + qglpixmapfilter_p.h \ + qgraphicssystem_gl_p.h \ + qwindowsurface_gl_p.h \ + qpixmapdata_gl_p.h \ + gl2paintengineex/qglgradientcache_p.h \ + gl2paintengineex/qglengineshadermanager_p.h \ + gl2paintengineex/qgl2pexvertexarray_p.h \ + gl2paintengineex/qpaintengineex_opengl2_p.h \ + gl2paintengineex/qglengineshadersource_p.h + + SOURCES += qglshaderprogram.cpp \ + qglpixmapfilter.cpp \ + qgraphicssystem_gl.cpp \ + qwindowsurface_gl.cpp \ + qpixmapdata_gl.cpp \ + gl2paintengineex/qglgradientcache.cpp \ + gl2paintengineex/qglengineshadermanager.cpp \ + gl2paintengineex/qgl2pexvertexarray.cpp \ + gl2paintengineex/qpaintengineex_opengl2.cpp -HEADERS += gl2paintengineex/qglgradientcache_p.h \ - gl2paintengineex/qglengineshadermanager_p.h \ - gl2paintengineex/qgl2pexvertexarray_p.h \ - gl2paintengineex/qpaintengineex_opengl2_p.h \ - gl2paintengineex/qglengineshadersource_p.h +} x11 { contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONFIG, opengles2) { diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 12f781e..a1f81ca 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1365,7 +1365,8 @@ QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alp QImage img(size, alpha_format ? QImage::Format_ARGB32 : QImage::Format_RGB32); int w = size.width(); int h = size.height(); -#if !defined(QT_OPENGL_ES_2) //### glGetTexImage not in GL ES 2.0, need to do something else here! +#if !defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + //### 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 convertFromGLImage(img, w, h, alpha_format, include_alpha); @@ -1971,12 +1972,14 @@ GLuint QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, GLin { Q_Q(QGLContext); QPixmapData *pd = pixmap.pixmapData(); +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) if (target == GL_TEXTURE_2D && pd->classId() == QPixmapData::OpenGLClass) { const QGLPixmapData *data = static_cast<const QGLPixmapData *>(pd); if (data->isValidContext(q)) return data->bind(); } +#endif const qint64 key = pixmap.cacheKey(); GLuint id; @@ -4159,7 +4162,9 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine) +#endif #ifndef QT_OPENGL_ES_2 Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_engine) @@ -4184,11 +4189,16 @@ Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() */ QPaintEngine *QGLWidget::paintEngine() const { -#ifndef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) + return qt_gl_engine(); +#elif defined(QT_OPENGL_ES_2) + return qt_gl_2_engine(); +#else if (!qt_gl_preferGL2Engine()) return qt_gl_engine(); + else + return qt_gl_2_engine(); #endif - return qt_gl_2_engine(); } #ifdef QT3_SUPPORT @@ -4338,6 +4348,7 @@ void QGLDrawable::setDevice(QPaintDevice *pdev) wsurf = 0; #endif +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) if (pdev->devType() == QInternal::Pixmap) { QPixmapData *data = static_cast<QPixmap *>(pdev)->pixmapData(); Q_ASSERT(data->classId() == QPixmapData::OpenGLClass); @@ -4345,6 +4356,9 @@ void QGLDrawable::setDevice(QPaintDevice *pdev) fbo = pixmapData->fbo(); } +#else + Q_ASSERT(pdev->devType() != QInternal::Pixmap); +#endif if (pdev->devType() == QInternal::Widget) widget = static_cast<QGLWidget *>(pdev); @@ -4352,10 +4366,11 @@ void QGLDrawable::setDevice(QPaintDevice *pdev) buffer = static_cast<QGLPixelBuffer *>(pdev); else if (pdev->devType() == QInternal::FramebufferObject) fbo = static_cast<QGLFramebufferObject *>(pdev); - else if (pdev->devType() == QInternal::UnknownDevice) #ifdef Q_WS_QWS + else if (pdev->devType() == QInternal::UnknownDevice) wsurf = static_cast<QWSGLPaintDevice*>(pdev)->windowSurface(); -#else +#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + else if (pdev->devType() == QInternal::UnknownDevice) wsurf = static_cast<QGLWindowSurface *>(pdev); #endif } @@ -4365,8 +4380,10 @@ void QGLDrawable::swapBuffers() if (widget) { if (widget->autoBufferSwap()) widget->swapBuffers(); +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) } else if (pixmapData) { pixmapData->swapBuffers(); +#endif } else { glFlush(); } @@ -4374,14 +4391,18 @@ void QGLDrawable::swapBuffers() void QGLDrawable::makeCurrent() { - if (pixmapData) - pixmapData->makeCurrent(); - else if (widget) + if (widget) widget->makeCurrent(); +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + else if (pixmapData) + pixmapData->makeCurrent(); +#endif else if (buffer) buffer->makeCurrent(); +#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) else if (wsurf) wsurf->context()->makeCurrent(); +#endif else if (fbo) { wasBound = fbo->isBound(); if (!wasBound) @@ -4389,18 +4410,25 @@ void QGLDrawable::makeCurrent() } } +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) QGLPixmapData *QGLDrawable::copyOnBegin() const { if (!pixmapData || pixmapData->isUninitialized()) return 0; return pixmapData; } +#endif void QGLDrawable::doneCurrent() { - if (pixmapData) +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + if (pixmapData) { pixmapData->doneCurrent(); - else if (fbo && !wasBound) + return; + } +#endif + + if (fbo && !wasBound) fbo->release(); } @@ -4409,19 +4437,22 @@ QSize QGLDrawable::size() const if (widget) { return QSize(widget->d_func()->glcx->device()->width(), widget->d_func()->glcx->device()->height()); +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) } else if (pixmapData) { return pixmapData->size(); +#endif } else if (buffer) { return buffer->size(); } else if (fbo) { return fbo->size(); - } else if (wsurf) { + } #ifdef Q_WS_QWS + else if (wsurf) return wsurf->window()->frameSize(); -#else +#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + else if (wsurf) return QSize(wsurf->width(), wsurf->height()); #endif - } return QSize(); } @@ -4431,8 +4462,10 @@ QGLFormat QGLDrawable::format() const return widget->format(); else if (buffer) return buffer->format(); +#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) else if (wsurf) return wsurf->context()->format(); +#endif else if (fbo && QGLContext::currentContext()) { QGLFormat fmt = QGLContext::currentContext()->format(); fmt.setStencil(fbo->attachment() == QGLFramebufferObject::CombinedDepthStencil); @@ -4451,8 +4484,10 @@ GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format return buffer->d_func()->qctx->d_func()->bindTexture(image, target, format, true); else if (fbo && QGLContext::currentContext()) return const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(image, target, format, true); +#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) else if (wsurf) return wsurf->context()->d_func()->bindTexture(image, target, format, true); +#endif return 0; } @@ -4464,8 +4499,10 @@ GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint form return buffer->d_func()->qctx->d_func()->bindTexture(pixmap, target, format, true); else if (fbo && QGLContext::currentContext()) return const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(pixmap, target, format, true); +#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) else if (wsurf) return wsurf->context()->d_func()->bindTexture(pixmap, target, format, true); +#endif return 0; } @@ -4484,8 +4521,10 @@ QGLContext *QGLDrawable::context() const return buffer->d_func()->qctx; else if (fbo) return const_cast<QGLContext *>(QGLContext::currentContext()); +#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) else if (wsurf) return wsurf->context(); +#endif return 0; } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index a294af9..b421eee 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -60,7 +60,10 @@ #include "QtCore/qthreadstorage.h" #include "QtCore/qhash.h" #include "private/qwidget_p.h" + +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) #include "private/qpixmapdata_gl_p.h" +#endif #ifndef QT_OPENGL_ES_1_CL #define q_vertexType float @@ -293,7 +296,12 @@ class QGLWindowSurface; class QGLDrawable { public: QGLDrawable() : widget(0), buffer(0), fbo(0) - , wsurf(0), pixmapData(0) +#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) + , wsurf(0) +#endif +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + , pixmapData(0) +#endif {} void setDevice(QPaintDevice *pdev); void swapBuffers(); @@ -307,7 +315,9 @@ public: QGLContext *context() const; bool autoFillBackground() const; +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) QGLPixmapData *copyOnBegin() const; +#endif private: bool wasBound; @@ -316,10 +326,13 @@ private: QGLFramebufferObject *fbo; #ifdef Q_WS_QWS QWSGLWindowSurface *wsurf; -#else +#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) QGLWindowSurface *wsurf; #endif + +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) QGLPixmapData *pixmapData; +#endif }; // GL extension definitions diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 46047ef..d6edfb6 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -705,7 +705,10 @@ struct QGLExtensionFuncs #if !defined(QT_OPENGL_ES_2) #define glStencilOpSeparate QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glStencilOpSeparate -#define glClearDepthf(x) glClearDepth(GLdouble(x)) +#endif + +#if defined(QT_OPENGL_ES_2) +#define glClearDepth glClearDepthf #endif extern bool qt_resolve_framebufferobject_extensions(QGLContext *ctx); diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 5f106ff..f6857ac 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -897,7 +897,9 @@ QImage QGLFramebufferObject::toImage() const return image; } +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_buffer_2_engine) +#endif #ifndef QT_OPENGL_ES_2 Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) @@ -906,14 +908,16 @@ Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) /*! \reimp */ QPaintEngine *QGLFramebufferObject::paintEngine() const { +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) + return qt_buffer_engine(); +#elif defined(QT_OPENGL_ES_2) + return qt_buffer_2_engine(); +#else Q_D(const QGLFramebufferObject); -#if !defined(QT_OPENGL_ES_2) if (d->ctx->d_func()->internal_context || qt_gl_preferGL2Engine()) return qt_buffer_2_engine(); else return qt_buffer_engine(); -#else - return 0; #endif } diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 00b58d3..ce7e9bd 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -365,7 +365,9 @@ bool QGLPixelBuffer::isValid() const return !d->invalid; } +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_buffer_2_engine) +#endif #ifndef QT_OPENGL_ES_2 Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) @@ -374,13 +376,15 @@ Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) /*! \reimp */ QPaintEngine *QGLPixelBuffer::paintEngine() const { -#if !defined(QT_OPENGL_ES_2) +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) + return qt_buffer_engine(); +#elif defined(QT_OPENGL_ES_2) + return qt_buffer_2_engine(); +#else if (d_ptr->qctx->d_func()->internal_context || qt_gl_preferGL2Engine()) return qt_buffer_2_engine(); else return qt_buffer_engine(); -#else - return 0; #endif } diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 0f447d3..d28a495 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -2255,11 +2255,12 @@ void QOpenGLPaintEnginePrivate::updateDepthClip() return; } -#ifndef QT_OPENGL_ES - glClearDepth(0.0f); -#else +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_ES_1_CL) glClearDepthf(0.0f); +#else + glClearDepth(0.0f); #endif + glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glClear(GL_DEPTH_BUFFER_BIT); @@ -5580,9 +5581,11 @@ void QOpenGLPaintEnginePrivate::ensureDrawableTexture() QPixmapFilter *QOpenGLPaintEngine::createPixmapFilter(int type) const { +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) if (QGLContext::currentContext()) return QGLContext::currentContext()->d_func()->createPixmapFilter(type); else +#endif return 0; } |