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