1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
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 The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGL_H
43 #define QGL_H
44 
45 #include <QtGui/qwidget.h>
46 #include <QtGui/qpaintengine.h>
47 #include <QtOpenGL/qglcolormap.h>
48 #include <QtCore/qmap.h>
49 #include <QtCore/qscopedpointer.h>
50 
51 #ifdef Q_WS_QPA
52 #include <QtGui/QPlatformWindowFormat>
53 #endif
54 
55 QT_BEGIN_HEADER
56 
57 #if defined(Q_WS_WIN)
58 # include <QtCore/qt_windows.h>
59 #endif
60 
61 #if defined(Q_WS_MAC)
62 # include <OpenGL/gl.h>
63 #elif defined(QT_OPENGL_ES_1)
64 # if defined(Q_OS_MAC)
65 #  include <OpenGLES/ES1/gl.h>
66 # else
67 #  include <GLES/gl.h>
68 # endif
69 # ifndef GL_DOUBLE
70 #  define GL_DOUBLE GL_FLOAT
71 # endif
72 # ifndef GLdouble
73 typedef GLfloat GLdouble;
74 # endif
75 #elif defined(QT_OPENGL_ES_2)
76 # if defined(Q_OS_MAC)
77 #  include <OpenGLES/ES2/gl.h>
78 # else
79 #  include <GLES2/gl2.h>
80 # endif
81 # ifndef GL_DOUBLE
82 #  define GL_DOUBLE GL_FLOAT
83 # endif
84 # ifndef GLdouble
85 typedef GLfloat GLdouble;
86 # endif
87 #else
88 # include <GL/gl.h>
89 #endif
90 
91 QT_BEGIN_NAMESPACE
92 
93 QT_MODULE(OpenGL)
94 
95 #if defined(Q_WS_MAC) && defined (QT_BUILD_OPENGL_LIB) && !defined(QT_MAC_USE_COCOA) && !defined(QDOC)
96 #define Q_MAC_COMPAT_GL_FUNCTIONS
97 
98 template <typename T>
99 struct QMacGLCompatTypes
100 {
101     typedef long CompatGLint;
102     typedef unsigned long CompatGLuint;
103     typedef unsigned long CompatGLenum;
104 };
105 
106 template <>
107 struct QMacGLCompatTypes<long>
108 {
109     typedef int CompatGLint;
110     typedef unsigned int CompatGLuint;
111     typedef unsigned int CompatGLenum;
112 };
113 
114 typedef QMacGLCompatTypes<GLint>::CompatGLint QMacCompatGLint;
115 typedef QMacGLCompatTypes<GLint>::CompatGLuint QMacCompatGLuint;
116 typedef QMacGLCompatTypes<GLint>::CompatGLenum QMacCompatGLenum;
117 
118 #endif
119 
120 #ifdef QT3_SUPPORT
121 #define QGL_VERSION        460
122 #define QGL_VERSION_STR        "4.6"
123 inline QT3_SUPPORT const char *qGLVersion() {
124     return QGL_VERSION_STR;
125 }
126 #endif
127 
128 #if defined(Q_WS_WIN) || defined(Q_WS_MAC)
129 class QGLCmap;
130 #endif
131 
132 class QPixmap;
133 #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
134 class QGLOverlayWidget;
135 #endif
136 class QGLWidgetPrivate;
137 class QGLContextPrivate;
138 
139 // Namespace class:
140 namespace QGL
141 {
142     Q_OPENGL_EXPORT void setPreferredPaintEngine(QPaintEngine::Type engineType);
143 
144     enum FormatOption {
145         DoubleBuffer            = 0x0001,
146         DepthBuffer             = 0x0002,
147         Rgba                    = 0x0004,
148         AlphaChannel            = 0x0008,
149         AccumBuffer             = 0x0010,
150         StencilBuffer           = 0x0020,
151         StereoBuffers           = 0x0040,
152         DirectRendering         = 0x0080,
153         HasOverlay              = 0x0100,
154         SampleBuffers           = 0x0200,
155         DeprecatedFunctions     = 0x0400,
156         SingleBuffer            = DoubleBuffer    << 16,
157         NoDepthBuffer           = DepthBuffer     << 16,
158         ColorIndex              = Rgba            << 16,
159         NoAlphaChannel          = AlphaChannel    << 16,
160         NoAccumBuffer           = AccumBuffer     << 16,
161         NoStencilBuffer         = StencilBuffer   << 16,
162         NoStereoBuffers         = StereoBuffers   << 16,
163         IndirectRendering       = DirectRendering << 16,
164         NoOverlay               = HasOverlay      << 16,
165         NoSampleBuffers         = SampleBuffers   << 16,
166         NoDeprecatedFunctions   = DeprecatedFunctions << 16
167     };
168     Q_DECLARE_FLAGS(FormatOptions, FormatOption)
169 }
170 
171 Q_DECLARE_OPERATORS_FOR_FLAGS(QGL::FormatOptions)
172 
173 class QGLFormatPrivate;
174 
175 class Q_OPENGL_EXPORT QGLFormat
176 {
177 public:
178     QGLFormat();
179     QGLFormat(QGL::FormatOptions options, int plane = 0);
180     QGLFormat(const QGLFormat &other);
181     QGLFormat &operator=(const QGLFormat &other);
182     ~QGLFormat();
183 
184     void setDepthBufferSize(int size);
185     int  depthBufferSize() const;
186 
187     void setAccumBufferSize(int size);
188     int  accumBufferSize() const;
189 
190     void setRedBufferSize(int size);
191     int  redBufferSize() const;
192 
193     void setGreenBufferSize(int size);
194     int  greenBufferSize() const;
195 
196     void setBlueBufferSize(int size);
197     int  blueBufferSize() const;
198 
199     void setAlphaBufferSize(int size);
200     int  alphaBufferSize() const;
201 
202     void setStencilBufferSize(int size);
203     int  stencilBufferSize() const;
204 
205     void setSampleBuffers(bool enable);
206     bool sampleBuffers() const;
207 
208     void setSamples(int numSamples);
209     int  samples() const;
210 
211     void setSwapInterval(int interval);
212     int  swapInterval() const;
213 
214     bool doubleBuffer() const;
215     void setDoubleBuffer(bool enable);
216     bool depth() const;
217     void setDepth(bool enable);
218     bool rgba() const;
219     void setRgba(bool enable);
220     bool alpha() const;
221     void setAlpha(bool enable);
222     bool accum() const;
223     void setAccum(bool enable);
224     bool stencil() const;
225     void setStencil(bool enable);
226     bool stereo() const;
227     void setStereo(bool enable);
228     bool directRendering() const;
229     void setDirectRendering(bool enable);
230     bool hasOverlay() const;
231     void setOverlay(bool enable);
232 
233     int plane() const;
234     void setPlane(int plane);
235 
236     void setOption(QGL::FormatOptions opt);
237     bool testOption(QGL::FormatOptions opt) const;
238 
239     static QGLFormat defaultFormat();
240     static void setDefaultFormat(const QGLFormat& f);
241 
242     static QGLFormat defaultOverlayFormat();
243     static void setDefaultOverlayFormat(const QGLFormat& f);
244 
245     static bool hasOpenGL();
246     static bool hasOpenGLOverlays();
247 
248     void setVersion(int major, int minor);
249     int majorVersion() const;
250     int minorVersion() const;
251 
252     enum OpenGLContextProfile {
253         NoProfile,
254         CoreProfile,
255         CompatibilityProfile
256     };
257 
258     void setProfile(OpenGLContextProfile profile);
259     OpenGLContextProfile profile() const;
260 
261     enum OpenGLVersionFlag {
262         OpenGL_Version_None               = 0x00000000,
263         OpenGL_Version_1_1                = 0x00000001,
264         OpenGL_Version_1_2                = 0x00000002,
265         OpenGL_Version_1_3                = 0x00000004,
266         OpenGL_Version_1_4                = 0x00000008,
267         OpenGL_Version_1_5                = 0x00000010,
268         OpenGL_Version_2_0                = 0x00000020,
269         OpenGL_Version_2_1                = 0x00000040,
270         OpenGL_ES_Common_Version_1_0      = 0x00000080,
271         OpenGL_ES_CommonLite_Version_1_0  = 0x00000100,
272         OpenGL_ES_Common_Version_1_1      = 0x00000200,
273         OpenGL_ES_CommonLite_Version_1_1  = 0x00000400,
274         OpenGL_ES_Version_2_0             = 0x00000800,
275         OpenGL_Version_3_0                = 0x00001000,
276         OpenGL_Version_3_1                = 0x00002000,
277         OpenGL_Version_3_2                = 0x00004000,
278         OpenGL_Version_3_3                = 0x00008000,
279         OpenGL_Version_4_0                = 0x00010000
280     };
281     Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)
282 
283     static OpenGLVersionFlags openGLVersionFlags();
284 
285 #if defined(Q_WS_QPA)
286     static QGLFormat fromPlatformWindowFormat(const QPlatformWindowFormat &format);
287     static QPlatformWindowFormat toPlatformWindowFormat(const QGLFormat &format);
288 #endif
289 private:
290     QGLFormatPrivate *d;
291 
292     void detach();
293 
294     friend Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&);
295     friend Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&);
296 #ifndef QT_NO_DEBUG_STREAM
297     friend Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &);
298 #endif
299 };
300 
301 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFormat::OpenGLVersionFlags)
302 
303 Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&);
304 Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&);
305 
306 #ifndef QT_NO_DEBUG_STREAM
307 Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &);
308 #endif
309 
310 class Q_OPENGL_EXPORT QGLContext
311 {
312     Q_DECLARE_PRIVATE(QGLContext)
313 public:
314     QGLContext(const QGLFormat& format, QPaintDevice* device);
315     QGLContext(const QGLFormat& format);
316     virtual ~QGLContext();
317 
318     virtual bool create(const QGLContext* shareContext = 0);
319     bool isValid() const;
320     bool isSharing() const;
321     void reset();
322 
323     static bool areSharing(const QGLContext *context1, const QGLContext *context2);
324 
325     QGLFormat format() const;
326     QGLFormat requestedFormat() const;
327     void setFormat(const QGLFormat& format);
328 
329     // ### Qt 5: return bools + maybe remove virtuals
330     virtual void makeCurrent();
331     virtual void doneCurrent();
332 
333     virtual void swapBuffers() const;
334 
335     enum BindOption {
336         NoBindOption                            = 0x0000,
337         InvertedYBindOption                     = 0x0001,
338         MipmapBindOption                        = 0x0002,
339         PremultipliedAlphaBindOption            = 0x0004,
340         LinearFilteringBindOption               = 0x0008,
341 
342         MemoryManagedBindOption                 = 0x0010, // internal flag
343         CanFlipNativePixmapBindOption           = 0x0020, // internal flag
344 
345         DefaultBindOption                       = LinearFilteringBindOption
346                                                   | InvertedYBindOption
347                                                   | MipmapBindOption,
348         InternalBindOption                      = MemoryManagedBindOption
349                                                   | PremultipliedAlphaBindOption
350     };
351     Q_DECLARE_FLAGS(BindOptions, BindOption)
352 
353     GLuint bindTexture(const QImage &image, GLenum target, GLint format,
354                        BindOptions options);
355     GLuint bindTexture(const QPixmap &pixmap, GLenum target, GLint format,
356                        BindOptions options);
357 
358     GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D,
359                        GLint format = GL_RGBA);
360     GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D,
361                        GLint format = GL_RGBA);
362     GLuint bindTexture(const QString &fileName);
363 
364     void deleteTexture(GLuint tx_id);
365 
366     void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
367     void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
368 
369 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
370     GLuint bindTexture(const QImage &image, QMacCompatGLenum = GL_TEXTURE_2D,
371                        QMacCompatGLint format = GL_RGBA);
372     GLuint bindTexture(const QPixmap &pixmap, QMacCompatGLenum = GL_TEXTURE_2D,
373                        QMacCompatGLint format = GL_RGBA);
374     GLuint bindTexture(const QImage &image, QMacCompatGLenum, QMacCompatGLint format,
375                        BindOptions);
376     GLuint bindTexture(const QPixmap &pixmap, QMacCompatGLenum, QMacCompatGLint format,
377                        BindOptions);
378 
379     void deleteTexture(QMacCompatGLuint tx_id);
380 
381     void drawTexture(const QRectF &target, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
382     void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
383 #endif
384 
385     static void setTextureCacheLimit(int size);
386     static int textureCacheLimit();
387 
388     void *getProcAddress(const QString &proc) const;
389     QPaintDevice* device() const;
390     QColor overlayTransparentColor() const;
391 
392     static const QGLContext* currentContext();
393 
394 #ifdef Q_WS_QPA
395     static QGLContext *fromPlatformGLContext(QPlatformGLContext *platformContext);
396 #endif
397 protected:
398     virtual bool chooseContext(const QGLContext* shareContext = 0);
399 
400 #if defined(Q_WS_WIN)
401     virtual int choosePixelFormat(void* pfd, HDC pdc);
402 #endif
403 #if defined(Q_WS_X11)
404     virtual void* tryVisual(const QGLFormat& f, int bufDepth = 1);
405     virtual void* chooseVisual();
406 #endif
407 #if defined(Q_WS_MAC)
408     virtual void* chooseMacVisual(GDHandle);
409 #endif
410 
411     bool deviceIsPixmap() const;
412     bool windowCreated() const;
413     void setWindowCreated(bool on);
414     bool initialized() const;
415     void setInitialized(bool on);
416     void generateFontDisplayLists(const QFont & fnt, int listBase); // ### Qt 5: remove
417 
418     uint colorIndex(const QColor& c) const;
419     void setValid(bool valid);
420     void setDevice(QPaintDevice *pDev);
421 
422 protected:
423     static QGLContext* currentCtx;
424 
425 private:
426 #ifdef Q_WS_QPA
427     QGLContext(QPlatformGLContext *platformContext);
428 #endif
429 
430     QScopedPointer<QGLContextPrivate> d_ptr;
431 
432     friend class QGLPixelBuffer;
433     friend class QGLPixelBufferPrivate;
434     friend class QGLWidget;
435     friend class QGLWidgetPrivate;
436     friend class QGLGlyphCache;
437     friend class QOpenGLPaintEngine;
438     friend class QOpenGLPaintEnginePrivate;
439     friend class QGL2PaintEngineEx;
440     friend class QGL2PaintEngineExPrivate;
441     friend class QGLEngineShaderManager;
442     friend class QGLWindowSurface;
443     friend class QGLPixmapData;
444     friend class QGLPixmapFilterBase;
445     friend class QGLTextureGlyphCache;
446     friend struct QGLGlyphTexture;
447     friend class QGLContextGroup;
448     friend class QGLSharedResourceGuard;
449     friend class QGLPixmapBlurFilter;
450     friend class QGLExtensions;
451     friend class QGLTexture;
452     friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags();
453 #ifdef Q_WS_MAC
454 public:
455     void updatePaintDevice();
456 private:
457     friend class QMacGLWindowChangeEvent;
458     friend QGLContextPrivate *qt_phonon_get_dptr(const QGLContext *);
459 #endif
460     friend class QGLFramebufferObject;
461     friend class QGLFramebufferObjectPrivate;
462     friend class QGLFBOGLPaintDevice;
463     friend class QGLPaintDevice;
464     friend class QGLWidgetGLPaintDevice;
465     friend class QX11GLPixmapData;
466     friend class QX11GLSharedContexts;
467     friend class QGLContextResourceBase;
468 private:
469     Q_DISABLE_COPY(QGLContext)
470 };
471 
472 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLContext::BindOptions)
473 
474 class Q_OPENGL_EXPORT QGLWidget : public QWidget
475 {
476     Q_OBJECT
477     Q_DECLARE_PRIVATE(QGLWidget)
478 public:
479     explicit QGLWidget(QWidget* parent=0,
480                        const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
481     explicit QGLWidget(QGLContext *context, QWidget* parent=0,
482                        const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
483     explicit QGLWidget(const QGLFormat& format, QWidget* parent=0,
484                        const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
485 #ifdef QT3_SUPPORT
486     QT3_SUPPORT_CONSTRUCTOR QGLWidget(QWidget* parent, const char* name,
487                                     const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
488     QT3_SUPPORT_CONSTRUCTOR QGLWidget(QGLContext *context, QWidget* parent, const char* name,
489                                     const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
490     QT3_SUPPORT_CONSTRUCTOR QGLWidget(const QGLFormat& format, QWidget* parent, const char* name,
491                                     const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
492 #endif
493     ~QGLWidget();
494 
495     void qglColor(const QColor& c) const;
496     void qglClearColor(const QColor& c) const;
497 
498     bool isValid() const;
499     bool isSharing() const;
500 
501     // ### Qt 5: return bools
502     void makeCurrent();
503     void doneCurrent();
504 
505     bool doubleBuffer() const;
506     void swapBuffers();
507 
508     QGLFormat format() const;
509     void setFormat(const QGLFormat& format);
510 
511     const QGLContext* context() const;
512     void setContext(QGLContext* context, const QGLContext* shareContext = 0,
513                     bool deleteOldContext = true);
514 
515     QPixmap renderPixmap(int w = 0, int h = 0, bool useContext = false);
516     QImage grabFrameBuffer(bool withAlpha = false);
517 
518     void makeOverlayCurrent();
519     const QGLContext* overlayContext() const;
520 
521     static QImage convertToGLFormat(const QImage& img);
522 
523     void setMouseTracking(bool enable);
524 
525     const QGLColormap & colormap() const;
526     void  setColormap(const QGLColormap & map);
527 
528     void renderText(int x, int y, const QString & str,
529                      const QFont & fnt = QFont(), int listBase = 2000);
530     void renderText(double x, double y, double z, const QString & str,
531                      const QFont & fnt = QFont(), int listBase = 2000);
532     QPaintEngine *paintEngine() const;
533 
534     GLuint bindTexture(const QImage &image, GLenum target, GLint format,
535                        QGLContext::BindOptions options);
536     GLuint bindTexture(const QPixmap &pixmap, GLenum target, GLint format,
537                        QGLContext::BindOptions options);
538 
539     GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D,
540                        GLint format = GL_RGBA);
541     GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D,
542                        GLint format = GL_RGBA);
543 
544     GLuint bindTexture(const QString &fileName);
545 
546     void deleteTexture(GLuint tx_id);
547 
548     void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
549     void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
550 
551 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
552     GLuint bindTexture(const QImage &image, QMacCompatGLenum = GL_TEXTURE_2D,
553                        QMacCompatGLint format = GL_RGBA);
554     GLuint bindTexture(const QPixmap &pixmap, QMacCompatGLenum = GL_TEXTURE_2D,
555                        QMacCompatGLint format = GL_RGBA);
556     GLuint bindTexture(const QImage &image, QMacCompatGLenum, QMacCompatGLint format,
557                        QGLContext::BindOptions);
558     GLuint bindTexture(const QPixmap &pixmap, QMacCompatGLenum, QMacCompatGLint format,
559                        QGLContext::BindOptions);
560 
561     void deleteTexture(QMacCompatGLuint tx_id);
562 
563     void drawTexture(const QRectF &target, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
564     void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
565 #endif
566 
567 public Q_SLOTS:
568     virtual void updateGL();
569     virtual void updateOverlayGL();
570 
571 protected:
572     bool event(QEvent *);
573     virtual void initializeGL();
574     virtual void resizeGL(int w, int h);
575     virtual void paintGL();
576 
577     virtual void initializeOverlayGL();
578     virtual void resizeOverlayGL(int w, int h);
579     virtual void paintOverlayGL();
580 
581     void setAutoBufferSwap(bool on);
582     bool autoBufferSwap() const;
583 
584     void paintEvent(QPaintEvent*);
585     void resizeEvent(QResizeEvent*);
586 
587     virtual void glInit();
588     virtual void glDraw();
589     int fontDisplayListBase(const QFont & fnt, int listBase = 2000); // ### Qt 5: remove
590 
591 private:
592     Q_DISABLE_COPY(QGLWidget)
593 
594 #ifdef Q_WS_MAC
595     friend class QMacGLWindowChangeEvent;
596 #endif
597     friend class QGLDrawable;
598     friend class QGLPixelBuffer;
599     friend class QGLPixelBufferPrivate;
600     friend class QGLContext;
601     friend class QGLContextPrivate;
602     friend class QGLOverlayWidget;
603     friend class QOpenGLPaintEngine;
604     friend class QGLPaintDevice;
605     friend class QGLWidgetGLPaintDevice;
606 };
607 
608 
609 //
610 // QGLFormat inline functions
611 //
612 
613 inline bool QGLFormat::doubleBuffer() const
614 {
615     return testOption(QGL::DoubleBuffer);
616 }
617 
618 inline bool QGLFormat::depth() const
619 {
620     return testOption(QGL::DepthBuffer);
621 }
622 
623 inline bool QGLFormat::rgba() const
624 {
625     return testOption(QGL::Rgba);
626 }
627 
628 inline bool QGLFormat::alpha() const
629 {
630     return testOption(QGL::AlphaChannel);
631 }
632 
633 inline bool QGLFormat::accum() const
634 {
635     return testOption(QGL::AccumBuffer);
636 }
637 
638 inline bool QGLFormat::stencil() const
639 {
640     return testOption(QGL::StencilBuffer);
641 }
642 
643 inline bool QGLFormat::stereo() const
644 {
645     return testOption(QGL::StereoBuffers);
646 }
647 
648 inline bool QGLFormat::directRendering() const
649 {
650     return testOption(QGL::DirectRendering);
651 }
652 
653 inline bool QGLFormat::hasOverlay() const
654 {
655     return testOption(QGL::HasOverlay);
656 }
657 
658 inline bool QGLFormat::sampleBuffers() const
659 {
660     return testOption(QGL::SampleBuffers);
661 }
662 
663 QT_END_NAMESPACE
664 
665 QT_END_HEADER
666 
667 #endif // QGL_H
668