Qt 4.8
qgl.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtOpenGL module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qapplication.h"
43 #include "qplatformdefs.h"
44 #include "qgl.h"
45 #include <qdebug.h>
46 
47 #if defined(Q_WS_X11)
48 #include "private/qt_x11_p.h"
49 #include "private/qpixmap_x11_p.h"
50 #define INT32 dummy_INT32
51 #define INT8 dummy_INT8
52 #ifdef QT_NO_EGL
53 # include <GL/glx.h>
54 #endif
55 #undef INT32
56 #undef INT8
57 #include "qx11info_x11.h"
58 #elif defined(Q_WS_MAC)
59 # include <private/qt_mac_p.h>
60 #endif
61 
62 #include <qdatetime.h>
63 
64 #include <stdlib.h> // malloc
65 
66 #include "qpixmap.h"
67 #include "qimage.h"
68 #include "qgl_p.h"
69 
70 #if !defined(QT_OPENGL_ES_1)
72 #include <private/qwindowsurface_gl_p.h>
73 #endif
74 
75 #ifndef QT_OPENGL_ES_2
76 #include <private/qpaintengine_opengl_p.h>
77 #endif
78 
79 #ifdef Q_WS_QWS
80 #include <private/qglwindowsurface_qws_p.h>
81 #endif
82 
83 #ifdef Q_WS_QPA
84 #include <QtGui/QPlatformGLContext>
85 #endif
86 
87 #include <qglpixelbuffer.h>
88 #include <qglframebufferobject.h>
89 
90 #include <private/qimage_p.h>
91 #include <private/qpixmapdata_p.h>
92 #include <private/qpixmapdata_gl_p.h>
93 #include <private/qglpixelbuffer_p.h>
94 #include <private/qimagepixmapcleanuphooks_p.h>
95 #include "qcolormap.h"
96 #include "qfile.h"
97 #include "qlibrary.h"
98 #include <qmutex.h>
99 
100 #if defined(QT_OPENGL_ES) && !defined(QT_NO_EGL)
101 #include <EGL/egl.h>
102 #endif
103 
104 #ifdef Q_OS_SYMBIAN
105 #include <private/qgltexturepool_p.h>
106 #include <private/qeglcontext_p.h>
107 #endif
108 
109 // #define QT_GL_CONTEXT_RESOURCE_DEBUG
110 
112 
113 #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
115 #endif
116 
117 #ifdef Q_WS_X11
118 extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
119 #endif
120 
123  if (context)
124  context->doneCurrent();
125  }
127 };
128 
129 #ifndef Q_WS_QPA
131 #endif
132 
133 Q_GLOBAL_STATIC(QGLFormat, qgl_default_format)
134 
136 {
137 public:
139  {
140  setOption(QGL::FormatOption(0xffff << 16)); // turn off all options
141  setOption(QGL::DirectRendering);
142  setPlane(1);
143  }
144 };
145 Q_GLOBAL_STATIC(QGLDefaultOverlayFormat, defaultOverlayFormatInstance)
146 
147 Q_GLOBAL_STATIC(QGLSignalProxy, theSignalProxy)
149 {
150  QGLSignalProxy *proxy = theSignalProxy();
151  if (proxy && proxy->thread() != qApp->thread()) {
152  if (proxy->thread() == QThread::currentThread())
153  proxy->moveToThread(qApp->thread());
154  }
155  return proxy;
156 }
157 
158 
160 {
161 public:
162  QGLEngineSelector() : engineType(QPaintEngine::MaxUser)
163  {
164  }
165 
167  if (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2)
168  engineType = type;
169  }
170 
172 #ifdef Q_WS_MAC
173  // The ATI X1600 driver for Mac OS X does not support return
174  // values from functions in GLSL. Since working around this in
175  // the GL2 engine would require a big, ugly rewrite, we're
176  // falling back to the GL 1 engine..
177  static bool mac_x1600_check_done = false;
178  if (!mac_x1600_check_done) {
179  QGLTemporaryContext *tmp = 0;
181  tmp = new QGLTemporaryContext();
182  if (strstr((char *) glGetString(GL_RENDERER), "X1600"))
183  engineType = QPaintEngine::OpenGL;
184  if (tmp)
185  delete tmp;
186  mac_x1600_check_done = true;
187  }
188 #endif
189  if (engineType == QPaintEngine::MaxUser) {
190  // No user-set engine - use the defaults
191 #if defined(QT_OPENGL_ES_2)
192  engineType = QPaintEngine::OpenGL2;
193 #else
194  // We can't do this in the constructor for this object because it
195  // needs to be called *before* the QApplication constructor.
196  // Also check for the FragmentShader extension in conjunction with
197  // the 2.0 version flag, to cover the case where we export the display
198  // from an old GL 1.1 server to a GL 2.x client. In that case we can't
199  // use GL 2.0.
202  && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty())
203  engineType = QPaintEngine::OpenGL2;
204  else
205  engineType = QPaintEngine::OpenGL;
206 #endif
207  }
208  return engineType;
209  }
210 
211 private:
213 };
214 
215 Q_GLOBAL_STATIC(QGLEngineSelector, qgl_engine_selector)
216 
217 
219 {
220  return qgl_engine_selector()->preferredPaintEngine() == QPaintEngine::OpenGL2;
221 }
222 
223 
300 {
301  qgl_engine_selector()->setPreferredPaintEngine(engineType);
302 }
303 
304 
305 /*****************************************************************************
306  QGLFormat implementation
307  *****************************************************************************/
308 
309 
379 #ifndef QT_OPENGL_ES
380 
381 static inline void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4])
382 {
383 #if defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
384 # pragma GCC diagnostic push
385 # pragma GCC diagnostic ignored "-Warray-bounds"
386 #endif
387 #define M(row,col) m[col*4+row]
388  out[0] =
389  M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
390  out[1] =
391  M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3];
392  out[2] =
393  M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3];
394  out[3] =
395  M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3];
396 #undef M
397 #if defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
398 # pragma GCC diagnostic pop
399 #endif
400 }
401 
402 static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz,
403  const GLdouble model[16], const GLdouble proj[16],
404  const GLint viewport[4],
405  GLdouble * winx, GLdouble * winy, GLdouble * winz)
406 {
407  GLdouble in[4], out[4];
408 
409  in[0] = objx;
410  in[1] = objy;
411  in[2] = objz;
412  in[3] = 1.0;
413  transform_point(out, model, in);
414  transform_point(in, proj, out);
415 
416  if (in[3] == 0.0)
417  return GL_FALSE;
418 
419  in[0] /= in[3];
420  in[1] /= in[3];
421  in[2] /= in[3];
422 
423  *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2;
424  *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2;
425 
426  *winz = (1 + in[2]) / 2;
427  return GL_TRUE;
428 }
429 
430 #endif // !QT_OPENGL_ES
431 
450 {
451  d = new QGLFormatPrivate;
452 }
453 
454 
478 QGLFormat::QGLFormat(QGL::FormatOptions options, int plane)
479 {
480  d = new QGLFormatPrivate;
481  QGL::FormatOptions newOpts = options;
482  d->opts = defaultFormat().d->opts;
483  d->opts |= (newOpts & 0xffff);
484  d->opts &= ~(newOpts >> 16);
485  d->pln = plane;
486 }
487 
492 {
493  if (d->ref != 1) {
494  QGLFormatPrivate *newd = new QGLFormatPrivate(d);
495  if (!d->ref.deref())
496  delete d;
497  d = newd;
498  }
499 }
500 
506 {
507  d = other.d;
508  d->ref.ref();
509 }
510 
516 {
517  if (d != other.d) {
518  other.d->ref.ref();
519  if (!d->ref.deref())
520  delete d;
521  d = other.d;
522  }
523  return *this;
524 }
525 
530 {
531  if (!d->ref.deref())
532  delete d;
533 }
534 
566 void QGLFormat::setDoubleBuffer(bool enable)
567 {
568  setOption(enable ? QGL::DoubleBuffer : QGL::SingleBuffer);
569 }
570 
571 
599 void QGLFormat::setDepth(bool enable)
600 {
601  setOption(enable ? QGL::DepthBuffer : QGL::NoDepthBuffer);
602 }
603 
604 
633 void QGLFormat::setRgba(bool enable)
634 {
635  setOption(enable ? QGL::Rgba : QGL::ColorIndex);
636 }
637 
638 
664 void QGLFormat::setAlpha(bool enable)
665 {
666  setOption(enable ? QGL::AlphaChannel : QGL::NoAlphaChannel);
667 }
668 
669 
694 void QGLFormat::setAccum(bool enable)
695 {
696  setOption(enable ? QGL::AccumBuffer : QGL::NoAccumBuffer);
697 }
698 
699 
724 void QGLFormat::setStencil(bool enable)
725 {
726  setOption(enable ? QGL::StencilBuffer: QGL::NoStencilBuffer);
727 }
728 
729 
754 void QGLFormat::setStereo(bool enable)
755 {
756  setOption(enable ? QGL::StereoBuffers : QGL::NoStereoBuffers);
757 }
758 
759 
788 {
789  setOption(enable ? QGL::DirectRendering : QGL::IndirectRendering);
790 }
791 
813 {
814  setOption(enable ? QGL::SampleBuffers : QGL::NoSampleBuffers);
815 }
816 
825 {
826  return d->numSamples;
827 }
828 
836 void QGLFormat::setSamples(int numSamples)
837 {
838  detach();
839  if (numSamples < 0) {
840  qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
841  return;
842  }
843  d->numSamples = numSamples;
844  setSampleBuffers(numSamples > 0);
845 }
846 
868 void QGLFormat::setSwapInterval(int interval)
869 {
870  detach();
871  d->swapInterval = interval;
872 }
873 
884 {
885  return d->swapInterval;
886 }
887 
912 void QGLFormat::setOverlay(bool enable)
913 {
914  setOption(enable ? QGL::HasOverlay : QGL::NoOverlay);
915 }
916 
924 int QGLFormat::plane() const
925 {
926  return d->pln;
927 }
928 
942 void QGLFormat::setPlane(int plane)
943 {
944  detach();
945  d->pln = plane;
946 }
947 
954 void QGLFormat::setOption(QGL::FormatOptions opt)
955 {
956  detach();
957  if (opt & 0xffff)
958  d->opts |= opt;
959  else
960  d->opts &= ~(opt >> 16);
961 }
962 
963 
964 
971 bool QGLFormat::testOption(QGL::FormatOptions opt) const
972 {
973  if (opt & 0xffff)
974  return (d->opts & opt) != 0;
975  else
976  return (d->opts & (opt >> 16)) == 0;
977 }
978 
985 {
986  detach();
987  if (size < 0) {
988  qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
989  return;
990  }
991  d->depthSize = size;
992  setDepth(size > 0);
993 }
994 
1001 {
1002  return d->depthSize;
1003 }
1004 
1016 {
1017  detach();
1018  if (size < 0) {
1019  qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
1020  return;
1021  }
1022  d->redSize = size;
1023 }
1024 
1036 {
1037  return d->redSize;
1038 }
1039 
1051 {
1052  detach();
1053  if (size < 0) {
1054  qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
1055  return;
1056  }
1057  d->greenSize = size;
1058 }
1059 
1071 {
1072  return d->greenSize;
1073 }
1074 
1086 {
1087  detach();
1088  if (size < 0) {
1089  qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
1090  return;
1091  }
1092  d->blueSize = size;
1093 }
1094 
1106 {
1107  return d->blueSize;
1108 }
1109 
1117 {
1118  detach();
1119  if (size < 0) {
1120  qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
1121  return;
1122  }
1123  d->alphaSize = size;
1124  setAlpha(size > 0);
1125 }
1126 
1133 {
1134  return d->alphaSize;
1135 }
1136 
1144 {
1145  detach();
1146  if (size < 0) {
1147  qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
1148  return;
1149  }
1150  d->accumSize = size;
1151  setAccum(size > 0);
1152 }
1153 
1160 {
1161  return d->accumSize;
1162 }
1163 
1170 {
1171  detach();
1172  if (size < 0) {
1173  qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
1174  return;
1175  }
1176  d->stencilSize = size;
1177  setStencil(size > 0);
1178 }
1179 
1186 {
1187  return d->stencilSize;
1188 }
1189 
1202 void QGLFormat::setVersion(int major, int minor)
1203 {
1204  if (major < 1 || minor < 0) {
1205  qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor);
1206  return;
1207  }
1208  detach();
1209  d->majorVersion = major;
1210  d->minorVersion = minor;
1211 }
1212 
1224 {
1225  return d->majorVersion;
1226 }
1227 
1239 {
1240  return d->minorVersion;
1241 }
1242 
1271 {
1272  detach();
1273  d->profile = profile;
1274 }
1275 
1287 {
1288  return d->profile;
1289 }
1290 
1291 
1320 QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString)
1321 {
1322  QGLFormat::OpenGLVersionFlags versionFlags = QGLFormat::OpenGL_Version_None;
1323 
1324  if (versionString.startsWith(QLatin1String("OpenGL ES"))) {
1325  QStringList parts = versionString.split(QLatin1Char(' '));
1326  if (parts.size() >= 3) {
1327  if (parts[2].startsWith(QLatin1String("1."))) {
1328  if (parts[1].endsWith(QLatin1String("-CM"))) {
1329  versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_0 |
1331  if (parts[2].startsWith(QLatin1String("1.1")))
1332  versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_1 |
1334  } else {
1335  // Not -CM, must be CL, CommonLite
1337  if (parts[2].startsWith(QLatin1String("1.1")))
1339  }
1340  } else {
1341  // OpenGL ES version 2.0 or higher
1342  versionFlags |= QGLFormat::OpenGL_ES_Version_2_0;
1343  }
1344  } else {
1345  // if < 3 parts to the name, it is an unrecognised OpenGL ES
1346  qWarning("Unrecognised OpenGL ES version");
1347  }
1348  } else {
1349  // not ES, regular OpenGL, the version numbers are first in the string
1350  if (versionString.startsWith(QLatin1String("1."))) {
1351  switch (versionString[2].toAscii()) {
1352  case '5':
1353  versionFlags |= QGLFormat::OpenGL_Version_1_5;
1354  case '4':
1355  versionFlags |= QGLFormat::OpenGL_Version_1_4;
1356  case '3':
1357  versionFlags |= QGLFormat::OpenGL_Version_1_3;
1358  case '2':
1359  versionFlags |= QGLFormat::OpenGL_Version_1_2;
1360  case '1':
1361  versionFlags |= QGLFormat::OpenGL_Version_1_1;
1362  default:
1363  break;
1364  }
1365  } else if (versionString.startsWith(QLatin1String("2."))) {
1366  versionFlags |= QGLFormat::OpenGL_Version_1_1 |
1372  if (versionString[2].toAscii() == '1')
1373  versionFlags |= QGLFormat::OpenGL_Version_2_1;
1374  } else if (versionString.startsWith(QLatin1String("3."))) {
1375  versionFlags |= QGLFormat::OpenGL_Version_1_1 |
1383  switch (versionString[2].toAscii()) {
1384  case '3':
1385  versionFlags |= QGLFormat::OpenGL_Version_3_3;
1386  case '2':
1387  versionFlags |= QGLFormat::OpenGL_Version_3_2;
1388  case '1':
1389  versionFlags |= QGLFormat::OpenGL_Version_3_1;
1390  case '0':
1391  break;
1392  default:
1393  versionFlags |= QGLFormat::OpenGL_Version_3_1 |
1396  break;
1397  }
1398  } else if (versionString.startsWith(QLatin1String("4."))) {
1399  versionFlags |= QGLFormat::OpenGL_Version_1_1 |
1411  } else {
1412  versionFlags |= QGLFormat::OpenGL_Version_1_1 |
1424  }
1425  }
1426  return versionFlags;
1427 }
1428 
2866 
2877 
2928 
2938 
2966 
3116 
3190 
3722 
4303 
4472 
5364 
5421 
5465 
5490 
5515 
5563 
5580 
5598 
5802 
double d
Definition: qnumeric_p.h:62
OpenGLContextProfile
This enum describes the OpenGL context profiles that can be specified for contexts implementing OpenG...
Definition: qgl.h:252
FormatOption
This enum specifies the format options that can be used to configure an OpenGL context.
Definition: qgl.h:144
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
void setProfile(OpenGLContextProfile profile)
Set the OpenGL context profile to profile.
Definition: qgl.cpp:1270
QGLFormat()
Constructs a QGLFormat object with the following default settings:
Definition: qgl.cpp:449
Q_OPENGL_EXPORT void setPreferredPaintEngine(QPaintEngine::Type engineType)
Sets the preferred OpenGL paint engine that is used to draw onto QGLWidget, QGLPixelBuffer and QGLFra...
Definition: qgl.cpp:299
int type
Definition: qmetatype.cpp:239
void setSamples(int numSamples)
Set the preferred number of samples per pixel when multisampling is enabled to numSamples.
Definition: qgl.cpp:836
void setStencil(bool enable)
If enable is true enables the stencil buffer; otherwise disables the stencil buffer.
Definition: qgl.cpp:724
static OpenGLVersionFlags openGLVersionFlags()
void setAccumBufferSize(int size)
Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component...
Definition: qgl.cpp:1143
static Q_OPENGL_EXPORT QGLExtensionFuncs qt_extensionFuncs
Definition: qgl_p.h:471
#define GL_TRUE
int greenBufferSize() const
Returns the green buffer size.
Definition: qgl.cpp:1070
void setSwapInterval(int interval)
Set the preferred swap interval.
Definition: qgl.cpp:868
void setRedBufferSize(int size)
Set the preferred red buffer size to size.
Definition: qgl.cpp:1015
Definition: qgl.h:147
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
void setOverlay(bool enable)
If enable is true enables an overlay plane; otherwise disables the overlay plane. ...
Definition: qgl.cpp:912
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QPaintEngine::Type preferredPaintEngine()
Definition: qgl.cpp:171
void setAlpha(bool enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer.
Definition: qgl.cpp:664
bool ref()
Atomically increments the value of this QAtomicInt.
void setSampleBuffers(bool enable)
If enable is true, a GL context with multisample buffer support is picked; otherwise ignored...
Definition: qgl.cpp:812
The QString class provides a Unicode character string.
Definition: qstring.h:83
int majorVersion() const
Returns the OpenGL major version.
Definition: qgl.cpp:1223
int redBufferSize() const
Returns the red buffer size.
Definition: qgl.cpp:1035
void setPreferredPaintEngine(QPaintEngine::Type type)
Definition: qgl.cpp:166
void setVersion(int major, int minor)
Set the OpenGL version to the major and minor numbers.
Definition: qgl.cpp:1202
OpenGLContextProfile profile() const
Returns the OpenGL context profile.
Definition: qgl.cpp:1286
QPaintEngine::Type engineType
Definition: qgl.cpp:212
static const QGLContext * currentContext()
Returns the current context, i.e.
Definition: qgl.cpp:3545
void setDirectRendering(bool enable)
If enable is true enables direct rendering; otherwise disables direct rendering.
Definition: qgl.cpp:787
#define M(row, col)
#define GL_FALSE
void detach()
Definition: qgl.cpp:491
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
void setAlphaBufferSize(int size)
Set the preferred alpha buffer size to size.
Definition: qgl.cpp:1116
int plane() const
Returns the plane of this format.
Definition: qgl.cpp:924
int alphaBufferSize() const
Returns the alpha buffer size.
Definition: qgl.cpp:1132
const Q_GUI_EXPORT QX11Info * qt_x11Info(const QPaintDevice *pd)
Returns the QX11Info structure for the pd paint device.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QGLContext * context
Definition: qgl.cpp:126
static bool isEmpty(const char *str)
int accumBufferSize() const
Returns the accumulation buffer size.
Definition: qgl.cpp:1159
The QGLFormat class specifies the display format of an OpenGL rendering context.
Definition: qgl.h:175
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
int depthBufferSize() const
Returns the depth buffer size.
Definition: qgl.cpp:1000
#define qApp
void setDepthBufferSize(int size)
Set the minimum depth buffer size to size.
Definition: qgl.cpp:984
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
void setDoubleBuffer(bool enable)
If enable is true sets double buffering; otherwise sets single buffering.
Definition: qgl.cpp:566
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
void setGreenBufferSize(int size)
Set the preferred green buffer size to size.
Definition: qgl.cpp:1050
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
Definition: qobject.cpp:1458
void setDepth(bool enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer.
Definition: qgl.cpp:599
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
bool qt_gl_preferGL2Engine()
Definition: qgl.cpp:218
QGLFormat & operator=(const QGLFormat &other)
Assigns other to this object.
Definition: qgl.cpp:515
static GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz, const GLdouble model[16], const GLdouble proj[16], const GLint viewport[4], GLdouble *winx, GLdouble *winy, GLdouble *winz)
Definition: qgl.cpp:402
void setRgba(bool enable)
If enable is true sets RGBA mode.
Definition: qgl.cpp:633
The QX11Info class provides information about the X display configuration.
Definition: qx11info_x11.h:63
~QGLFormat()
Destroys the QGLFormat.
Definition: qgl.cpp:529
static QThreadStorage< QGLThreadContext * > qgl_context_storage
Definition: qgl.cpp:130
int minorVersion() const
Returns the OpenGL minor version.
Definition: qgl.cpp:1238
QGLFormatPrivate * d
Definition: qgl.h:290
virtual void doneCurrent()
Makes no GL context the current context.
Definition: qgl_egl.cpp:277
int swapInterval() const
Returns the currently set swap interval.
Definition: qgl.cpp:883
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971
#define GL_RENDERER
~QGLThreadContext()
Definition: qgl.cpp:122
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954
int blueBufferSize() const
Returns the blue buffer size.
Definition: qgl.cpp:1105
static Extensions glExtensions()
Definition: qgl.cpp:5781
typedef GLint
Definition: glfunctions.h:67
QAtomicInt ref
Definition: qgl_p.h:155
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
void setStereo(bool enable)
If enable is true enables stereo buffering; otherwise disables stereo buffering.
Definition: qgl.cpp:754
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
static void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4])
Definition: qgl.cpp:381
void setBlueBufferSize(int size)
Set the preferred blue buffer size to size.
Definition: qgl.cpp:1085
#define class
int stencilBufferSize() const
Returns the stencil buffer size.
Definition: qgl.cpp:1185
void setPlane(int plane)
Sets the requested plane to plane.
Definition: qgl.cpp:942
The QThreadStorage class provides per-thread data storage.
void setStencilBufferSize(int size)
Set the preferred stencil buffer size to size.
Definition: qgl.cpp:1169
int samples() const
Returns the number of samples per pixel when multisampling is enabled.
Definition: qgl.cpp:824
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void setAccum(bool enable)
If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer...
Definition: qgl.cpp:694
QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString)
Definition: qgl.cpp:1320