QGLContext Class

The QGLContext class encapsulates an OpenGL rendering context. More...

Header: #include <QGLContext>
qmake: QT += opengl

This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Public Types

enum BindOption { NoBindOption, InvertedYBindOption, MipmapBindOption, PremultipliedAlphaBindOption, LinearFilteringBindOption, DefaultBindOption }

Detailed Description

An OpenGL rendering context is a complete set of OpenGL state variables. The rendering context's format is set in the constructor, but it can also be set later with setFormat(). The format options that are actually set are returned by format(); the options you asked for are returned by requestedFormat(). Note that after a QGLContext object has been constructed, the actual OpenGL context must be created by explicitly calling the create() function. The makeCurrent() function makes this context the current rendering context. You can make no context current using doneCurrent(). The reset() function will reset the context and make it invalid.

You can examine properties of the context with, e.g. isValid(), isSharing(), initialized(), windowCreated() and overlayTransparentColor().

If you're using double buffering you can swap the screen contents with the off-screen buffer using swapBuffers().

Please note that QGLContext is not thread safe.

Member Type Documentation

enum QGLContext::BindOption

A set of options to decide how to bind a texture using bindTexture().

ConstantValueDescription
QGLContext::NoBindOption0x0000Don't do anything, pass the texture straight through.
QGLContext::InvertedYBindOption0x0001Specifies that the texture should be flipped over the X axis so that the texture coordinate 0,0 corresponds to the top left corner. Inverting the texture implies a deep copy prior to upload.
QGLContext::MipmapBindOption0x0002Specifies that bindTexture() should try to generate mipmaps. If the GL implementation supports the GL_SGIS_generate_mipmap extension, mipmaps will be automatically generated for the texture. Mipmap generation is only supported for the GL_TEXTURE_2D target.
QGLContext::PremultipliedAlphaBindOption0x0004Specifies that the image should be uploaded with premultiplied alpha and does a conversion accordingly.
QGLContext::LinearFilteringBindOption0x0008Specifies that the texture filtering should be set to GL_LINEAR. Default is GL_NEAREST. If mipmap is also enabled, filtering will be set to GL_LINEAR_MIPMAP_LINEAR.
QGLContext::DefaultBindOptionLinearFilteringBindOption | InvertedYBindOption | MipmapBindOptionIn Qt 4.5 and earlier, bindTexture() would mirror the image and automatically generate mipmaps. This option helps preserve this default behavior.

This enum was introduced or modified in Qt 4.6.