rhi: gl: Fix GL_INVALID_OPERATION error at glPolygonMode

Fixes: QTBUG-112756
Pick-to: 6.5 6.4 6.2
Change-Id: Id03bf805d70754818a98606b81a08a70d06853ba
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
JiDe Zhang 2023-04-12 17:59:18 +08:00
parent d7607a463d
commit 143d00cc2c

View File

@ -658,6 +658,8 @@ bool QRhiGles2::create(QRhi::Flags flags)
return false;
f = static_cast<QOpenGLExtensions *>(ctx->extraFunctions());
const QSurfaceFormat actualFormat = ctx->format();
caps.gles = actualFormat.renderableType() == QSurfaceFormat::OpenGLES;
if (!caps.gles) {
glPolygonMode = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLenum, GLenum)>(
@ -708,8 +710,6 @@ bool QRhiGles2::create(QRhi::Flags flags)
if (version)
driverInfoStruct.deviceName += QByteArray(version);
const QSurfaceFormat actualFormat = ctx->format();
caps.ctxMajor = actualFormat.majorVersion();
caps.ctxMinor = actualFormat.minorVersion();
@ -769,8 +769,6 @@ bool QRhiGles2::create(QRhi::Flags flags)
f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.maxTextureSize);
caps.gles = actualFormat.renderableType() == QSurfaceFormat::OpenGLES;
if (!caps.gles || caps.ctxMajor >= 3) {
// non-ES or ES 3.0+
f->glGetIntegerv(GL_MAX_DRAW_BUFFERS, &caps.maxDrawBuffers);