QGLContext(3qt)
β¨ QGLContext β¨
okay bestie, welcome to QGLContext(3qt) β the Qt class that encapsulates an OpenGL rendering context. Yes queen, we're going low-level today π
π NAME π
QGLContext β Encapsulates an OpenGL rendering context
π SYNOPSIS π
#include <qgl.h>
Inherits QGL.
π Public Members π
QGLContext ( const QGLFormat & format, QPaintDevice * device )
virtual ~QGLContext ()
virtual bool create ( const QGLContext * shareContext = 0 )
bool isValid () const
bool isSharing () const
virtual void reset ()
QGLFormat format () const
QGLFormat requestedFormat () const
virtual void setFormat ( const QGLFormat & format )
virtual void makeCurrent ()
virtual void swapBuffers () const
QPaintDevice * device () const
QColor overlayTransparentColor () const
β Static Public Members β
const QGLContext * currentContext ()
π§ Protected Members π§
virtual bool chooseContext ( const QGLContext * shareContext = 0 )
virtual void doneCurrent ()
virtual int choosePixelFormat ( void * dummyPfd, HDC pdc )
virtual void * chooseVisual ()
virtual void * chooseMacVisual ( GDHandle device )
bool deviceIsPixmap () const
bool windowCreated () const
void setWindowCreated ( bool on )
bool initialized () const
void setInitialized ( bool on )
void generateFontDisplayLists ( const QFont & font, int listBase )
πΈ DESCRIPTION πΈ
The QGLContext class encapsulates an OpenGL rendering context.
An OpenGL* rendering context is, like, a complete set of OpenGL state variables. That's it. That's the whole vibe. π
The context's format gets set in the constructor, or later with setFormat(). The format options that are actually set are what format() hands back; the options you asked for are what requestedFormat() hands back. Important distinction, bestie β manifesting isn't the same as receiving. π
Note that once a QGLContext object has been constructed, the actual OpenGL context still has to be created by explicitly calling create(). The makeCurrent() function makes this context the current rendering context. You can make no context current using doneCurrent(). And reset() will reset the context and make it invalid.
You can snoop on the properties of the context with, like, isValid(), isSharing(), initialized(), windowCreated() and overlayTransparentColor().
If you're doing double buffering you can swap the screen contents with the off-screen buffer using swapBuffers().
Please note that QGLContext is not thread safe. It's giving "one bestie at a time," no cap. π
* OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
See also Graphics Classes and Image Processing Classes.
π MEMBER FUNCTION DOCUMENTATION π
QGLContext::QGLContext ( const QGLFormat & format, QPaintDevice * device )
Constructs an OpenGL context for the paint device device, which can be a widget or a pixmap. The format specifies several display options for the context.
If the underlying OpenGL/Window system can't satisfy all the features requested in format, the nearest subset of features gets used instead. After creation, the format() method will return the actual format obtained. (So like, you get what you get, and format() tells you the truth.)
Note that after a QGLContext object has been constructed, create() must be called explicitly to create the actual OpenGL context. The context will be invalid if it was not possible to obtain a GL context at all.
See also format() and isValid().
QGLContext::~QGLContext () [virtual]
Destroys the OpenGL context and frees its resources. bye bestie π«Ά
bool QGLContext::chooseContext ( const QGLContext * shareContext = 0 ) [virtual protected]
This semi-internal function is called by create(). It creates a system-dependent OpenGL handle that matches the format() of shareContext as closely as possible.
On Windows, it calls the virtual function choosePixelFormat(), which finds a matching pixel format identifier. On X11, it calls the virtual function chooseVisual() which finds an appropriate X visual. On other platforms it may work differently.
void * QGLContext::chooseMacVisual ( GDHandle device ) [virtual protected]
Mac only: This virtual function tries to find a visual that matches the format using the given device handle, reducing the demands if the original request cannot be met.
The algorithm for reducing the demands of the format is quite simple-minded, so override this method in your subclass if your application has specific requirements on visual selection.
See also chooseContext().
int QGLContext::choosePixelFormat ( void * dummyPfd, HDC pdc ) [virtual protected]
Win32 only. This virtual function chooses a pixel format that matches the OpenGL format. Reimplement this function in a subclass if you need a custom context.
Warning: The dummyPfd pointer and pdc are used as aPIXELFORMATDESCRIPTOR*. We usevoidto avoid using Windows-specific types in our header files. (iconic avoidance behavior, honestly π )
See also chooseContext().
void * QGLContext::chooseVisual () [virtual protected]
X11 only: This virtual function tries to find a visual that matches the format, reducing the demands if the original request cannot be met.
The algorithm for reducing the demands of the format is quite simple-minded, so override this method in your subclass if your application has spcific requirements on visual selection. (yes that's a typo in the original, we are simply relaying the lore π)
See also chooseContext().
bool QGLContext::create ( const QGLContext * shareContext = 0 ) [virtual]
Creates the GL context. Returns TRUE if it was successful in creating a valid GL rendering context on the paint device specified in the constructor; otherwise returns FALSE (i.e. the context is invalid).
After successful creation, format() returns the set of features of the created GL rendering context.
If shareContext points to a valid QGLContext, this method will try to establish OpenGL display list sharing between this context and the shareContext. Note that this may fail if the two contexts have different formats. Use isSharing() to see if sharing succeeded.
Warning: Implementation note: initialization of C++ class members usually takes place in the class constructor.QGLContextis an exception because it must be simple to customize. The virtual functionschooseContext()(andchooseVisual()for X11) can be reimplemented in a subclass to select a particular context. The problem is that virtual functions are not properly called during construction (even though this is correct C++) because C++ constructs class hierarchies from the bottom up. For this reason we need acreate()function.
See also chooseContext(), format(), and isValid().
const QGLContext * QGLContext::currentContext () [static]
Returns the current context, i.e. the context to which any OpenGL commands will currently be directed. Returns 0 if no context is current.
See also makeCurrent().
QPaintDevice * QGLContext::device () const
Returns the paint device set for this context.
See also QGLContext::QGLContext().
bool QGLContext::deviceIsPixmap () const [protected]
Returns TRUE if the paint device of this context is a pixmap; otherwise returns FALSE.
void QGLContext::doneCurrent () [virtual protected]
Makes no GL context the current context. Normally, you do not need to call this function; QGLContext calls it as necessary.
QGLFormat QGLContext::format () const
Returns the frame buffer format that was obtained (this may be a subset of what was requested).
See also requestedFormat().
void QGLContext::generateFontDisplayLists ( const QFont & font, int listBase ) [protected]
Generates a set of 256 display lists for the 256 first characters in the font font. The first list will start at index listBase.
See also QGLWidget::renderText().
bool QGLContext::initialized () const [protected]
Returns TRUE if this context has been initialized, i.e. if QGLWidget::initializeGL() has been performed on it; otherwise returns FALSE.
See also setInitialized().
bool QGLContext::isSharing () const
Returns TRUE if display list sharing with another context was requested in the create() call and the GL system was able to fulfill this request; otherwise returns FALSE. Note that display list sharing might not be supported between contexts with different formats.
bool QGLContext::isValid () const
Returns TRUE if a GL rendering context has been successfully created; otherwise returns FALSE.
void QGLContext::makeCurrent () [virtual]
Makes this context the current OpenGL rendering context. All GL functions you call operate on this context until another context is made current.
In some very rare cases the underlying call may fail. If this occurs an error message is output to stderr. π
QColor QGLContext::overlayTransparentColor () const
If this context is a valid context in an overlay plane, returns the plane's transparent color. Otherwise returns an invalid color.
The returned color's pixel value is the index of the transparent color in the colormap of the overlay plane. (Naturally, the color's RGB values are meaningless.)
The returned QColor object will generally work as expected only when passed as the argument to QGLWidget::qglColor() or QGLWidget::qglClearColor(). Under certain circumstances it can also be used to draw transparent graphics with a QPainter. See the examples/opengl/overlay_x11 example for details.
QGLFormat QGLContext::requestedFormat () const
Returns the frame buffer format that was originally requested in the constructor or setFormat().
See also format().
void QGLContext::reset () [virtual]
Resets the context and makes it invalid.
See also create() and isValid().
void QGLContext::setFormat ( const QGLFormat & format ) [virtual]
Sets a format for this context. The context is reset.
Call create() to create a new GL context that tries to match the new format.
QGLContext *cx;
// ...
QGLFormat f;
f.setStereo( TRUE );
cx->setFormat( f );
if ( !cx->create() )
exit(); // no OpenGL support, or cannot render on the specified paintdevice
if ( !cx->format().stereo() )
exit(); // could not create stereo context
See also format(), reset(), and create().
void QGLContext::setInitialized ( bool on ) [protected]
If on is TRUE the context has been initialized, i.e. QGLContext::setInitialized() has been called on it. If on is FALSE the context has not been initialized.
See also initialized().
void QGLContext::setWindowCreated ( bool on ) [protected]
If on is TRUE the context has had a window created for it. If on is FALSE no window has been created for the context.
See also windowCreated().
void QGLContext::swapBuffers () const [virtual]
Swaps the screen contents with an off-screen buffer. Only works if the context is in double buffer mode.
See also QGLFormat::setDoubleBuffer().
bool QGLContext::windowCreated () const [protected]
Returns TRUE if a window has been created for this context; otherwise returns FALSE.
See also setWindowCreated().
π¦ SEE ALSO π¦
π COPYRIGHT π
Okay so legal stuff, but make it cute: this whole thing is Copyright 1992-2007 Trolltech ASA, and their website lives at http://www.trolltech.com. If you want the complete license statement, it's in the license file that's included in the distribution β go read that, bestie, it's right there. πβ¨
π«Ά AUTHOR π«Ά
Not a person, not a vibe, not a mysterious hooded figure writing manpages at 3am (well...). It was generated automatically from the source code. The code wrote about itself. Main character energy fr fr. π
π BUGS π
Found a bug in Qt? Iconic of you honestly. Please report it exactly as described at:
http://doc.trolltech.com/bughowto.html
Good bug reports help us help you. Thank you. π₯Ή (That's the actual energy β bug reports are a love language.)
π the definitive docs situation
So the definitive Qt documentation is provided in HTML format, and it lives at $QTDIR/doc/html. You can read it using Qt Assistant or with a plain old web browser. Either one, no judgement. πΈ
This man page? It's provided as a convenience for those users who prefer man pages. Lowkey a whole aesthetic. But heads up: this format is not officially supported by Trolltech. So if it looks a lil janky, that's why. π«
π found an error in this man page?
Not the code β the page. Different thing, bestie. If you spot errors in this manual page, please report them to:
qt-bugs@trolltech.com
And please include these two things, or the report is giving "mystery":
- the name of the manual page (
qglcontext.3qt) - the Qt version (
3.3.8)
That's it, that's the whole ask. π
tl;dr β Qt's real docs = HTML at$QTDIR/doc/html. This man page = a convenience, not officially supported. Bugs in Qt βhttp://doc.trolltech.com/bughowto.html. Errors in this man page βqt-bugs@trolltech.com, with the page name and version. Periodt. π
And that's the whole page, bestie β you made it to the end, which honestly deserves a little crown π. This one came from Trolltech AS, dated 2 February 2007, and the page is QGLContext(3qt), hanging out in the Qt 3.3.8 era. Go forth and make your contexts current. Slay. β¨π¦π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms