diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2012-07-30 18:33:42 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-16 22:04:26 +0200 |
commit | 625c192f54834a5ff5944ecb76f719543f901824 (patch) | |
tree | 57a8476d5eba1f06dbf47ece49e814e08494d014 | |
parent | 0e929f49d716c76aec796a18b450c78842353b32 (diff) |
Compile on OpenGL ES2 when using Khronos headers
This change is needed to allow qtdeclarative to build with change
https://codereview.qt-project.org/#change,28334 as OpenGL ES 2 and
the EXT_sRGB do not define the symbol GL_FRAMEBUFFER_SRGB.
Also use symbols defined by OES extensions where needed.
The #defines will be removed in a follow-up commit once 28334 has
been merged.
Change-Id: I1c4e5297c29ecf723463da7fbfe353628c4c35ef
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
-rw-r--r-- | src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 4 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp | 21 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 2f1a4ae457..6616173253 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -128,10 +128,12 @@ void QSGTextMaskMaterialData::activate() QSGMaterialShader::activate(); glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR); +#if !defined(QT_OPENGL_ES_2) // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0, // but using sRGB looks okay. if (qAbs(fontSmoothingGamma() - 2.2) < 0.25) glEnable(GL_FRAMEBUFFER_SRGB); +#endif } void QSGTextMaskMaterialData::deactivate() @@ -139,8 +141,10 @@ void QSGTextMaskMaterialData::deactivate() QSGMaterialShader::deactivate(); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); +#if !defined(QT_OPENGL_ES_2) if (qAbs(fontSmoothingGamma() - 2.2) < 0.25) glDisable(GL_FRAMEBUFFER_SRGB); +#endif } void QSGTextMaskMaterialData::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) diff --git a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp index bca57a3b6b..932da70471 100644 --- a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp +++ b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp @@ -75,6 +75,16 @@ void QSGDepthStencilBuffer::detach() GL_RENDERBUFFER, 0); } +// ###TODO Remove once using Khronos OpenGL headers +#if defined(QT_OPENGL_ES_2) +#ifndef GL_DEPTH24_STENCIL8_OES +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +#ifndef GL_DEPTH_COMPONENT24_OES +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif +#endif QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *context, const Format &format) : QSGDepthStencilBuffer(context, format) @@ -88,10 +98,19 @@ QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *conte m_functions.glGenRenderbuffers(1, &m_depthBuffer); m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); if (format.samples && m_functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) { +#if defined(QT_OPENGL_ES_2) + m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples, + GL_DEPTH24_STENCIL8_OES, width, height); +#else m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples, GL_DEPTH24_STENCIL8, width, height); +#endif } else { +#if defined(QT_OPENGL_ES_2) + m_functions.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); +#else m_functions.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); +#endif } m_stencilBuffer = m_depthBuffer; } @@ -100,7 +119,7 @@ QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *conte m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); #ifdef QT_OPENGL_ES const GLenum internalFormat = m_functions.hasOpenGLExtension(QOpenGLExtensions::Depth24) - ? GL_DEPTH_COMPONENT24 : GL_DEPTH_COMPONENT16; + ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16; #else const GLenum internalFormat = GL_DEPTH_COMPONENT; #endif |