52 #include <QtGui/QPlatformWindowFormat>
62 # include <OpenGL/gl.h>
63 #elif defined(QT_OPENGL_ES_1)
64 # if defined(Q_OS_MAC)
65 # include <OpenGLES/ES1/gl.h>
70 # define GL_DOUBLE GL_FLOAT
73 typedef GLfloat GLdouble;
75 #elif defined(QT_OPENGL_ES_2)
76 # if defined(Q_OS_MAC)
77 # include <OpenGLES/ES2/gl.h>
79 # include <GLES2/gl2.h>
82 # define GL_DOUBLE GL_FLOAT
85 typedef GLfloat GLdouble;
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
99 struct QMacGLCompatTypes
101 typedef long CompatGLint;
102 typedef unsigned long CompatGLuint;
103 typedef unsigned long CompatGLenum;
107 struct QMacGLCompatTypes<long>
109 typedef int CompatGLint;
110 typedef unsigned int CompatGLuint;
111 typedef unsigned int CompatGLenum;
114 typedef QMacGLCompatTypes<GLint>::CompatGLint QMacCompatGLint;
115 typedef QMacGLCompatTypes<GLint>::CompatGLuint QMacCompatGLuint;
116 typedef QMacGLCompatTypes<GLint>::CompatGLenum QMacCompatGLenum;
121 #define QGL_VERSION 460
122 #define QGL_VERSION_STR "4.6"
123 inline QT3_SUPPORT
const char *qGLVersion() {
124 return QGL_VERSION_STR;
128 #if defined(Q_WS_WIN) || defined(Q_WS_MAC)
133 #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
134 class QGLOverlayWidget;
136 class QGLWidgetPrivate;
137 class QGLContextPrivate;
171 Q_DECLARE_OPERATORS_FOR_FLAGS(QGL::FormatOptions)
173 class QGLFormatPrivate;
179 QGLFormat(QGL::FormatOptions options,
int plane = 0);
180 QGLFormat(
const QGLFormat &other);
181 QGLFormat &operator=(
const QGLFormat &other);
184 void setDepthBufferSize(
int size);
185 int depthBufferSize()
const;
187 void setAccumBufferSize(
int size);
188 int accumBufferSize()
const;
190 void setRedBufferSize(
int size);
191 int redBufferSize()
const;
193 void setGreenBufferSize(
int size);
194 int greenBufferSize()
const;
196 void setBlueBufferSize(
int size);
197 int blueBufferSize()
const;
199 void setAlphaBufferSize(
int size);
200 int alphaBufferSize()
const;
202 void setStencilBufferSize(
int size);
203 int stencilBufferSize()
const;
205 void setSampleBuffers(
bool enable);
206 bool sampleBuffers()
const;
208 void setSamples(
int numSamples);
211 void setSwapInterval(
int interval);
212 int swapInterval()
const;
214 bool doubleBuffer()
const;
215 void setDoubleBuffer(
bool enable);
217 void setDepth(
bool enable);
219 void setRgba(
bool enable);
221 void setAlpha(
bool enable);
223 void setAccum(
bool enable);
224 bool stencil()
const;
225 void setStencil(
bool enable);
227 void setStereo(
bool enable);
228 bool directRendering()
const;
229 void setDirectRendering(
bool enable);
230 bool hasOverlay()
const;
231 void setOverlay(
bool enable);
234 void setPlane(
int plane);
236 void setOption(QGL::FormatOptions opt);
237 bool testOption(QGL::FormatOptions opt)
const;
239 static QGLFormat defaultFormat();
240 static void setDefaultFormat(
const QGLFormat&
f);
242 static QGLFormat defaultOverlayFormat();
243 static void setDefaultOverlayFormat(
const QGLFormat& f);
245 static bool hasOpenGL();
246 static bool hasOpenGLOverlays();
248 void setVersion(
int major,
int minor);
249 int majorVersion()
const;
250 int minorVersion()
const;
258 void setProfile(OpenGLContextProfile profile);
259 OpenGLContextProfile profile()
const;
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
281 Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)
283 static OpenGLVersionFlags openGLVersionFlags();
285 #if defined(Q_WS_QPA)
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
301 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFormat::OpenGLVersionFlags)
303 Q_OPENGL_EXPORT
bool operator==(const QGLFormat&, const QGLFormat&);
304 Q_OPENGL_EXPORT
bool operator!=(const QGLFormat&, const QGLFormat&);
306 #ifndef QT_NO_DEBUG_STREAM
318 virtual bool create(
const QGLContext* shareContext = 0);
319 bool isValid()
const;
320 bool isSharing()
const;
326 QGLFormat requestedFormat()
const;
327 void setFormat(
const QGLFormat& format);
330 virtual void makeCurrent();
331 virtual void doneCurrent();
333 virtual void swapBuffers()
const;
336 NoBindOption = 0x0000,
337 InvertedYBindOption = 0x0001,
338 MipmapBindOption = 0x0002,
339 PremultipliedAlphaBindOption = 0x0004,
340 LinearFilteringBindOption = 0x0008,
342 MemoryManagedBindOption = 0x0010,
343 CanFlipNativePixmapBindOption = 0x0020,
345 DefaultBindOption = LinearFilteringBindOption
346 | InvertedYBindOption
348 InternalBindOption = MemoryManagedBindOption
349 | PremultipliedAlphaBindOption
351 Q_DECLARE_FLAGS(BindOptions, BindOption)
354 BindOptions options);
356 BindOptions options);
361 GLint format = GL_RGBA);
364 void deleteTexture(
GLuint tx_id);
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);
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,
376 GLuint bindTexture(
const QPixmap &pixmap, QMacCompatGLenum, QMacCompatGLint format,
379 void deleteTexture(QMacCompatGLuint tx_id);
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);
385 static void setTextureCacheLimit(
int size);
386 static int textureCacheLimit();
388 void *getProcAddress(
const QString &proc)
const;
390 QColor overlayTransparentColor()
const;
398 virtual bool chooseContext(
const QGLContext* shareContext = 0);
400 #if defined(Q_WS_WIN)
401 virtual int choosePixelFormat(
void* pfd, HDC pdc);
403 #if defined(Q_WS_X11)
404 virtual void* tryVisual(
const QGLFormat& f,
int bufDepth = 1);
405 virtual void* chooseVisual();
407 #if defined(Q_WS_MAC)
408 virtual void* chooseMacVisual(
GDHandle);
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);
418 uint colorIndex(
const QColor&
c)
const;
419 void setValid(
bool valid);
433 friend class QGLPixelBufferPrivate;
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;
455 void updatePaintDevice();
457 friend class QMacGLWindowChangeEvent;
458 friend QGLContextPrivate *qt_phonon_get_dptr(
const QGLContext *);
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;
472 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLContext::BindOptions)
480 const QGLWidget* shareWidget = 0, Qt::WindowFlags f=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);
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);
495 void qglColor(
const QColor&
c)
const;
496 void qglClearColor(
const QColor& c)
const;
498 bool isValid()
const;
499 bool isSharing()
const;
505 bool doubleBuffer()
const;
509 void setFormat(
const QGLFormat& format);
513 bool deleteOldContext =
true);
515 QPixmap renderPixmap(
int w = 0,
int h = 0,
bool useContext =
false);
516 QImage grabFrameBuffer(
bool withAlpha =
false);
518 void makeOverlayCurrent();
523 void setMouseTracking(
bool enable);
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);
535 QGLContext::BindOptions options);
537 QGLContext::BindOptions options);
546 void deleteTexture(
GLuint tx_id);
551 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
553 QMacCompatGLint format =
GL_RGBA);
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);
561 void deleteTexture(QMacCompatGLuint tx_id);
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);
568 virtual void updateGL();
569 virtual void updateOverlayGL();
573 virtual void initializeGL();
574 virtual void resizeGL(
int w,
int h);
575 virtual void paintGL();
577 virtual void initializeOverlayGL();
578 virtual void resizeOverlayGL(
int w,
int h);
579 virtual void paintOverlayGL();
581 void setAutoBufferSwap(
bool on);
582 bool autoBufferSwap()
const;
587 virtual void glInit();
588 virtual void glDraw();
589 int fontDisplayListBase(
const QFont & fnt,
int listBase = 2000);
592 Q_DISABLE_COPY(QGLWidget)
595 friend class QMacGLWindowChangeEvent;
597 friend class QGLDrawable;
599 friend class QGLPixelBufferPrivate;
601 friend class QGLContextPrivate;
602 friend class QGLOverlayWidget;
603 friend class QOpenGLPaintEngine;
604 friend class QGLPaintDevice;
605 friend class QGLWidgetGLPaintDevice;
QFuture< void > map(Sequence &sequence, MapFunctor map)
GLXFBConfig Pixmap pixmap
GLenum GLsizei GLenum GLenum const GLvoid * image
Q_OPENGL_EXPORT bool operator!=(const QGLFormat &, const QGLFormat &)
#define QT_BEGIN_NAMESPACE
GLenum GLsizei GLenum format
typedef GLenum(APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target)
typedef GLuint(APIENTRYP PFNGLCREATEPROGRAMPROC)()
GLclampf GLclampf GLclampf alpha
static QGLContext * currentCtx
Q_OPENGL_EXPORT void setPreferredPaintEngine(QPaintEngine::Type engineType)
Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &)
GLint GLint GLsizei GLsizei GLsizei depth
int int int int int int h
GLuint const GLchar * name
typedef GLint(APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program
GLubyte GLubyte GLubyte GLubyte w
Q_OPENGL_EXPORT bool operator==(const QGLFormat &, const QGLFormat &)