Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qplatformopenglcontext.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QOpenGLFunctions>
7
9
52
57
61
71
81
83{
84 Q_D(const QPlatformOpenGLContext);
85 return d->context;
86}
87
88void QPlatformOpenGLContext::setContext(QOpenGLContext *context)
89{
91 d->context = context;
92}
93
94bool QPlatformOpenGLContext::parseOpenGLVersion(const QByteArray &versionString, int &major, int &minor)
95{
96 bool majorOk = false;
97 bool minorOk = false;
98 QList<QByteArray> parts = versionString.split(' ');
99 if (versionString.startsWith(QByteArrayLiteral("OpenGL ES"))) {
100 if (parts.size() >= 3) {
101 QList<QByteArray> versionParts = parts.at(2).split('.');
102 if (versionParts.size() >= 2) {
103 major = versionParts.at(0).toInt(&majorOk);
104 minor = versionParts.at(1).toInt(&minorOk);
105 // Nexus 6 has "OpenGL ES 3.0V@95.0 (GIT@I86da836d38)"
106 if (!minorOk)
107 if (int idx = versionParts.at(1).indexOf('V'))
108 minor = versionParts.at(1).left(idx).toInt(&minorOk);
109 } else {
110 qWarning("Unrecognized OpenGL ES version");
111 }
112 } else {
113 // If < 3 parts to the name, it is an unrecognised OpenGL ES
114 qWarning("Unrecognised OpenGL ES version");
115 }
116 } else {
117 // Not OpenGL ES, but regular OpenGL, the version numbers are first in the string
118 QList<QByteArray> versionParts = parts.at(0).split('.');
119 if (versionParts.size() >= 2) {
120 major = versionParts.at(0).toInt(&majorOk);
121 minor = versionParts.at(1).toInt(&minorOk);
122 } else {
123 qWarning("Unrecognized OpenGL version");
124 }
125 }
126
127 if (!majorOk || !minorOk)
128 qWarning("Unrecognized OpenGL version");
129 return (majorOk && minorOk);
130}
131
139
147
\inmodule QtCore
Definition qbytearray.h:57
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays.
bool startsWith(QByteArrayView bv) const
Definition qbytearray.h:223
\inmodule QtGui
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
virtual void initialize()
Called after a new instance is constructed.
QOpenGLContext * context() const
virtual void endFrame()
Called when the RHI ends rendering a in the context.
virtual GLuint defaultFramebufferObject(QPlatformSurface *surface) const
Reimplement in subclass if your platform uses framebuffer objects for surfaces.
virtual void beginFrame()
Called when the RHI begins rendering a new frame in the context.
static bool parseOpenGLVersion(const QByteArray &versionString, int &major, int &minor)
The QPlatformSurface class provides an abstraction for a surface.
Combined button and popup list for selecting options.
static void * context
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
#define qWarning
Definition qlogging.h:166
#define GLuint
QObject::connect nullptr