1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtOpenGL module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QGL_H
|
---|
43 | #define QGL_H
|
---|
44 |
|
---|
45 | #include <QtGui/qwidget.h>
|
---|
46 | #include <QtOpenGL/qglcolormap.h>
|
---|
47 | #include <QtCore/qmap.h>
|
---|
48 |
|
---|
49 | QT_BEGIN_HEADER
|
---|
50 |
|
---|
51 | #if defined(Q_WS_WIN)
|
---|
52 | # include <QtCore/qt_windows.h>
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #if defined(Q_WS_MAC)
|
---|
56 | # include <OpenGL/gl.h>
|
---|
57 | # include <OpenGL/glu.h>
|
---|
58 | #elif defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
|
---|
59 | # include <GLES/gl.h>
|
---|
60 | #ifndef GL_DOUBLE
|
---|
61 | # define GL_DOUBLE GL_FLOAT
|
---|
62 | #endif
|
---|
63 | #ifndef GLdouble
|
---|
64 | typedef GLfloat GLdouble;
|
---|
65 | #endif
|
---|
66 | #elif defined(QT_OPENGL_ES_2)
|
---|
67 | # include <GLES2/gl2.h>
|
---|
68 | #ifndef GL_DOUBLE
|
---|
69 | # define GL_DOUBLE GL_FLOAT
|
---|
70 | #endif
|
---|
71 | #ifndef GLdouble
|
---|
72 | typedef GLfloat GLdouble;
|
---|
73 | #endif
|
---|
74 | #else
|
---|
75 | # include <GL/gl.h>
|
---|
76 | # ifndef QT_LINUXBASE
|
---|
77 | # include <GL/glu.h>
|
---|
78 | # endif
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | QT_BEGIN_NAMESPACE
|
---|
82 |
|
---|
83 | QT_MODULE(OpenGL)
|
---|
84 |
|
---|
85 | #if defined(Q_WS_MAC) && defined (QT_BUILD_OPENGL_LIB) && !defined(QT_MAC_USE_COCOA) && !defined(QDOC)
|
---|
86 | #define Q_MAC_COMPAT_GL_FUNCTIONS
|
---|
87 |
|
---|
88 | template <typename T>
|
---|
89 | struct QMacGLCompatTypes
|
---|
90 | {
|
---|
91 | typedef long CompatGLint;
|
---|
92 | typedef unsigned long CompatGLuint;
|
---|
93 | typedef unsigned long CompatGLenum;
|
---|
94 | };
|
---|
95 |
|
---|
96 | template <>
|
---|
97 | struct QMacGLCompatTypes<long>
|
---|
98 | {
|
---|
99 | typedef int CompatGLint;
|
---|
100 | typedef unsigned int CompatGLuint;
|
---|
101 | typedef unsigned int CompatGLenum;
|
---|
102 | };
|
---|
103 |
|
---|
104 | typedef QMacGLCompatTypes<GLint>::CompatGLint QMacCompatGLint;
|
---|
105 | typedef QMacGLCompatTypes<GLint>::CompatGLuint QMacCompatGLuint;
|
---|
106 | typedef QMacGLCompatTypes<GLint>::CompatGLenum QMacCompatGLenum;
|
---|
107 |
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | #ifdef QT3_SUPPORT
|
---|
111 | #define QGL_VERSION 460
|
---|
112 | #define QGL_VERSION_STR "4.6"
|
---|
113 | inline QT3_SUPPORT const char *qGLVersion() {
|
---|
114 | return QGL_VERSION_STR;
|
---|
115 | }
|
---|
116 | #endif
|
---|
117 |
|
---|
118 | #if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
---|
119 | class QGLCmap;
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | class QPixmap;
|
---|
123 | #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
|
---|
124 | class QGLOverlayWidget;
|
---|
125 | #endif
|
---|
126 | class QGLWidgetPrivate;
|
---|
127 | class QGLContextPrivate;
|
---|
128 |
|
---|
129 | // Namespace class:
|
---|
130 | namespace QGL
|
---|
131 | {
|
---|
132 | enum FormatOption {
|
---|
133 | DoubleBuffer = 0x0001,
|
---|
134 | DepthBuffer = 0x0002,
|
---|
135 | Rgba = 0x0004,
|
---|
136 | AlphaChannel = 0x0008,
|
---|
137 | AccumBuffer = 0x0010,
|
---|
138 | StencilBuffer = 0x0020,
|
---|
139 | StereoBuffers = 0x0040,
|
---|
140 | DirectRendering = 0x0080,
|
---|
141 | HasOverlay = 0x0100,
|
---|
142 | SampleBuffers = 0x0200,
|
---|
143 | SingleBuffer = DoubleBuffer << 16,
|
---|
144 | NoDepthBuffer = DepthBuffer << 16,
|
---|
145 | ColorIndex = Rgba << 16,
|
---|
146 | NoAlphaChannel = AlphaChannel << 16,
|
---|
147 | NoAccumBuffer = AccumBuffer << 16,
|
---|
148 | NoStencilBuffer = StencilBuffer << 16,
|
---|
149 | NoStereoBuffers = StereoBuffers << 16,
|
---|
150 | IndirectRendering = DirectRendering << 16,
|
---|
151 | NoOverlay = HasOverlay << 16,
|
---|
152 | NoSampleBuffers = SampleBuffers << 16
|
---|
153 | };
|
---|
154 | Q_DECLARE_FLAGS(FormatOptions, FormatOption)
|
---|
155 | }
|
---|
156 |
|
---|
157 | Q_DECLARE_OPERATORS_FOR_FLAGS(QGL::FormatOptions)
|
---|
158 |
|
---|
159 | class QGLFormatPrivate;
|
---|
160 |
|
---|
161 | class Q_OPENGL_EXPORT QGLFormat
|
---|
162 | {
|
---|
163 | public:
|
---|
164 | QGLFormat();
|
---|
165 | QGLFormat(QGL::FormatOptions options, int plane = 0);
|
---|
166 | QGLFormat(const QGLFormat &other);
|
---|
167 | QGLFormat &operator=(const QGLFormat &other);
|
---|
168 | ~QGLFormat();
|
---|
169 |
|
---|
170 | void setDepthBufferSize(int size);
|
---|
171 | int depthBufferSize() const;
|
---|
172 |
|
---|
173 | void setAccumBufferSize(int size);
|
---|
174 | int accumBufferSize() const;
|
---|
175 |
|
---|
176 | void setRedBufferSize(int size);
|
---|
177 | int redBufferSize() const;
|
---|
178 |
|
---|
179 | void setGreenBufferSize(int size);
|
---|
180 | int greenBufferSize() const;
|
---|
181 |
|
---|
182 | void setBlueBufferSize(int size);
|
---|
183 | int blueBufferSize() const;
|
---|
184 |
|
---|
185 | void setAlphaBufferSize(int size);
|
---|
186 | int alphaBufferSize() const;
|
---|
187 |
|
---|
188 | void setStencilBufferSize(int size);
|
---|
189 | int stencilBufferSize() const;
|
---|
190 |
|
---|
191 | void setSampleBuffers(bool enable);
|
---|
192 | bool sampleBuffers() const;
|
---|
193 |
|
---|
194 | void setSamples(int numSamples);
|
---|
195 | int samples() const;
|
---|
196 |
|
---|
197 | void setSwapInterval(int interval);
|
---|
198 | int swapInterval() const;
|
---|
199 |
|
---|
200 | bool doubleBuffer() const;
|
---|
201 | void setDoubleBuffer(bool enable);
|
---|
202 | bool depth() const;
|
---|
203 | void setDepth(bool enable);
|
---|
204 | bool rgba() const;
|
---|
205 | void setRgba(bool enable);
|
---|
206 | bool alpha() const;
|
---|
207 | void setAlpha(bool enable);
|
---|
208 | bool accum() const;
|
---|
209 | void setAccum(bool enable);
|
---|
210 | bool stencil() const;
|
---|
211 | void setStencil(bool enable);
|
---|
212 | bool stereo() const;
|
---|
213 | void setStereo(bool enable);
|
---|
214 | bool directRendering() const;
|
---|
215 | void setDirectRendering(bool enable);
|
---|
216 | bool hasOverlay() const;
|
---|
217 | void setOverlay(bool enable);
|
---|
218 |
|
---|
219 | int plane() const;
|
---|
220 | void setPlane(int plane);
|
---|
221 |
|
---|
222 | void setOption(QGL::FormatOptions opt);
|
---|
223 | bool testOption(QGL::FormatOptions opt) const;
|
---|
224 |
|
---|
225 | static QGLFormat defaultFormat();
|
---|
226 | static void setDefaultFormat(const QGLFormat& f);
|
---|
227 |
|
---|
228 | static QGLFormat defaultOverlayFormat();
|
---|
229 | static void setDefaultOverlayFormat(const QGLFormat& f);
|
---|
230 |
|
---|
231 | static bool hasOpenGL();
|
---|
232 | static bool hasOpenGLOverlays();
|
---|
233 |
|
---|
234 | enum OpenGLVersionFlag {
|
---|
235 | OpenGL_Version_None = 0x00000000,
|
---|
236 | OpenGL_Version_1_1 = 0x00000001,
|
---|
237 | OpenGL_Version_1_2 = 0x00000002,
|
---|
238 | OpenGL_Version_1_3 = 0x00000004,
|
---|
239 | OpenGL_Version_1_4 = 0x00000008,
|
---|
240 | OpenGL_Version_1_5 = 0x00000010,
|
---|
241 | OpenGL_Version_2_0 = 0x00000020,
|
---|
242 | OpenGL_Version_2_1 = 0x00000040,
|
---|
243 | OpenGL_ES_Common_Version_1_0 = 0x00000080,
|
---|
244 | OpenGL_ES_CommonLite_Version_1_0 = 0x00000100,
|
---|
245 | OpenGL_ES_Common_Version_1_1 = 0x00000200,
|
---|
246 | OpenGL_ES_CommonLite_Version_1_1 = 0x00000400,
|
---|
247 | OpenGL_ES_Version_2_0 = 0x00000800,
|
---|
248 | OpenGL_Version_3_0 = 0x00001000
|
---|
249 | };
|
---|
250 | Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)
|
---|
251 |
|
---|
252 | static OpenGLVersionFlags openGLVersionFlags();
|
---|
253 |
|
---|
254 | private:
|
---|
255 | QGLFormatPrivate *d;
|
---|
256 |
|
---|
257 | friend Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&);
|
---|
258 | friend Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&);
|
---|
259 | };
|
---|
260 |
|
---|
261 | Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFormat::OpenGLVersionFlags)
|
---|
262 |
|
---|
263 | Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&);
|
---|
264 | Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&);
|
---|
265 |
|
---|
266 | class Q_OPENGL_EXPORT QGLContext
|
---|
267 | {
|
---|
268 | Q_DECLARE_PRIVATE(QGLContext)
|
---|
269 | public:
|
---|
270 | QGLContext(const QGLFormat& format, QPaintDevice* device);
|
---|
271 | QGLContext(const QGLFormat& format);
|
---|
272 | virtual ~QGLContext();
|
---|
273 |
|
---|
274 | virtual bool create(const QGLContext* shareContext = 0);
|
---|
275 | bool isValid() const;
|
---|
276 | bool isSharing() const;
|
---|
277 | void reset();
|
---|
278 |
|
---|
279 | // ### Qt 5: make format() return a const ref instead
|
---|
280 | QGLFormat format() const;
|
---|
281 | QGLFormat requestedFormat() const;
|
---|
282 | void setFormat(const QGLFormat& format);
|
---|
283 |
|
---|
284 | // ### Qt 5: return bools + maybe remove virtuals
|
---|
285 | virtual void makeCurrent();
|
---|
286 | virtual void doneCurrent();
|
---|
287 |
|
---|
288 | virtual void swapBuffers() const;
|
---|
289 |
|
---|
290 | GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D,
|
---|
291 | GLint format = GL_RGBA);
|
---|
292 | GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D,
|
---|
293 | GLint format = GL_RGBA);
|
---|
294 | GLuint bindTexture(const QString &fileName);
|
---|
295 |
|
---|
296 | void deleteTexture(GLuint tx_id);
|
---|
297 |
|
---|
298 | void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
|
---|
299 | void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
|
---|
300 |
|
---|
301 | #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
|
---|
302 | GLuint bindTexture(const QImage &image, QMacCompatGLenum = GL_TEXTURE_2D,
|
---|
303 | QMacCompatGLint format = GL_RGBA);
|
---|
304 | GLuint bindTexture(const QPixmap &pixmap, QMacCompatGLenum = GL_TEXTURE_2D,
|
---|
305 | QMacCompatGLint format = GL_RGBA);
|
---|
306 |
|
---|
307 | void deleteTexture(QMacCompatGLuint tx_id);
|
---|
308 |
|
---|
309 | void drawTexture(const QRectF &target, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
|
---|
310 | void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
|
---|
311 | #endif
|
---|
312 |
|
---|
313 | static void setTextureCacheLimit(int size);
|
---|
314 | static int textureCacheLimit();
|
---|
315 |
|
---|
316 | void *getProcAddress(const QString &proc) const;
|
---|
317 | QPaintDevice* device() const;
|
---|
318 | QColor overlayTransparentColor() const;
|
---|
319 |
|
---|
320 | static const QGLContext* currentContext();
|
---|
321 |
|
---|
322 | protected:
|
---|
323 | virtual bool chooseContext(const QGLContext* shareContext = 0);
|
---|
324 |
|
---|
325 | #if defined(Q_WS_WIN)
|
---|
326 | virtual int choosePixelFormat(void* pfd, HDC pdc);
|
---|
327 | #endif
|
---|
328 | #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
|
---|
329 | virtual void* tryVisual(const QGLFormat& f, int bufDepth = 1);
|
---|
330 | virtual void* chooseVisual();
|
---|
331 | #endif
|
---|
332 | #if defined(Q_WS_MAC)
|
---|
333 | virtual void* chooseMacVisual(GDHandle);
|
---|
334 | #endif
|
---|
335 |
|
---|
336 | bool deviceIsPixmap() const;
|
---|
337 | bool windowCreated() const;
|
---|
338 | void setWindowCreated(bool on);
|
---|
339 | bool initialized() const;
|
---|
340 | void setInitialized(bool on);
|
---|
341 | void generateFontDisplayLists(const QFont & fnt, int listBase); // ### Qt 5: remove
|
---|
342 |
|
---|
343 | uint colorIndex(const QColor& c) const;
|
---|
344 | void setValid(bool valid);
|
---|
345 | void setDevice(QPaintDevice *pDev);
|
---|
346 |
|
---|
347 | protected:
|
---|
348 | static QGLContext* currentCtx;
|
---|
349 |
|
---|
350 | private:
|
---|
351 | QGLContextPrivate* d_ptr;
|
---|
352 |
|
---|
353 | friend class QGLPixelBuffer;
|
---|
354 | friend class QGLPixelBufferPrivate;
|
---|
355 | friend class QGLWidget;
|
---|
356 | friend class QGLDrawable;
|
---|
357 | friend class QGLWidgetPrivate;
|
---|
358 | friend class QGLGlyphCache;
|
---|
359 | friend class QOpenGLPaintEngine;
|
---|
360 | friend class QOpenGLPaintEnginePrivate;
|
---|
361 | friend class QGL2PaintEngineEx;
|
---|
362 | friend class QGL2PaintEngineExPrivate;
|
---|
363 | friend class QGLWindowSurface;
|
---|
364 | friend class QGLPixmapData;
|
---|
365 | friend class QGLPixmapFilterBase;
|
---|
366 | friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags();
|
---|
367 | #ifdef Q_WS_MAC
|
---|
368 | public:
|
---|
369 | void updatePaintDevice();
|
---|
370 | private:
|
---|
371 | friend class QMacGLWindowChangeEvent;
|
---|
372 | friend QGLContextPrivate *qt_phonon_get_dptr(const QGLContext *);
|
---|
373 | #endif
|
---|
374 | #ifdef Q_WS_WIN
|
---|
375 | friend class QGLFramebufferObject;
|
---|
376 | friend class QGLFramebufferObjectPrivate;
|
---|
377 | friend bool qt_resolve_GLSL_functions(QGLContext *ctx);
|
---|
378 | friend bool qt_createGLSLProgram(QGLContext *ctx, GLuint &program, const char *shader_src, GLuint &shader);
|
---|
379 | #endif
|
---|
380 | private:
|
---|
381 | Q_DISABLE_COPY(QGLContext)
|
---|
382 | };
|
---|
383 |
|
---|
384 |
|
---|
385 | class Q_OPENGL_EXPORT QGLWidget : public QWidget
|
---|
386 | {
|
---|
387 | Q_OBJECT
|
---|
388 | Q_DECLARE_PRIVATE(QGLWidget)
|
---|
389 | public:
|
---|
390 | explicit QGLWidget(QWidget* parent=0,
|
---|
391 | const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
|
---|
392 | explicit QGLWidget(QGLContext *context, QWidget* parent=0,
|
---|
393 | const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
|
---|
394 | explicit QGLWidget(const QGLFormat& format, QWidget* parent=0,
|
---|
395 | const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
|
---|
396 | #ifdef QT3_SUPPORT
|
---|
397 | QT3_SUPPORT_CONSTRUCTOR QGLWidget(QWidget* parent, const char* name,
|
---|
398 | const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
|
---|
399 | QT3_SUPPORT_CONSTRUCTOR QGLWidget(QGLContext *context, QWidget* parent, const char* name,
|
---|
400 | const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
|
---|
401 | QT3_SUPPORT_CONSTRUCTOR QGLWidget(const QGLFormat& format, QWidget* parent, const char* name,
|
---|
402 | const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
|
---|
403 | #endif
|
---|
404 | ~QGLWidget();
|
---|
405 |
|
---|
406 | void qglColor(const QColor& c) const;
|
---|
407 | void qglClearColor(const QColor& c) const;
|
---|
408 |
|
---|
409 | bool isValid() const;
|
---|
410 | bool isSharing() const;
|
---|
411 |
|
---|
412 | // ### Qt 5: return bools
|
---|
413 | void makeCurrent();
|
---|
414 | void doneCurrent();
|
---|
415 |
|
---|
416 | bool doubleBuffer() const;
|
---|
417 | void swapBuffers();
|
---|
418 |
|
---|
419 | // ### Qt 5: make format() return a const ref instead
|
---|
420 | QGLFormat format() const;
|
---|
421 | void setFormat(const QGLFormat& format);
|
---|
422 |
|
---|
423 | const QGLContext* context() const;
|
---|
424 | void setContext(QGLContext* context, const QGLContext* shareContext = 0,
|
---|
425 | bool deleteOldContext = true);
|
---|
426 |
|
---|
427 | QPixmap renderPixmap(int w = 0, int h = 0, bool useContext = false);
|
---|
428 | QImage grabFrameBuffer(bool withAlpha = false);
|
---|
429 |
|
---|
430 | void makeOverlayCurrent();
|
---|
431 | const QGLContext* overlayContext() const;
|
---|
432 |
|
---|
433 | static QImage convertToGLFormat(const QImage& img);
|
---|
434 |
|
---|
435 | void setMouseTracking(bool enable);
|
---|
436 |
|
---|
437 | const QGLColormap & colormap() const;
|
---|
438 | void setColormap(const QGLColormap & map);
|
---|
439 |
|
---|
440 | void renderText(int x, int y, const QString & str,
|
---|
441 | const QFont & fnt = QFont(), int listBase = 2000);
|
---|
442 | void renderText(double x, double y, double z, const QString & str,
|
---|
443 | const QFont & fnt = QFont(), int listBase = 2000);
|
---|
444 | QPaintEngine *paintEngine() const;
|
---|
445 |
|
---|
446 | GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D,
|
---|
447 | GLint format = GL_RGBA);
|
---|
448 | GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D,
|
---|
449 | GLint format = GL_RGBA);
|
---|
450 | GLuint bindTexture(const QString &fileName);
|
---|
451 |
|
---|
452 | void deleteTexture(GLuint tx_id);
|
---|
453 |
|
---|
454 | void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
|
---|
455 | void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
|
---|
456 |
|
---|
457 | #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
|
---|
458 | GLuint bindTexture(const QImage &image, QMacCompatGLenum = GL_TEXTURE_2D,
|
---|
459 | QMacCompatGLint format = GL_RGBA);
|
---|
460 | GLuint bindTexture(const QPixmap &pixmap, QMacCompatGLenum = GL_TEXTURE_2D,
|
---|
461 | QMacCompatGLint format = GL_RGBA);
|
---|
462 |
|
---|
463 | void deleteTexture(QMacCompatGLuint tx_id);
|
---|
464 |
|
---|
465 | void drawTexture(const QRectF &target, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
|
---|
466 | void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D);
|
---|
467 | #endif
|
---|
468 |
|
---|
469 | public Q_SLOTS:
|
---|
470 | virtual void updateGL();
|
---|
471 | virtual void updateOverlayGL();
|
---|
472 |
|
---|
473 | protected:
|
---|
474 | bool event(QEvent *);
|
---|
475 | virtual void initializeGL();
|
---|
476 | virtual void resizeGL(int w, int h);
|
---|
477 | virtual void paintGL();
|
---|
478 |
|
---|
479 | virtual void initializeOverlayGL();
|
---|
480 | virtual void resizeOverlayGL(int w, int h);
|
---|
481 | virtual void paintOverlayGL();
|
---|
482 |
|
---|
483 | void setAutoBufferSwap(bool on);
|
---|
484 | bool autoBufferSwap() const;
|
---|
485 |
|
---|
486 | void paintEvent(QPaintEvent*);
|
---|
487 | void resizeEvent(QResizeEvent*);
|
---|
488 |
|
---|
489 | virtual void glInit();
|
---|
490 | virtual void glDraw();
|
---|
491 | int fontDisplayListBase(const QFont & fnt, int listBase = 2000); // ### Qt 5: remove
|
---|
492 |
|
---|
493 | private:
|
---|
494 | Q_DISABLE_COPY(QGLWidget)
|
---|
495 |
|
---|
496 | #ifdef Q_WS_MAC
|
---|
497 | friend class QMacGLWindowChangeEvent;
|
---|
498 | #endif
|
---|
499 | friend class QGLDrawable;
|
---|
500 | friend class QGLPixelBuffer;
|
---|
501 | friend class QGLPixelBufferPrivate;
|
---|
502 | friend class QGLContext;
|
---|
503 | friend class QGLOverlayWidget;
|
---|
504 | friend class QOpenGLPaintEngine;
|
---|
505 | };
|
---|
506 |
|
---|
507 |
|
---|
508 | //
|
---|
509 | // QGLFormat inline functions
|
---|
510 | //
|
---|
511 |
|
---|
512 | inline bool QGLFormat::doubleBuffer() const
|
---|
513 | {
|
---|
514 | return testOption(QGL::DoubleBuffer);
|
---|
515 | }
|
---|
516 |
|
---|
517 | inline bool QGLFormat::depth() const
|
---|
518 | {
|
---|
519 | return testOption(QGL::DepthBuffer);
|
---|
520 | }
|
---|
521 |
|
---|
522 | inline bool QGLFormat::rgba() const
|
---|
523 | {
|
---|
524 | return testOption(QGL::Rgba);
|
---|
525 | }
|
---|
526 |
|
---|
527 | inline bool QGLFormat::alpha() const
|
---|
528 | {
|
---|
529 | return testOption(QGL::AlphaChannel);
|
---|
530 | }
|
---|
531 |
|
---|
532 | inline bool QGLFormat::accum() const
|
---|
533 | {
|
---|
534 | return testOption(QGL::AccumBuffer);
|
---|
535 | }
|
---|
536 |
|
---|
537 | inline bool QGLFormat::stencil() const
|
---|
538 | {
|
---|
539 | return testOption(QGL::StencilBuffer);
|
---|
540 | }
|
---|
541 |
|
---|
542 | inline bool QGLFormat::stereo() const
|
---|
543 | {
|
---|
544 | return testOption(QGL::StereoBuffers);
|
---|
545 | }
|
---|
546 |
|
---|
547 | inline bool QGLFormat::directRendering() const
|
---|
548 | {
|
---|
549 | return testOption(QGL::DirectRendering);
|
---|
550 | }
|
---|
551 |
|
---|
552 | inline bool QGLFormat::hasOverlay() const
|
---|
553 | {
|
---|
554 | return testOption(QGL::HasOverlay);
|
---|
555 | }
|
---|
556 |
|
---|
557 | inline bool QGLFormat::sampleBuffers() const
|
---|
558 | {
|
---|
559 | return testOption(QGL::SampleBuffers);
|
---|
560 | }
|
---|
561 |
|
---|
562 | QT_END_NAMESPACE
|
---|
563 |
|
---|
564 | QT_END_HEADER
|
---|
565 |
|
---|
566 | #endif // QGL_H
|
---|