<class name="QGLContext" doc="/** <p>The <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a> class encapsulates an OpenGL rendering context.</p> <p>An OpenGL rendering context is a complete set of OpenGL state variables. The rendering context's format</tt> is set in the constructor, but it can also be set later with <a href="QGLContext.html#setFormat(com.trolltech.qt.opengl.QGLFormat)"><tt>setFormat</tt></a>. The format options that are actually set are returned by <a href="QGLContext.html#format()"><tt>format</tt></a>; the options you asked for are returned by <a href="QGLContext.html#requestedFormat()"><tt>requestedFormat</tt></a>. Note that after a <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a> object has been constructed, the actual OpenGL context must be created by explicitly calling the <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)">create()</a> function. The <a href="QGLContext.html#makeCurrent()"><tt>makeCurrent</tt></a> function makes this context the current rendering context. You can make <i>no</i> context current using <a href="QGLContext.html#doneCurrent()"><tt>doneCurrent</tt></a>. The <a href="QGLContext.html#reset()"><tt>reset</tt></a> function will reset the context and make it invalid.</p> <p>You can examine properties of the context with, e.g&#x2e; <a href="QGLContext.html#isValid()"><tt>isValid</tt></a>, <a href="QGLContext.html#isSharing()"><tt>isSharing</tt></a>, <a href="QGLContext.html#initialized()"><tt>initialized</tt></a>, <a href="QGLContext.html#windowCreated()"><tt>windowCreated</tt></a> and <a href="QGLContext.html#overlayTransparentColor()"><tt>overlayTransparentColor</tt></a>.</p> <p>If you're using double buffering you can swap the screen contents with the off-screen buffer using <a href="QGLContext.html#swapBuffers()"><tt>swapBuffers</tt></a>.</p> <p>Please note that <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a> is not thread safe.</p> */"> <method name="public QGLContext(com.trolltech.qt.opengl.QGLFormat format, com.trolltech.qt.gui.QPaintDeviceInterface device)" doc="/** <p>This method is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.</p> <p>Constructs an OpenGL context for the given paint <tt>device</tt>, which can be a widget or a pixmap. The <tt>format</tt> specifies several display options for the context.</p> <p>If the underlying OpenGL/Window system cannot satisfy all the features requested in <tt>format</tt>, the nearest subset of features will be used. After creation, the <a href="QGLContext.html#format()"><tt>format</tt></a> method will return the actual format obtained.</p> <p>Note that after a <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a> object has been constructed, <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)"><tt>create</tt></a> must be called explicitly to create the actual OpenGL context. The context will be <a href="QGLContext.html#isValid()">invalid</tt></a> if it was not possible to obtain a GL context at all.</p> */"/> <method name="public QGLContext(com.trolltech.qt.opengl.QGLFormat format)" doc="/** <p>Constructs an OpenGL context with the given <tt>format</tt> which specifies several display options for the context.</p> <p>If the underlying OpenGL/Window system cannot satisfy all the features requested in <tt>format</tt>, the nearest subset of features will be used. After creation, the <a href="QGLContext.html#format()"><tt>format</tt></a> method will return the actual format obtained.</p> <p>Note that after a <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a> object has been constructed, <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)"><tt>create</tt></a> must be called explicitly to create the actual OpenGL context. The context will be <a href="QGLContext.html#isValid()">invalid</tt></a> if it was not possible to obtain a GL context at all.</p> @see <a href="QGLContext.html#format()"><tt>format</tt></a> @see <a href="QGLContext.html#isValid()"><tt>isValid</tt></a> */"/> <method name="public final int bindTexture(com.trolltech.qt.gui.QImage image, int target, int format)" doc="/** <p>Generates and binds a 2D GL texture to the current context, based on <tt>image</tt>. The generated texture id is returned and can be used in later <tt>glBindTexture()</tt> calls.</p> <p>The <tt>target</tt> parameter specifies the texture target. The default target is <tt>GL_TEXTURE_2D</tt>.</p> <p>The <tt>format</tt> parameter sets the internal format for the texture. The default format is <tt>GL_RGBA8</tt>.</p> <p>If the GL implementation supports the <tt>GL_SGIS_generate_mipmap</tt> extension, mipmaps will be automatically generated for the texture. Mipmap generation is only supported for the <tt>GL_TEXTURE_2D</tt> target.</p> <p>The texture that is generated is cached, so multiple calls to <a href="QGLContext.html#bindTexture(com.trolltech.qt.gui.QPixmap, int, int)"><tt>bindTexture</tt></a> with the same <a href="%2E%2E/gui/QImage.html"><tt>QImage</tt></a> will return the same texture id.</p> @see <a href="QGLContext.html#deleteTexture(int)"><tt>deleteTexture</tt></a> */"/> <method name="public final int bindTexture(com.trolltech.qt.gui.QImage image, int target)" doc="/** <p>Equivalent to <a href="QGLContext.html#bindTexture(com.trolltech.qt.gui.QPixmap, int, int)"><tt>bindTexture</tt></a>(<tt>image</tt>, <tt>target</tt>, GL_RGBA). */"/> <method name="public final int bindTexture(com.trolltech.qt.gui.QImage image)" doc="/** <p>Equivalent to <a href="QGLContext.html#bindTexture(com.trolltech.qt.gui.QPixmap, int, int)"><tt>bindTexture</tt></a>(<tt>image</tt>, GL_TEXTURE_2D, GL_RGBA). */"/> <method name="public final int bindTexture(java.lang.String fileName)" doc="/** <p>Reads the DirectDrawSurface (DDS) compressed file <tt>fileName</tt> and generates a 2D GL texture from it.</p> <p>Only the DXT1, DXT3 and DXT5 DDS formats are supported.</p> <p>Note that this will only work if the implementation supports the <tt>GL_ARB_texture_compression</tt> and <tt>GL_EXT_texture_compression_s3tc</tt> extensions.</p> @see <a href="QGLContext.html#deleteTexture(int)"><tt>deleteTexture</tt></a> */"/> <method name="public final int bindTexture(com.trolltech.qt.gui.QPixmap pixmap, int target, int format)" doc="/** <p>Generates and binds a 2D GL texture based on <tt>pixmap</tt>.</p> */"/> <method name="public final int bindTexture(com.trolltech.qt.gui.QPixmap pixmap, int target)" doc="/** <p>Equivalent to <a href="QGLContext.html#bindTexture(com.trolltech.qt.gui.QPixmap, int, int)"><tt>bindTexture</tt></a>(<tt>pixmap</tt>, <tt>target</tt>, GL_RGBA). */"/> <method name="public final int bindTexture(com.trolltech.qt.gui.QPixmap pixmap)" doc="/** <p>Equivalent to <a href="QGLContext.html#bindTexture(com.trolltech.qt.gui.QPixmap, int, int)"><tt>bindTexture</tt></a>(<tt>pixmap</tt>, GL_TEXTURE_2D, GL_RGBA). */"/> <method name="protected final int colorIndex(com.trolltech.qt.gui.QColor c)" doc="/** <p>This method is used internally by Qt Jambi. Do not use it in your applications.</p> */"/> <method name="public final void deleteTexture(int tx_id)" doc="/** <p>Removes the texture identified by <tt>tx_id</tt> from the texture cache. If the context is not shared by any other <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a>, glDeleteTextures() will be called to delete the texture from the context.</p> @see <a href="QGLContext.html#bindTexture(com.trolltech.qt.gui.QPixmap, int, int)"><tt>bindTexture</tt></a> */"/> <method name="public final com.trolltech.qt.gui.QPaintDeviceInterface device()" doc="/** <p>Returns the paint device set for this context.</p> @see <tt>QGLContext::QGLContext</tt> */"/> <method name="protected final boolean deviceIsPixmap()" doc="/** <p>Returns true if the paint device of this context is a pixmap; otherwise returns false.</p> */"/> <method name="public final com.trolltech.qt.opengl.QGLFormat format()" doc="/** <p>Returns the frame buffer format that was obtained (this may be a subset of what was requested).</p> @see <a href="QGLContext.html#setFormat(com.trolltech.qt.opengl.QGLFormat)"><tt>setFormat</tt></a> @see <a href="QGLContext.html#requestedFormat()"><tt>requestedFormat</tt></a> */"/> <method name="protected final boolean initialized()" doc="/** <p>Returns true if this context has been initialized, i.e&#x2e; if QGLWidget::initializeGL() has been performed on it; otherwise returns false.</p> @see <a href="QGLContext.html#setInitialized(boolean)"><tt>setInitialized</tt></a> */"/> <method name="public final boolean isSharing()" doc="/** <p>Returns true if this context is sharing its GL context with another <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a>, otherwise false is returned. Note that context sharing might not be supported between contexts with different formats.</p> */"/> <method name="public final boolean isValid()" doc="/** <p>Returns true if a GL rendering context has been successfully created; otherwise returns false.</p> */"/> <method name="public final com.trolltech.qt.gui.QColor overlayTransparentColor()" doc="/** <p>If this context is a valid context in an overlay plane, returns the plane's transparent color. Otherwise returns an invalid</tt> color.</p> <p>The returned color's pixel</tt> value is the index of the transparent color in the colormap of the overlay plane. (Naturally, the color's RGB values are meaningless.)</p> <p>The returned <a href="%2E%2E/gui/QColor.html"><tt>QColor</tt></a> 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 <a href="%2E%2E/gui/QPainter.html"><tt>QPainter</tt></a>. See the examples/opengl/overlay_x11 example for details.</p> */"/> <method name="public final com.trolltech.qt.opengl.QGLFormat requestedFormat()" doc="/** <p>Returns the frame buffer format that was originally requested in the constructor or <a href="QGLContext.html#setFormat(com.trolltech.qt.opengl.QGLFormat)"><tt>setFormat</tt></a>.</p> @see <a href="QGLContext.html#format()"><tt>format</tt></a> */"/> <method name="public final void reset()" doc="/** <p>Resets the context and makes it invalid.</p> @see <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)"><tt>create</tt></a> @see <a href="QGLContext.html#isValid()"><tt>isValid</tt></a> */"/> <method name="public final void setFormat(com.trolltech.qt.opengl.QGLFormat format)" doc="/** <p>Sets a <tt>format</tt> for this context. The context is <a href="QGLContext.html#reset()">reset</tt></a>.</p> <p>Call <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)"><tt>create</tt></a> to create a new GL context that tries to match the new format.</p> <pre> QGLContext *cx; <span class="comment"> // ...</span> QGLFormat f; f.setStereo(true); cx-&gt;setFormat(f); if (!cx-&gt;create()) exit(); <span class="comment">// no OpenGL support, or cannot render on the specified paintdevice</span> if (!cx-&gt;format().stereo()) exit(); <span class="comment">// could not create stereo context</span></pre> @see <a href="QGLContext.html#format()"><tt>format</tt></a> @see <a href="QGLContext.html#reset()"><tt>reset</tt></a> @see <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)"><tt>create</tt></a> */"/> <method name="protected final void setInitialized(boolean on)" doc="/** <p>If <tt>on</tt> is true the context has been initialized, i.e&#x2e; QGLContext::setInitialized() has been called on it. If <tt>on</tt> is false the context has not been initialized.</p> @see <a href="QGLContext.html#initialized()"><tt>initialized</tt></a> */"/> <method name="protected final void setValid(boolean valid)" doc="/** <p>This method is used internally by Qt Jambi. Do not use it in your applications.</p> @see <a href="QGLContext.html#isValid()"><tt>isValid</tt></a> */"/> <method name="protected final void setWindowCreated(boolean on)" doc="/** <p>If <tt>on</tt> is true the context has had a window created for it. If <tt>on</tt> is false no window has been created for the context.</p> @see <a href="QGLContext.html#windowCreated()"><tt>windowCreated</tt></a> */"/> <method name="protected final boolean windowCreated()" doc="/** <p>Returns true if a window has been created for this context; otherwise returns false.</p> @see <a href="QGLContext.html#setWindowCreated(boolean)"><tt>setWindowCreated</tt></a> */"/> <method name="protected boolean chooseContext(com.trolltech.qt.opengl.QGLContext shareContext)" doc="/** <p>This semi-internal function is called by <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)"><tt>create</tt></a>. It creates a system-dependent OpenGL handle that matches the <a href="QGLContext.html#format()"><tt>format</tt></a> of <tt>shareContext</tt> as closely as possible, returning true if successful or false if a suitable handle could not be found.</p> <p>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.</p> */"/> <method name="protected final boolean chooseContext()" doc="/** <p>Equivalent to <a href="QGLContext.html#chooseContext(com.trolltech.qt.opengl.QGLContext)"><tt>chooseContext</tt></a>(0). */"/> <method name="public boolean create(com.trolltech.qt.opengl.QGLContext shareContext)" doc="/** <p>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&#x2e; the context is invalid).</p> <p>After successful creation, <a href="QGLContext.html#format()"><tt>format</tt></a> returns the set of features of the created GL rendering context.</p> <p>If <tt>shareContext</tt> points to a valid <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a>, this method will try to establish OpenGL display list sharing between this context and the <tt>shareContext</tt>. Note that this may fail if the two contexts have different formats. Use <a href="QGLContext.html#isSharing()"><tt>isSharing</tt></a> to see if sharing succeeded.</p> <p><b>Warning:</b> Implementation note: initialization of C++ class members usually takes place in the class constructor. <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a> is an exception because it must be simple to customize. The virtual functions <a href="QGLContext.html#chooseContext(com.trolltech.qt.opengl.QGLContext)"><tt>chooseContext</tt></a> (and chooseVisual() 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="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)"><tt>create</tt></a> function.</p> @see <a href="QGLContext.html#chooseContext(com.trolltech.qt.opengl.QGLContext)"><tt>chooseContext</tt></a> @see <a href="QGLContext.html#format()"><tt>format</tt></a> @see <a href="QGLContext.html#isValid()"><tt>isValid</tt></a> */"/> <method name="public final boolean create()" doc="/** <p>Equivalent to <a href="QGLContext.html#create(com.trolltech.qt.opengl.QGLContext)">create</tt></a>(0). */"/> <method name="public void doneCurrent()" doc="/** <p>Makes no GL context the current context. Normally, you do not need to call this function; <a href="QGLContext.html#QGLContext(com.trolltech.qt.opengl.QGLFormat)"><tt>QGLContext</tt></a> calls it as necessary.</p> */"/> <method name="public void makeCurrent()" doc="/** <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> <p>In some very rare cases the underlying call may fail. If this occurs an error message is output to stderr.</p> */"/> <method name="public void swapBuffers()" doc="/** <p>Swaps the screen contents with an off-screen buffer. Only works if the context is in double buffer mode.</p> @see <tt>QGLFormat::setDoubleBuffer</tt> */"/> <method name="public native static com.trolltech.qt.opengl.QGLContext currentContext()" doc="/** <p>Returns the current context, i.e&#x2e; the context to which any OpenGL commands will currently be directed. Returns 0 if no context is current.</p> @see <a href="QGLContext.html#makeCurrent()"><tt>makeCurrent</tt></a> */"/> <method name="public native static void setTextureCacheLimit(int size)" doc="/** <p>This function sets the limit for the texture cache to <tt>size</tt>, expressed in kilobytes.</p> <p>By default, the cache limit is approximately 64 MB.</p> @see <a href="QGLContext.html#textureCacheLimit()"><tt>textureCacheLimit</tt></a> */"/> <method name="public native static int textureCacheLimit()" doc="/** <p>Returns the current texture cache limit in kilobytes.</p> @see <a href="QGLContext.html#setTextureCacheLimit(int)"><tt>setTextureCacheLimit</tt></a> */"/> <method name="protected native static com.trolltech.qt.opengl.QGLContext currentCtx()"/> <method name="protected static void setCurrentCtx(com.trolltech.qt.opengl.QGLContext currentCtx)"/> </class>