<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt - 3.3.8 - espenr - 2499/qt - x11 - free - 3.3.8/src/opengl/qgl.cpp:733 -->
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > TQGLContext Class< / title >
< style type = "text/css" > < ! - -
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
-->< / style >
< / head >
< body >
< table border = "0" cellpadding = "0" cellspacing = "0" width = "100%" >
< tr bgcolor = "#E5E5E5" >
< td valign = center >
< a href = "index.html" >
< font color = "#004faf" > Home< / font > < / a >
| < a href = "classes.html" >
< font color = "#004faf" > All Classes< / font > < / a >
| < a href = "mainclasses.html" >
< font color = "#004faf" > Main Classes< / font > < / a >
| < a href = "annotated.html" >
< font color = "#004faf" > Annotated< / font > < / a >
| < a href = "groups.html" >
< font color = "#004faf" > Grouped Classes< / font > < / a >
| < a href = "functions.html" >
< font color = "#004faf" > Functions< / font > < / a >
< / td >
< td align = "right" valign = "center" > < img src = "logo32.png" align = "right" width = "64" height = "32" border = "0" > < / td > < / tr > < / table > < h1 align = center > TQGLContext Class Reference< br > < small > [< a href = "opengl.html" > OpenGL module< / a > ]< / small > < / h1 >
< p > The TQGLContext class encapsulates an OpenGL rendering context.
< a href = "#details" > More...< / a >
< p > < tt > #include < < a href = "qgl-h.html" > ntqgl.h< / a > > < / tt >
< p > Inherits < a href = "ntqgl.html" > TQGL< / a > .
< p > < a href = "qglcontext-members.html" > List of all member functions.< / a >
< h2 > Public Members< / h2 >
< ul >
< li class = fn > < a href = "#TQGLContext" > < b > TQGLContext< / b > < / a > ( const TQGLFormat & format, TQPaintDevice * device )< / li >
< li class = fn > virtual < a href = "#~TQGLContext" > < b > ~TQGLContext< / b > < / a > ()< / li >
< li class = fn > virtual bool < a href = "#create" > < b > create< / b > < / a > ( const TQGLContext * shareContext = 0 )< / li >
< li class = fn > bool < a href = "#isValid" > < b > isValid< / b > < / a > () const< / li >
< li class = fn > bool < a href = "#isSharing" > < b > isSharing< / b > < / a > () const< / li >
< li class = fn > virtual void < a href = "#reset" > < b > reset< / b > < / a > ()< / li >
< li class = fn > TQGLFormat < a href = "#format" > < b > format< / b > < / a > () const< / li >
< li class = fn > TQGLFormat < a href = "#requestedFormat" > < b > requestedFormat< / b > < / a > () const< / li >
< li class = fn > virtual void < a href = "#setFormat" > < b > setFormat< / b > < / a > ( const TQGLFormat & format )< / li >
< li class = fn > virtual void < a href = "#makeCurrent" > < b > makeCurrent< / b > < / a > ()< / li >
< li class = fn > virtual void < a href = "#swapBuffers" > < b > swapBuffers< / b > < / a > () const< / li >
< li class = fn > TQPaintDevice * < a href = "#device" > < b > device< / b > < / a > () const< / li >
< li class = fn > TQColor < a href = "#overlayTransparentColor" > < b > overlayTransparentColor< / b > < / a > () const< / li >
< / ul >
< h2 > Static Public Members< / h2 >
< ul >
< li class = fn > const TQGLContext * < a href = "#currentContext" > < b > currentContext< / b > < / a > ()< / li >
< / ul >
< h2 > Protected Members< / h2 >
< ul >
< li class = fn > virtual bool < a href = "#chooseContext" > < b > chooseContext< / b > < / a > ( const TQGLContext * shareContext = 0 )< / li >
< li class = fn > virtual void < a href = "#doneCurrent" > < b > doneCurrent< / b > < / a > ()< / li >
< li class = fn > virtual int < a href = "#choosePixelFormat" > < b > choosePixelFormat< / b > < / a > ( void * dummyPfd, HDC pdc )< / li >
< li class = fn > virtual void * < a href = "#chooseVisual" > < b > chooseVisual< / b > < / a > ()< / li >
< li class = fn > virtual void * < a href = "#chooseMacVisual" > < b > chooseMacVisual< / b > < / a > ( GDHandle device )< / li >
< li class = fn > bool < a href = "#deviceIsPixmap" > < b > deviceIsPixmap< / b > < / a > () const< / li >
< li class = fn > bool < a href = "#windowCreated" > < b > windowCreated< / b > < / a > () const< / li >
< li class = fn > void < a href = "#setWindowCreated" > < b > setWindowCreated< / b > < / a > ( bool on )< / li >
< li class = fn > bool < a href = "#initialized" > < b > initialized< / b > < / a > () const< / li >
< li class = fn > void < a href = "#setInitialized" > < b > setInitialized< / b > < / a > ( bool on )< / li >
< li class = fn > void < a href = "#generateFontDisplayLists" > < b > generateFontDisplayLists< / b > < / a > ( const TQFont & font, int listBase )< / li >
< / ul >
< hr > < a name = "details" > < / a > < h2 > Detailed Description< / h2 >
The TQGLContext class encapsulates an OpenGL rendering context.
< p >
< p > An OpenGL< sup > *< / sup > rendering context is a complete set of
OpenGL state variables.
< p > The context's < a href = "ntqgl.html#FormatOption-enum" > format< / a > is set in the
constructor or later with < a href = "#setFormat" > setFormat< / a > (). The format options that are
actually set are returned by < a href = "#format" > format< / a > (); the options you asked for
are returned by < a href = "#requestedFormat" > requestedFormat< / a > (). Note that after a TQGLContext
object has been constructed, the actual OpenGL context must be
created by explicitly calling the < a href = "#create" > create()< / a >
function. The < a href = "#makeCurrent" > makeCurrent< / a > () function makes this context the
current rendering context. You can make < em > no< / em > context current
using < a href = "#doneCurrent" > doneCurrent< / a > (). The < a href = "#reset" > reset< / a > () function will reset the context
and make it invalid.
< p > You can examine properties of the context with, e.g. < a href = "#isValid" > isValid< / a > (),
< a href = "#isSharing" > isSharing< / a > (), < a href = "#initialized" > initialized< / a > (), < a href = "#windowCreated" > windowCreated< / a > () and
< a href = "#overlayTransparentColor" > overlayTransparentColor< / a > ().
< p > If you're using double buffering you can swap the screen contents
with the off-screen buffer using < a href = "#swapBuffers" > swapBuffers< / a > ().
< p > Please note that TQGLContext is not thread safe.
< p > < sup > *< / sup > OpenGL is a trademark of Silicon Graphics, Inc. in the
United States and other countries.
< p > < p > See also < a href = "graphics.html" > Graphics Classes< / a > and < a href = "images.html" > Image Processing Classes< / a > .
< hr > < h2 > Member Function Documentation< / h2 >
< h3 class = fn > < a name = "TQGLContext" > < / a > TQGLContext::TQGLContext ( const < a href = "qglformat.html" > TQGLFormat< / a > & format, < a href = "ntqpaintdevice.html" > TQPaintDevice< / a > * device )
< / h3 >
Constructs an OpenGL context for the paint device < em > device< / em > , which
can be a widget or a pixmap. The < em > format< / em > specifies several
display options for the context.
< p > If the underlying OpenGL/Window system cannot satisfy all the
features requested in < em > format< / em > , the nearest subset of features
will be used. After creation, the < a href = "#format" > format< / a > () method will return the
actual format obtained.
< p > Note that after a TQGLContext object has been constructed, < a href = "#create" > create()< / a > must be called explicitly to create
the actual OpenGL context. The context will be < a href = "#isValid" > invalid< / a > if it was not possible to obtain a GL context at
all.
< p > < p > See also < a href = "#format" > format< / a > () and < a href = "#isValid" > isValid< / a > ().
< h3 class = fn > < a name = "~TQGLContext" > < / a > TQGLContext::~TQGLContext ()< tt > [virtual]< / tt >
< / h3 >
Destroys the OpenGL context and frees its resources.
< h3 class = fn > bool < a name = "chooseContext" > < / a > TQGLContext::chooseContext ( const < a href = "qglcontext.html" > TQGLContext< / a > * shareContext = 0 )< tt > [virtual protected]< / tt >
< / h3 >
< p > This semi-internal function is called by < a href = "#create" > create< / a > (). It creates a
system-dependent OpenGL handle that matches the < a href = "#format" > format< / a > () of < em > shareContext< / em > as closely as possible.
< p > On Windows, it calls the virtual function < a href = "#choosePixelFormat" > choosePixelFormat< / a > (),
which finds a matching pixel format identifier. On X11, it calls
the virtual function < a href = "#chooseVisual" > chooseVisual< / a > () which finds an appropriate X
visual. On other platforms it may work differently.
< h3 class = fn > void * < a name = "chooseMacVisual" > < / a > TQGLContext::chooseMacVisual ( GDHandle device )< tt > [virtual protected]< / tt >
< / h3 >
< p > < strong > Mac only< / strong > : This virtual function tries to find a
visual that matches the format using the given < em > device< / em > handle,
reducing the demands if the original request cannot be met.
< p > 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.
< p > < p > See also < a href = "#chooseContext" > chooseContext< / a > ().
< h3 class = fn > int < a name = "choosePixelFormat" > < / a > TQGLContext::choosePixelFormat ( void * dummyPfd, HDC pdc )< tt > [virtual protected]< / tt >
< / h3 >
< strong > Win32 only< / strong > This virtual function chooses a pixel
format that matches the OpenGL < a href = "#setFormat" > format< / a > .
Reimplement this function in a subclass if you need a custom
context.
< p > < b > Warning:< / b > The < em > dummyPfd< / em > pointer and < em > pdc< / em > are used as a < tt > PIXELFORMATDESCRIPTOR*< / tt > . We use < tt > void< / tt > to avoid using
Windows-specific types in our header files.
< p > < p > See also < a href = "#chooseContext" > chooseContext< / a > ().
< h3 class = fn > void * < a name = "chooseVisual" > < / a > TQGLContext::chooseVisual ()< tt > [virtual protected]< / tt >
< / h3 >
< strong > X11 only< / strong > : This virtual function tries to find a
visual that matches the format, reducing the demands if the original
request cannot be met.
< p > 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.
< p > < p > See also < a href = "#chooseContext" > chooseContext< / a > ().
< h3 class = fn > bool < a name = "create" > < / a > TQGLContext::create ( const < a href = "qglcontext.html" > TQGLContext< / a > * shareContext = 0 )< tt > [virtual]< / tt >
< / h3 >
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).
< p > After successful creation, < a href = "#format" > format< / a > () returns the set of features of
the created GL rendering context.
< p > If < em > shareContext< / em > points to a valid TQGLContext, this method will
try to establish OpenGL display list sharing between this context
and the < em > shareContext< / em > . Note that this may fail if the two
contexts have different formats. Use < a href = "#isSharing" > isSharing< / a > () to see if sharing
succeeded.
< p > < b > Warning:< / b > Implementation note: initialization of C++ class
members usually takes place in the class constructor. TQGLContext
is an exception because it must be simple to customize. The
virtual functions < a href = "#chooseContext" > chooseContext< / a > () (and < a href = "#chooseVisual" > chooseVisual< / a > () 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 a < a href = "#create" > create< / a > () function.
< p > < p > See also < a href = "#chooseContext" > chooseContext< / a > (), < a href = "#format" > format< / a > (), and < a href = "#isValid" > isValid< / a > ().
< h3 class = fn > const < a href = "qglcontext.html" > TQGLContext< / a > * < a name = "currentContext" > < / a > TQGLContext::currentContext ()< tt > [static]< / tt >
< / h3 >
< p > Returns the current context, i.e. the context to which any OpenGL
commands will currently be directed. Returns 0 if no context is
current.
< p > < p > See also < a href = "#makeCurrent" > makeCurrent< / a > ().
< h3 class = fn > < a href = "ntqpaintdevice.html" > TQPaintDevice< / a > * < a name = "device" > < / a > TQGLContext::device () const
< / h3 >
< p > Returns the paint device set for this context.
< p > < p > See also < a href = "#TQGLContext" > TQGLContext::TQGLContext< / a > ().
< h3 class = fn > bool < a name = "deviceIsPixmap" > < / a > TQGLContext::deviceIsPixmap () const< tt > [protected]< / tt >
< / h3 >
< p > Returns TRUE if the paint device of this context is a pixmap;
otherwise returns FALSE.
< h3 class = fn > void < a name = "doneCurrent" > < / a > TQGLContext::doneCurrent ()< tt > [virtual protected]< / tt >
< / h3 >
< p > Makes no GL context the current context. Normally, you do not need
to call this function; TQGLContext calls it as necessary.
< h3 class = fn > < a href = "qglformat.html" > TQGLFormat< / a > < a name = "format" > < / a > TQGLContext::format () const
< / h3 >
< p > Returns the frame buffer format that was obtained (this may be a
subset of what was requested).
< p > < p > See also < a href = "#requestedFormat" > requestedFormat< / a > ().
< h3 class = fn > void < a name = "generateFontDisplayLists" > < / a > TQGLContext::generateFontDisplayLists ( const < a href = "ntqfont.html" > TQFont< / a > & font, int listBase )< tt > [protected]< / tt >
< / h3 >
< p > Generates a set of 256 display lists for the 256 first characters
in the font < em > font< / em > . The first list will start at index < em > listBase< / em > .
< p > < p > See also < a href = "qglwidget.html#renderText" > TQGLWidget::renderText< / a > ().
< h3 class = fn > bool < a name = "initialized" > < / a > TQGLContext::initialized () const< tt > [protected]< / tt >
< / h3 >
< p > Returns TRUE if this context has been initialized, i.e. if
< a href = "qglwidget.html#initializeGL" > TQGLWidget::initializeGL< / a > () has been performed on it; otherwise
returns FALSE.
< p > < p > See also < a href = "#setInitialized" > setInitialized< / a > ().
< h3 class = fn > bool < a name = "isSharing" > < / a > TQGLContext::isSharing () const
< / h3 >
< p > Returns TRUE if display list sharing with another context was
requested in the < a href = "#create" > create< / a > () 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.
< h3 class = fn > bool < a name = "isValid" > < / a > TQGLContext::isValid () const
< / h3 >
< p > Returns TRUE if a GL rendering context has been successfully
created; otherwise returns FALSE.
< h3 class = fn > void < a name = "makeCurrent" > < / a > TQGLContext::makeCurrent ()< tt > [virtual]< / tt >
< / h3 >
< p > Makes this context the current OpenGL rendering context. All GL
functions you call operate on this context until another context
is made current.
< p > In some very rare cases the underlying call may fail. If this
occurs an error message is output to stderr.
< h3 class = fn > < a href = "ntqcolor.html" > TQColor< / a > < a name = "overlayTransparentColor" > < / a > TQGLContext::overlayTransparentColor () const
< / h3 >
< p > If this context is a valid context in an overlay plane, returns
the plane's transparent color. Otherwise returns an < a href = "ntqcolor.html#isValid" > invalid< / a > color.
< p > The returned color's < a href = "ntqcolor.html#pixel" > pixel< / a > value is
the index of the transparent color in the colormap of the overlay
plane. (Naturally, the color's RGB values are meaningless.)
< p > The returned < a href = "ntqcolor.html" > TQColor< / a > object will generally work as expected only
when passed as the argument to < a href = "qglwidget.html#qglColor" > TQGLWidget::qglColor< / a > () or
< a href = "qglwidget.html#qglClearColor" > TQGLWidget::qglClearColor< / a > (). Under certain circumstances it can
also be used to draw transparent graphics with a < a href = "ntqpainter.html" > TQPainter< / a > . See the
examples/opengl/overlay_x11 example for details.
< h3 class = fn > < a href = "qglformat.html" > TQGLFormat< / a > < a name = "requestedFormat" > < / a > TQGLContext::requestedFormat () const
< / h3 >
< p > Returns the frame buffer format that was originally requested in
the constructor or < a href = "#setFormat" > setFormat< / a > ().
< p > < p > See also < a href = "#format" > format< / a > ().
< h3 class = fn > void < a name = "reset" > < / a > TQGLContext::reset ()< tt > [virtual]< / tt >
< / h3 >
< p > Resets the context and makes it invalid.
< p > < p > See also < a href = "#create" > create< / a > () and < a href = "#isValid" > isValid< / a > ().
< h3 class = fn > void < a name = "setFormat" > < / a > TQGLContext::setFormat ( const < a href = "qglformat.html" > TQGLFormat< / a > & format )< tt > [virtual]< / tt >
< / h3 >
Sets a < em > format< / em > for this context. The context is < a href = "#reset" > reset< / a > .
< p > Call < a href = "#create" > create< / a > () to create a new GL context that tries to match the
new format.
< p > < pre >
TQGLContext *cx;
// ...
< a href = "qglformat.html" > TQGLFormat< / a > f;
f.< a href = "qglformat.html#setStereo" > setStereo< / a > ( TRUE );
cx-> < a href = "#setFormat" > setFormat< / a > ( f );
if ( !cx-> < a href = "#create" > create< / a > () )
exit(); // no OpenGL support, or cannot render on the specified paintdevice
if ( !cx-> < a href = "#format" > format< / a > ().stereo() )
exit(); // could not create stereo context
< / pre >
< p > < p > See also < a href = "#format" > format< / a > (), < a href = "#reset" > reset< / a > (), and < a href = "#create" > create< / a > ().
< h3 class = fn > void < a name = "setInitialized" > < / a > TQGLContext::setInitialized ( bool on )< tt > [protected]< / tt >
< / h3 >
< p > If < em > on< / em > is TRUE the context has been initialized, i.e.
< a href = "#setInitialized" > TQGLContext::setInitialized< / a > () has been called on it. If < em > on< / em > is
FALSE the context has not been initialized.
< p > < p > See also < a href = "#initialized" > initialized< / a > ().
< h3 class = fn > void < a name = "setWindowCreated" > < / a > TQGLContext::setWindowCreated ( bool on )< tt > [protected]< / tt >
< / h3 >
< p > If < em > on< / em > is TRUE the context has had a window created for it. If
< em > on< / em > is FALSE no window has been created for the context.
< p > < p > See also < a href = "#windowCreated" > windowCreated< / a > ().
< h3 class = fn > void < a name = "swapBuffers" > < / a > TQGLContext::swapBuffers () const< tt > [virtual]< / tt >
< / h3 >
< p > Swaps the screen contents with an off-screen buffer. Only works if
the context is in double buffer mode.
< p > < p > See also < a href = "qglformat.html#setDoubleBuffer" > TQGLFormat::setDoubleBuffer< / a > ().
< h3 class = fn > bool < a name = "windowCreated" > < / a > TQGLContext::windowCreated () const< tt > [protected]< / tt >
< / h3 >
< p > Returns TRUE if a window has been created for this context;
otherwise returns FALSE.
< p > < p > See also < a href = "#setWindowCreated" > setWindowCreated< / a > ().
<!-- eof -->
< hr > < p >
This file is part of the < a href = "index.html" > TQt toolkit< / a > .
Copyright © 1995-2007
< a href = "http://www.trolltech.com/" > Trolltech< / a > . All Rights Reserved.< p > < address > < hr > < div align = center >
< table width = 100% cellspacing = 0 border = 0 > < tr >
< td > Copyright © 2007
< a href = "troll.html" > Trolltech< / a > < td align = center > < a href = "trademarks.html" > Trademarks< / a >
< td align = right > < div align = right > TQt 3.3.8< / div >
< / table > < / div > < / address > < / body >
< / html >