diff options
author | Eike Ziller <eike.ziller@nokia.com> | 2011-08-17 07:08:13 (GMT) |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-08-17 08:04:51 (GMT) |
commit | 8cce6c8b2a2fe831d9b20a9c751e35a3bdb8f9b4 (patch) | |
tree | 34f4cec8d8a84874d4c0a0919d8c12f4e9b03cb6 | |
parent | d3277f6d32395b373f45a63e462d3a345745e6f4 (diff) | |
download | Qt-8cce6c8b2a2fe831d9b20a9c751e35a3bdb8f9b4.zip Qt-8cce6c8b2a2fe831d9b20a9c751e35a3bdb8f9b4.tar.gz Qt-8cce6c8b2a2fe831d9b20a9c751e35a3bdb8f9b4.tar.bz2 |
uikit: Fixes for Open GL ES 1 and for pre-3GS devices
-rw-r--r-- | src/imports/imports.pro | 2 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikitwindow.mm | 31 |
2 files changed, 27 insertions, 6 deletions
diff --git a/src/imports/imports.pro b/src/imports/imports.pro index c1298e2..d0e24b0 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs SUBDIRS += folderlistmodel particles gestures -contains(QT_CONFIG, opengl): SUBDIRS += shaders +contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1): SUBDIRS += shaders diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm index 6e018fe..640b92e 100644 --- a/src/plugins/platforms/uikit/quikitwindow.mm +++ b/src/plugins/platforms/uikit/quikitwindow.mm @@ -53,6 +53,23 @@ #include <QtDebug> +static GLint stencilBits() +{ + static GLint bits; + static bool initialized = false; + if (!initialized) { + glGetIntegerv(GL_STENCIL_BITS, &bits); + initialized = true; + } + return bits; +} + +static GLint depthBits() +{ + // we can choose between GL_DEPTH24_STENCIL8_OES and GL_DEPTH_COMPONENT16 + return stencilBits() > 0 ? 24 : 16; +} + class EAGLPlatformContext : public QPlatformGLContext { public: @@ -60,13 +77,13 @@ public: : mView(view) { mFormat.setWindowApi(QPlatformWindowFormat::OpenGL); - mFormat.setDepthBufferSize(24); + mFormat.setDepthBufferSize(depthBits()); mFormat.setAccumBufferSize(0); mFormat.setRedBufferSize(8); mFormat.setGreenBufferSize(8); mFormat.setBlueBufferSize(8); mFormat.setAlphaBufferSize(8); - mFormat.setStencilBufferSize(8); + mFormat.setStencilBufferSize(stencilBits()); mFormat.setSamples(0); mFormat.setSampleBuffers(false); mFormat.setDoubleBuffer(true); @@ -74,7 +91,7 @@ public: mFormat.setRgba(true); mFormat.setAlpha(true); mFormat.setAccum(false); - mFormat.setStencil(true); + mFormat.setStencil(stencilBits() > 0); mFormat.setStereo(false); mFormat.setDirectRendering(false); @@ -203,9 +220,13 @@ private: glGenRenderbuffers(1, &mDepthRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, mDepthRenderbuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, mFramebufferWidth, mFramebufferHeight); + if (stencilBits() > 0) { + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, mFramebufferWidth, mFramebufferHeight); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mDepthRenderbuffer); + } else { + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mFramebufferWidth, mFramebufferHeight); + } glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthRenderbuffer); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mDepthRenderbuffer); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER)); |