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> 52 #include <QtGui/QPlatformWindowFormat> 58 # include <QtCore/qt_windows.h> 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) 179 QGLFormat(QGL::FormatOptions options,
int plane = 0);
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;
240 static void setDefaultFormat(
const QGLFormat& f);
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;
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
283 static OpenGLVersionFlags openGLVersionFlags();
285 #if defined(Q_WS_QPA) 296 #ifndef QT_NO_DEBUG_STREAM 306 #ifndef QT_NO_DEBUG_STREAM 319 bool isValid()
const;
320 bool isSharing()
const;
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
354 BindOptions options);
356 BindOptions options);
364 void deleteTexture(GLuint tx_id);
369 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS 371 QMacCompatGLint format =
GL_RGBA);
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);
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);
419 void setValid(
bool valid);
455 void updatePaintDevice();
457 friend class QMacGLWindowChangeEvent;
480 const QGLWidget* shareWidget = 0, Qt::WindowFlags f=0);
482 const QGLWidget* shareWidget = 0, Qt::WindowFlags f=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;
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);
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);
595 friend class QMacGLWindowChangeEvent;
597 friend class QGLDrawable;
The QDebug class provides an output stream for debugging information.
The QColor class provides colors based on RGB, HSV or CMYK values.
The QGL namespace specifies miscellaneous identifiers used in the Qt OpenGL module.
FormatOption
This enum specifies the format options that can be used to configure an OpenGL context.
QScopedPointer< QGLContextPrivate > d_ptr
Q_OPENGL_EXPORT void setPreferredPaintEngine(QPaintEngine::Type engineType)
Sets the preferred OpenGL paint engine that is used to draw onto QGLWidget, QGLPixelBuffer and QGLFra...
#define QT_END_NAMESPACE
This macro expands to.
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
The QGLFramebufferObject class encapsulates an OpenGL framebuffer object.
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
The QPointF class defines a point in the plane using floating point precision.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
The QString class provides a Unicode character string.
Q_OPENGL_EXPORT bool operator!=(const QGLFormat &, const QGLFormat &)
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
The QGLContext class encapsulates an OpenGL rendering context.
BindOption
A set of options to decide how to bind a texture using bindTexture().
The QResizeEvent class contains event parameters for resize events.
The QImage class provides a hardware-independent image representation that allows direct access to th...
The QGLPixelBuffer class encapsulates an OpenGL pbuffer.
handler setDevice(device)
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &src=QRectF())
The QGLColormap class is used for installing custom colormaps into a QGLWidget.
Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &)
The QPlatformGLContext class provides an abstraction for native GL contexts.
The QFont class specifies a font used for drawing text.
The QPixmap class is an off-screen image representation that can be used as a paint device...
#define Q_DECLARE_PRIVATE(Class)
The QPaintEvent class contains event parameters for paint events.
Q_OPENGL_EXPORT bool operator==(const QGLFormat &, const QGLFormat &)
static QGLContext * currentCtx
The QEvent class is the base class of all event classes.
static QString fileName(const QString &fileUrl)