[QtOpenGL module]
该QGLPixelBuffer类封装了一个OpenGL pbuffer的。More…
继承QPaintDevice。
Methods
__init__ (self, QSize size, QGLFormat format = QGLFormat.defaultFormat(), QGLWidget shareWidget = None)
__init__ (self, int width, int height, QGLFormat format = QGLFormat.defaultFormat(), QGLWidget shareWidget = None)
int bindTexture (self, QImage image, int target = GL_TEXTURE_2D)
int bindTexture (self, QPixmap pixmap, int target = GL_TEXTURE_2D)
int bindTexture (self, QString fileName)
bool bindToDynamicTexture (self, int texture)
deleteTexture (self, int texture_id)
int devType (self)
bool doneCurrent (self)
drawTexture (self, QRectF target, int textureId, int textureTarget = GL_TEXTURE_2D)
drawTexture (self, QPointF point, int textureId, int textureTarget = GL_TEXTURE_2D)
QGLFormat format (self)
int generateDynamicTexture (self)
int handle (self)
bool isValid (self)
bool makeCurrent (self)
int metric (self, QPaintDevice.PaintDeviceMetric metric)
QPaintEngine paintEngine (self)
releaseFromDynamicTexture (self)
QSize size (self)
QImage toImage (self)
updateDynamicTexture (self, int texture_id)
Static Methods
bool hasOpenGLPbuffers ()
Detailed Description
该QGLPixelBuffer类封装了一个OpenGL pbuffer的。
渲染到pbuffer的通常情况下用完整的硬件加速。这可以比渲染成显着更快QPixmap。
有三种方法来使用这个类:
- We can draw into the pbuffer and convert it to a QImage using toImage().这通常比调用更快QGLWidget.renderPixmap( ) 。
- We can draw into the pbuffer and copy the contents into an OpenGL texture using updateDynamicTexture().这使我们能够创建与pbuffer的支持所有的系统动态纹理和作品。
- On systems that support it, we can bind the pbuffer to an OpenGL texture.纹理将自动更新时, pbuffer的内容发生变化,不再需要额外的复制操作。这仅支持在Windows和Mac OS X系统,提供了
render_texture
扩展名。需要注意的是在Windows下,一个多采样pbuffer的不能与结合使用render_texture
扩展名。如果一个多重采样pbuffer的在Windows下所要求的render_texture
扩展关闭该pbuffer的。
Threading
由于Qt的4.8的,有可能使用的是渲染成QGLPixelBufferQPainter在一个单独的线程。需要注意的是OpenGL的2.0或OpenGL ES 2.0的是需要这种合作。此外, X11下,有必要设置Qt.AA_X11InitThreads应用属性。
pbuffers的是通过对OpenGL提供pbuffer
扩展;调用hasOpenGLPbuffer ( ) ,以找出是否为系统提供pbuffers的。
Method Documentation
QGLPixelBuffer.__init__ (self, QSize size, QGLFormat format = QGLFormat.defaultFormat(), QGLWidget shareWidget = None)
构造给定一个OpenGL pbuffer的size。如果没有format被指定,则default format被使用。如果shareWidget参数指向一个有效的QGLWidget,该pbuffer的将共享其上下文shareWidget。
如果您打算在这个pbuffer的绑定为一个动态纹理的宽度和高度组件size
必须是两个(例如, 512× 128)的权力。
QGLPixelBuffer.__init__ (self, int width, int height, QGLFormat format = QGLFormat.defaultFormat(), QGLWidget shareWidget = None)
这是一个重载函数。
构造一个OpenGL pbuffer的同width和height。如果没有format被指定,则default format被使用。如果shareWidget参数指向一个有效的QGLWidget,该pbuffer的将共享其上下文shareWidget。
如果您打算在这个pbuffer的绑定为一个动态纹理的宽度和高度组件size
必须是两个(例如, 512× 128)的权力。
int QGLPixelBuffer.bindTexture (self, QImage image, int target = GL_TEXTURE_2D)
生成和二维GL纹理绑定到当前上下文的基础上,image。所生成的纹理ID被返回,并且可以被用于在以后glBindTexture ()调用。
该target参数指定纹理目标。
相当于调用QGLContext.bindTexture( ) 。
See also deleteTexture( ) 。
int QGLPixelBuffer.bindTexture (self, QPixmap pixmap, int target = GL_TEXTURE_2D)
这是一个重载函数。
生成并根据绑定一个2D GL纹理pixmap。
相当于调用QGLContext.bindTexture( ) 。
See also deleteTexture( ) 。
int QGLPixelBuffer.bindTexture (self, QString fileName)
这是一个重载函数。
读取DirectDrawSurface ( DDS )压缩文件fileName并从它生成一个二维GL纹理。
相当于调用QGLContext.bindTexture( ) 。
See also deleteTexture( ) 。
bool QGLPixelBuffer.bindToDynamicTexture (self, int texture)
通过绑定指定的质感texture_id该pbuffer的。成功时返回TRUE ,否则返回False 。
纹理必须是相同的尺寸和格式的pbuffer的的。
要解除绑定纹理,呼叫releaseFromDynamicTexture( ) 。虽然质地是绑定的,它会自动更新时, pbuffer的内容发生变化,不再需要额外的复制操作。
例如:
[QGLPixelBuffer](docs_qglpixelbuffer.html) pbuffer(...);
...
pbuffer.makeCurrent();
GLuint dynamicTexture = pbuffer.generateDynamicTexture();
pbuffer.bindToDynamicTexture(dynamicTexture);
...
pbuffer.releaseFromDynamicTexture();
Warning:该函数使用render_texture
扩展,这是目前没有在X11下的支持。在所有的系统(包括X11)的作品另一种方法是手动使用pbuffer的内容复制到一个纹理updateDynamicTexture( ) 。
Warning:对于bindToDynamicTexture ( )调用成功,在Mac OS X上, pbuffer的需要一个共享的情况下,即QGLPixelBuffer必须以份额小部件来创建。
See also generateDynamicTexture()和releaseFromDynamicTexture( ) 。
QGLPixelBuffer.deleteTexture (self, int texture_id)
去除所确定的纹理texture_id从纹理高速缓存。
相当于调用QGLContext.deleteTexture( ) 。
int QGLPixelBuffer.devType (self)
bool QGLPixelBuffer.doneCurrent (self)
是没有上下文的当前OpenGL上下文。成功时返回TRUE ,否则返回False 。
QGLPixelBuffer.drawTexture (self, QRectF target, int textureId, int textureTarget = GL_TEXTURE_2D)
绘制给定的质感,textureId向给定目标矩形,target在OpenGL的模型空间。该textureTarget应该是一个2D纹理的目标。
等同于相应的QGLContext.drawTexture( ) 。
此功能被引入Qt的4.4 。
QGLPixelBuffer.drawTexture (self, QPointF point, int textureId, int textureTarget = GL_TEXTURE_2D)
绘制给定的质感,textureId,在给定的point在OpenGL的模型空间。该textureTarget参数应该是一个2D纹理的目标。
等同于相应的QGLContext.drawTexture( ) 。
此功能被引入Qt的4.4 。
QGLFormat QGLPixelBuffer.format (self)
[
返回pbuffer的格式。该格式可以是从被请求的不同。
int QGLPixelBuffer.generateDynamicTexture (self)
](docs_qglformat.html)
生成并结合一个2D GL的手感是大小相同的pbuffer的,并返回该纹理的ID。这可与结合使用bindToDynamicTexture()和updateDynamicTexture( ) 。
See also size( ) 。
int QGLPixelBuffer.handle (self)
返回本机pbuffer的句柄。
bool QGLPixelBuffer.hasOpenGLPbuffers ()
返回True如果OpenGL的pbuffer
扩展出现在这个系统上,否则返回False 。
bool QGLPixelBuffer.isValid (self)
返回True如果pbuffer的是有效的,否则返回False 。
bool QGLPixelBuffer.makeCurrent (self)
使得这个pbuffer的当前OpenGL渲染上下文。成功时返回TRUE ,否则返回False 。
See also QGLContext.makeCurrent()和doneCurrent( ) 。
int QGLPixelBuffer.metric (self, QPaintDevice.PaintDeviceMetric metric)
从重新实现QPaintDevice.metric( ) 。
QPaintEngine QGLPixelBuffer.paintEngine (self)
从重新实现QPaintDevice.paintEngine( ) 。
QGLPixelBuffer.releaseFromDynamicTexture (self)
发布任何以前绑定的质感pbuffer的。
See also bindToDynamicTexture( ) 。
QSize QGLPixelBuffer.size (self)
[
返回pbuffer的大小。
](docs_qsize.html)
QImage QGLPixelBuffer.toImage (self)
QGLPixelBuffer.updateDynamicTexture (self, int texture_id)
与指定复制pbuffer的内容到纹理texture_id。
纹理必须是相同的尺寸和格式的pbuffer的的。
例如:
[QGLPixelBuffer](docs_qglpixelbuffer.html) pbuffer(...);
...
pbuffer.makeCurrent();
GLuint dynamicTexture = pbuffer.generateDynamicTexture();
...
pbuffer.updateDynamicTexture(dynamicTexture);
在支持Windows和Mac OS X系统的替代render_texture
分机是用bindToDynamicTexture()来获取纹理的动态更新。
See also generateDynamicTexture()和bindToDynamicTexture( ) 。