1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QGLPixelBuffer Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QGLPixelBuffer Class Reference<br /><sup><sup>[<a href="qtopengl.html">QtOpenGL</a> module]</sup></sup></h1><p>The QGLPixelBuffer class encapsulates an OpenGL pbuffer. <a href="#details">More...</a></p>
<p>Inherits <a href="qpaintdevice.html">QPaintDevice</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qglpixelbuffer.html#QGLPixelBuffer">__init__</a></b> (<i>self</i>, QSize <i>size</i>, QGLFormat <i>format</i> = QGLFormat::defaultFormat(), QGLWidget <i>shareWidget</i> = None)</li><li><div class="fn" />unsigned long <b><a href="qglpixelbuffer.html#bindTexture">bindTexture</a></b> (<i>self</i>, QImage <i>image</i>, unsigned long <i>target</i> = GL_TEXTURE_2D)</li><li><div class="fn" />unsigned long <b><a href="qglpixelbuffer.html#bindTexture-2">bindTexture</a></b> (<i>self</i>, QPixmap <i>pixmap</i>, unsigned long <i>target</i> = GL_TEXTURE_2D)</li><li><div class="fn" />unsigned long <b><a href="qglpixelbuffer.html#bindTexture-3">bindTexture</a></b> (<i>self</i>, QString <i>fileName</i>)</li><li><div class="fn" />bool <b><a href="qglpixelbuffer.html#bindToDynamicTexture">bindToDynamicTexture</a></b> (<i>self</i>, unsigned long <i>texture</i>)</li><li><div class="fn" /><b><a href="qglpixelbuffer.html#deleteTexture">deleteTexture</a></b> (<i>self</i>, unsigned long <i>texture_id</i>)</li><li><div class="fn" />int <b><a href="qglpixelbuffer.html#devType">devType</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qglpixelbuffer.html#doneCurrent">doneCurrent</a></b> (<i>self</i>)</li><li><div class="fn" />QGLFormat <b><a href="qglpixelbuffer.html#format">format</a></b> (<i>self</i>)</li><li><div class="fn" />unsigned long <b><a href="qglpixelbuffer.html#generateDynamicTexture">generateDynamicTexture</a></b> (<i>self</i>)</li><li><div class="fn" />unsigned long <b><a href="qglpixelbuffer.html#handle">handle</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qglpixelbuffer.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qglpixelbuffer.html#makeCurrent">makeCurrent</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qglpixelbuffer.html#metric">metric</a></b> (<i>self</i>, QPaintDevice.PaintDeviceMetric <i>metric</i>)</li><li><div class="fn" />QPaintEngine <b><a href="qglpixelbuffer.html#paintEngine">paintEngine</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglpixelbuffer.html#releaseFromDynamicTexture">releaseFromDynamicTexture</a></b> (<i>self</i>)</li><li><div class="fn" />QSize <b><a href="qglpixelbuffer.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QImage <b><a href="qglpixelbuffer.html#toImage">toImage</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglpixelbuffer.html#updateDynamicTexture">updateDynamicTexture</a></b> (<i>self</i>, unsigned long <i>texture_id</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />bool <b><a href="qglpixelbuffer.html#hasOpenGLPbuffers">hasOpenGLPbuffers</a></b> ()</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGLPixelBuffer class encapsulates an OpenGL pbuffer.</p>
<p>Rendering into a pbuffer is normally done using full hardware acceleration. This can be significantly faster than rendering into a <a href="qpixmap.html">QPixmap</a>.</p>
<p>There are three approaches to using this class:</p>
<ol type="1">
<li><b>We can draw into the pbuffer and convert it to a <a href="qimage.html">QImage</a> using <a href="qglpixelbuffer.html#toImage">toImage</a>().</b> This is normally much faster than calling <a href="qglwidget.html#renderPixmap">QGLWidget.renderPixmap</a>().</li>
<li><b>We can draw into the pbuffer and copy the contents into an OpenGL texture using <a href="qglpixelbuffer.html#updateDynamicTexture">updateDynamicTexture</a>().</b> This allows us to create dynamic textures and works on all systems with pbuffer support.</li>
<li><b>On systems that support it, we can bind the pbuffer to an OpenGL texture.</b> The texture is then updated automatically when the pbuffer contents change, eliminating the need for additional copy operations. This is supported only on Windows and Mac OS X systems that provide the <tt>render_texture</tt> extension.</li>
</ol>
<p>Pbuffers are provided by the OpenGL <tt>pbuffer</tt> extension; call hasOpenGLPbuffer() to find out if the system provides pbuffers.</p>
<p>See also <a href="opengl-pbuffers.html">Pbuffers Example</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGLPixelBuffer" />QGLPixelBuffer.__init__ (<i>self</i>, <a href="qsize.html">QSize</a> <i>size</i>, <a href="qglformat.html">QGLFormat</a> <i>format</i> = QGLFormat::defaultFormat(), <a href="qglwidget.html">QGLWidget</a> <i>shareWidget</i> = None)</h3><p>Constructs an OpenGL pbuffer of the given <i>size</i>. If no <i>format</i> is specified, the <a href="qglformat.html#defaultFormat">default format</a> is used. If the <i>shareWidget</i> parameter points to a valid <a href="qglwidget.html">QGLWidget</a>, the pbuffer will share its context with <i>shareWidget</i>.</p>
<p>If you intend to bind this pbuffer as a dynamic texture, the width and height components of <tt>size</tt> must be powers of two (e.g., 512 x 128). On Mac OS X, the size must be a power of two.</p>
<p>See also <a href="qglpixelbuffer.html#size">size</a>() and <a href="qglpixelbuffer.html#format">format</a>().</p>
<h3 class="fn"><a name="bindTexture" />unsigned long QGLPixelBuffer.bindTexture (<i>self</i>, <a href="qimage.html">QImage</a> <i>image</i>, unsigned long <i>target</i> = GL_TEXTURE_2D)</h3><p>Generates and binds a 2D GL texture to the current context, based on <i>image</i>. The generated texture id is returned and can be used in later glBindTexture() calls.</p>
<p>The <i>target</i> parameter specifies the texture target.</p>
<p>Equivalent to calling <a href="qglcontext.html#bindTexture">QGLContext.bindTexture</a>().</p>
<p>See also <a href="qglpixelbuffer.html#deleteTexture">deleteTexture</a>().</p>
<h3 class="fn"><a name="bindTexture-2" />unsigned long QGLPixelBuffer.bindTexture (<i>self</i>, <a href="qpixmap.html">QPixmap</a> <i>pixmap</i>, unsigned long <i>target</i> = GL_TEXTURE_2D)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Generates and binds a 2D GL texture based on <i>pixmap</i>.</p>
<p>Equivalent to calling <a href="qglcontext.html#bindTexture">QGLContext.bindTexture</a>().</p>
<p>See also <a href="qglpixelbuffer.html#deleteTexture">deleteTexture</a>().</p>
<h3 class="fn"><a name="bindTexture-3" />unsigned long QGLPixelBuffer.bindTexture (<i>self</i>, <a href="qstring.html">QString</a> <i>fileName</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Reads the DirectDrawSurface (DDS) compressed file <i>fileName</i> and generates a 2D GL texture from it.</p>
<p>Equivalent to calling <a href="qglcontext.html#bindTexture">QGLContext.bindTexture</a>().</p>
<p>See also <a href="qglpixelbuffer.html#deleteTexture">deleteTexture</a>().</p>
<h3 class="fn"><a name="bindToDynamicTexture" />bool QGLPixelBuffer.bindToDynamicTexture (<i>self</i>, unsigned long <i>texture</i>)</h3><p>Binds the texture specified by <i>texture_id</i> to this pbuffer. Returns true on success; otherwise returns false.</p>
<p>The texture must be of the same size and format as the pbuffer.</p>
<p>To unbind the texture, call <a href="qglpixelbuffer.html#releaseFromDynamicTexture">releaseFromDynamicTexture</a>(). While the texture is bound, it is updated automatically when the pbuffer contents change, eliminating the need for additional copy operations.</p>
<p>Example:</p>
<pre>
QGLPixelBuffer pbuffer(...);
...
pbuffer.makeCurrent();
GLuint dynamicTexture = pbuffer.generateDynamicTexture();
pbuffer.bindToDynamicTexture(dynamicTexture);
...
pbuffer.releaseFromDynamicTexture();
</pre>
<p><b>Warning:</b> This function uses the <tt>render_texture</tt> extension, which is currently not supported under X11. An alternative that works on all systems (including X11) is to manually copy the pbuffer contents to a texture using <a href="qglpixelbuffer.html#updateDynamicTexture">updateDynamicTexture</a>().</p>
<p><b>Warning:</b> For the bindToDynamicTexture() call to succeed on the Mac OS X, the pbuffer needs a shared context, i.e. the <a href="qglpixelbuffer.html">QGLPixelBuffer</a> must be created with a share widget.</p>
<p>See also <a href="qglpixelbuffer.html#generateDynamicTexture">generateDynamicTexture</a>() and <a href="qglpixelbuffer.html#releaseFromDynamicTexture">releaseFromDynamicTexture</a>().</p>
<h3 class="fn"><a name="deleteTexture" />QGLPixelBuffer.deleteTexture (<i>self</i>, unsigned long <i>texture_id</i>)</h3><p>Removes the texture identified by <i>texture_id</i> from the texture cache.</p>
<p>Equivalent to calling <a href="qglcontext.html#deleteTexture">QGLContext.deleteTexture</a>().</p>
<h3 class="fn"><a name="devType" />int QGLPixelBuffer.devType (<i>self</i>)</h3><h3 class="fn"><a name="doneCurrent" />bool QGLPixelBuffer.doneCurrent (<i>self</i>)</h3><p>Makes no context the current OpenGL context. Returns true on success; otherwise returns false.</p>
<h3 class="fn"><a name="format" /><a href="qglformat.html">QGLFormat</a> QGLPixelBuffer.format (<i>self</i>)</h3><p>Returns the format of the pbuffer. The format may be different from the one that was requested.</p>
<h3 class="fn"><a name="generateDynamicTexture" />unsigned long QGLPixelBuffer.generateDynamicTexture (<i>self</i>)</h3><p>Generates and binds a 2D GL texture that is the same size as the pbuffer, and returns the texture's ID. This can be used in conjunction with <a href="qglpixelbuffer.html#bindToDynamicTexture">bindToDynamicTexture</a>() and <a href="qglpixelbuffer.html#updateDynamicTexture">updateDynamicTexture</a>().</p>
<p>See also <a href="qglpixelbuffer.html#size">size</a>().</p>
<h3 class="fn"><a name="handle" />unsigned long QGLPixelBuffer.handle (<i>self</i>)</h3><p>Returns the native pbuffer handle.</p>
<h3 class="fn"><a name="hasOpenGLPbuffers" />bool QGLPixelBuffer.hasOpenGLPbuffers ()</h3><p>Returns true if the OpenGL <tt>pbuffer</tt> extension is present on this system; otherwise returns false.</p>
<h3 class="fn"><a name="isValid" />bool QGLPixelBuffer.isValid (<i>self</i>)</h3><p>Returns true if this pbuffer is valid; otherwise returns false.</p>
<h3 class="fn"><a name="makeCurrent" />bool QGLPixelBuffer.makeCurrent (<i>self</i>)</h3><p>Makes this pbuffer the current OpenGL rendering context. Returns true on success; otherwise returns false.</p>
<p>See also <a href="qglcontext.html#makeCurrent">QGLContext.makeCurrent</a>() and <a href="qglpixelbuffer.html#doneCurrent">doneCurrent</a>().</p>
<h3 class="fn"><a name="metric" />int QGLPixelBuffer.metric (<i>self</i>, <a href="qpaintdevice.html#PaintDeviceMetric-enum">QPaintDevice.PaintDeviceMetric</a> <i>metric</i>)</h3><h3 class="fn"><a name="paintEngine" /><a href="qpaintengine.html">QPaintEngine</a> QGLPixelBuffer.paintEngine (<i>self</i>)</h3><h3 class="fn"><a name="releaseFromDynamicTexture" />QGLPixelBuffer.releaseFromDynamicTexture (<i>self</i>)</h3><p>Releases the pbuffer from any previously bound texture. Returns true on success; otherwise returns false.</p>
<p>See also <a href="qglpixelbuffer.html#bindToDynamicTexture">bindToDynamicTexture</a>().</p>
<h3 class="fn"><a name="size" /><a href="qsize.html">QSize</a> QGLPixelBuffer.size (<i>self</i>)</h3><p>Returns the size of the pbuffer.</p>
<h3 class="fn"><a name="toImage" /><a href="qimage.html">QImage</a> QGLPixelBuffer.toImage (<i>self</i>)</h3><p>Returns the contents of the pbuffer as a <a href="qimage.html">QImage</a>.</p>
<h3 class="fn"><a name="updateDynamicTexture" />QGLPixelBuffer.updateDynamicTexture (<i>self</i>, unsigned long <i>texture_id</i>)</h3><p>Copies the pbuffer contents into the texture specified with <i>texture_id</i>.</p>
<p>The texture must be of the same size and format as the pbuffer.</p>
<p>Example:</p>
<pre>
QGLPixelBuffer pbuffer(...);
...
pbuffer.makeCurrent();
GLuint dynamicTexture = pbuffer.generateDynamicTexture();
...
pbuffer.updateDynamicTexture(dynamicTexture);
</pre>
<p>An alternative on Windows and Mac OS X systems that support the <tt>render_texture</tt> extension is to use <a href="qglpixelbuffer.html#bindToDynamicTexture">bindToDynamicTexture</a>() to get dynamic updates of the texture.</p>
<p>See also <a href="qglpixelbuffer.html#generateDynamicTexture">generateDynamicTexture</a>() and <a href="qglpixelbuffer.html#bindToDynamicTexture">bindToDynamicTexture</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|