summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorJames Turner <james.turner@kdab.com>2014-08-13 10:09:45 +0100
committerSean Harmer <sean.harmer@kdab.com>2014-08-19 11:46:10 +0200
commit6ebc0bd863f7b3c95021224ae223fe207bec0d4a (patch)
treed801dd4b0997030bf7b6c7101593020f7f99f6fe /src/plugins/platforms/ios
parent97cd20b2a02998e610d97e1907c23ad420f58502 (diff)
Allow ES3 (and ES1) context creation on iOS
Instead of hardcoding an ES2 context, use the major version from QSurfaceFormat. The EAGL API constants match the major versions so simply cast to avoid SDK version issues. Change-Id: Ieb46f10ea6b797d65c6c8b778bb043becb7a2f95 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qioscontext.mm23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm
index 4083c2d5a9..0143b75828 100644
--- a/src/plugins/platforms/ios/qioscontext.mm
+++ b/src/plugins/platforms/ios/qioscontext.mm
@@ -53,14 +53,27 @@
QIOSContext::QIOSContext(QOpenGLContext *context)
: QPlatformOpenGLContext()
, m_sharedContext(static_cast<QIOSContext *>(context->shareHandle()))
- , m_eaglContext([[EAGLContext alloc]
- initWithAPI:kEAGLRenderingAPIOpenGLES2
- sharegroup:m_sharedContext ? [m_sharedContext->m_eaglContext sharegroup] : nil])
, m_format(context->format())
{
m_format.setRenderableType(QSurfaceFormat::OpenGLES);
- m_format.setMajorVersion(2);
- m_format.setMinorVersion(0);
+ m_eaglContext = [[EAGLContext alloc]
+ initWithAPI:EAGLRenderingAPI(m_format.majorVersion())
+ sharegroup:m_sharedContext ? [m_sharedContext->m_eaglContext sharegroup] : nil];
+
+ if (m_eaglContext != nil) {
+ EAGLContext *originalContext = [EAGLContext currentContext];
+ [EAGLContext setCurrentContext:m_eaglContext];
+ const GLubyte *s = glGetString(GL_VERSION);
+ if (s) {
+ QByteArray version = QByteArray(reinterpret_cast<const char *>(s));
+ int major, minor;
+ if (QPlatformOpenGLContext::parseOpenGLVersion(version, major, minor)) {
+ m_format.setMajorVersion(major);
+ m_format.setMinorVersion(minor);
+ }
+ }
+ [EAGLContext setCurrentContext:originalContext];
+ }
// iOS internally double-buffers its rendering using copy instead of flipping,
// so technically we could report that we are single-buffered so that clients