egl: Update the OpenGL version in the context's QSurfaceFormat
The GLX and WGL support code does this already. Do it for EGL too since requesting OpenGLES with majorVersion 3 results in GLES3 (where supported) and in this case the expected majorVersion in QOpenGLContext::format() is 3. Change-Id: I73d61d7569e6ebaa91aef57fb1b0051a77a73355 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
parent
5aaec48000
commit
a4f421d431
@ -41,6 +41,7 @@
|
||||
|
||||
#include "qeglplatformcontext_p.h"
|
||||
#include "qeglconvenience_p.h"
|
||||
#include "qeglpbuffer_p.h"
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include <QOpenGLContext>
|
||||
|
||||
@ -126,6 +127,36 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont
|
||||
m_shareContext = 0;
|
||||
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, 0, contextAttrs.constData());
|
||||
}
|
||||
|
||||
if (m_eglContext == EGL_NO_CONTEXT) {
|
||||
qWarning("QEGLPlatformContext::init: eglError: %x, this: %p \n", eglGetError(), this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make the context current to ensure the GL version query works. This needs a surface too.
|
||||
const EGLint pbufferAttributes[] = {
|
||||
EGL_WIDTH, 1,
|
||||
EGL_HEIGHT, 1,
|
||||
EGL_LARGEST_PBUFFER, EGL_FALSE,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLSurface pbuffer = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, pbufferAttributes);
|
||||
if (pbuffer == EGL_NO_SURFACE)
|
||||
return;
|
||||
|
||||
if (eglMakeCurrent(m_eglDisplay, pbuffer, pbuffer, m_eglContext)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
}
|
||||
eglDestroySurface(m_eglDisplay, pbuffer);
|
||||
}
|
||||
|
||||
bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)
|
||||
|
Loading…
x
Reference in New Issue
Block a user