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>
This commit is contained in:
James Turner 2014-08-13 10:09:45 +01:00 committed by Sean Harmer
parent 97cd20b2a0
commit 6ebc0bd863

View File

@ -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