• PySide 模块
  • PySide.QtOpenGL
  • 内容表

    上一话题

    QGLColormap

    下一话题

    QGLFramebufferObject

    QGLPixelBuffer

    概要

    函数

    静态函数

    详细描述

    PySide.QtOpenGL.QGLPixelBuffer class encapsulates an OpenGL pbuffer.

    Rendering into a pbuffer is normally done using full hardware acceleration. This can be significantly faster than rendering into a PySide.QtGui.QPixmap .

    There are three approaches to using this class:

    线程

    As of Qt 4.8, it's possible to render into a PySide.QtOpenGL.QGLPixelBuffer 使用 PySide.QtGui.QPainter in a separate thread. Note that OpenGL 2.0 or OpenGL ES 2.0 is required for this to work. Also, under X11, it's necessary to set the Qt.AA_X11InitThreads 应用程序属性。

    Pbuffers are provided by the OpenGL pbuffer extension; call hasOpenGLPbuffer() to find out if the system provides pbuffers.

    另请参阅

    Pbuffers Example

    class PySide.QtOpenGL. QGLPixelBuffer ( size [ , format=QGLFormat.defaultFormat() [ , shareWidget=None ] ] )
    class PySide.QtOpenGL. QGLPixelBuffer ( width , height [ , format=QGLFormat.defaultFormat() [ , shareWidget=None ] ] )
    参数:

    Constructs an OpenGL pbuffer of the given size . If no format is specified, the default format is used. If the shareWidget parameter points to a valid PySide.QtOpenGL.QGLWidget , the pbuffer will share its context with shareWidget .

    If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

    这是重载函数。

    Constructs an OpenGL pbuffer with the width and height . If no format is specified, the default format is used. If the shareWidget parameter points to a valid PySide.QtOpenGL.QGLWidget , the pbuffer will share its context with shareWidget .

    If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

    PySide.QtOpenGL.QGLPixelBuffer. bindTexture ( fileName )
    参数: fileName – unicode
    返回类型: PySide.QtOpenGL.GLuint

    这是重载函数。

    Reads the DirectDrawSurface (DDS) compressed file fileName and generates a 2D GL texture from it.

    相当于调用 QGLContext.bindTexture() .

    PySide.QtOpenGL.QGLPixelBuffer. bindTexture ( pixmap [ , target=0x0DE1 ] )
    参数:
    返回类型:

    PySide.QtOpenGL.GLuint

    这是重载函数。

    Generates and binds a 2D GL texture based on pixmap .

    相当于调用 QGLContext.bindTexture() .

    PySide.QtOpenGL.QGLPixelBuffer. bindTexture ( image [ , target=0x0DE1 ] )
    参数:
    返回类型:

    PySide.QtOpenGL.GLuint

    Generates and binds a 2D GL texture to the current context, based on image . The generated texture id is returned and can be used in later glBindTexture() calls.

    target parameter specifies the texture target.

    相当于调用 QGLContext.bindTexture() .

    PySide.QtOpenGL.QGLPixelBuffer. bindToDynamicTexture ( texture )
    参数: texture PySide.QtOpenGL.GLuint
    返回类型: PySide.QtCore.bool

    Binds the texture specified by texture_id to this pbuffer. Returns true on success; otherwise returns false.

    The texture must be of the same size and format as the pbuffer.

    To unbind the texture, call PySide.QtOpenGL.QGLPixelBuffer.releaseFromDynamicTexture() . While the texture is bound, it is updated automatically when the pbuffer contents change, eliminating the need for additional copy operations.

    范例:

    pbuffer QGLPixelBuffer(...)
    ...
    pbuffer.makeCurrent()
    dynamicTexture = pbuffer.generateDynamicTexture()
    pbuffer.bindToDynamicTexture(dynamicTexture)
    ...
    pbuffer.releaseFromDynamicTexture()
    											

    警告

    This function uses the render_texture 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 PySide.QtOpenGL.QGLPixelBuffer.updateDynamicTexture() .

    警告

    对于 PySide.QtOpenGL.QGLPixelBuffer.bindToDynamicTexture() call to succeed on the Mac OS X, the pbuffer needs a shared context, i.e. the PySide.QtOpenGL.QGLPixelBuffer must be created with a share widget.

    PySide.QtOpenGL.QGLPixelBuffer. deleteTexture ( texture_id )
    参数: texture_id PySide.QtOpenGL.GLuint

    Removes the texture identified by texture_id from the texture cache.

    相当于调用 QGLContext.deleteTexture() .

    PySide.QtOpenGL.QGLPixelBuffer. doneCurrent ( )
    返回类型: PySide.QtCore.bool

    Makes no context the current OpenGL context. Returns true on success; otherwise returns false.

    PySide.QtOpenGL.QGLPixelBuffer. drawTexture ( point , textureId [ , textureTarget=0x0DE1 ] )
    参数:

    Draws the given texture, textureId , at the given point in OpenGL model space. The textureTarget parameter should be a 2D texture target.

    Equivalent to the corresponding QGLContext.drawTexture() .

    PySide.QtOpenGL.QGLPixelBuffer. drawTexture ( target , textureId [ , textureTarget=0x0DE1 ] )
    参数:
    • target PySide.QtCore.QRectF
    • textureId PySide.QtOpenGL.GLuint
    • textureTarget PySide.QtOpenGL.GLenum

    Draws the given texture, textureId , to the given target rectangle, target , in OpenGL model space. The textureTarget should be a 2D texture target.

    Equivalent to the corresponding QGLContext.drawTexture() .

    PySide.QtOpenGL.QGLPixelBuffer. format ( )
    返回类型: PySide.QtOpenGL.QGLFormat

    Returns the format of the pbuffer. The format may be different from the one that was requested.

    PySide.QtOpenGL.QGLPixelBuffer. generateDynamicTexture ( )
    返回类型: PySide.QtOpenGL.GLuint
    PySide.QtOpenGL.QGLPixelBuffer. handle ( )
    返回类型: PySide.QtCore.Qt::HANDLE

    Returns the native pbuffer handle.

    static PySide.QtOpenGL.QGLPixelBuffer. hasOpenGLPbuffers ( )
    返回类型: PySide.QtCore.bool

    Returns true if the OpenGL pbuffer extension is present on this system; otherwise returns false.

    PySide.QtOpenGL.QGLPixelBuffer. isValid ( )
    返回类型: PySide.QtCore.bool

    Returns true if this pbuffer is valid; otherwise returns false.

    PySide.QtOpenGL.QGLPixelBuffer. makeCurrent ( )
    返回类型: PySide.QtCore.bool

    Makes this pbuffer the current OpenGL rendering context. Returns true on success; otherwise returns false.

    PySide.QtOpenGL.QGLPixelBuffer. releaseFromDynamicTexture ( )

    Releases the pbuffer from any previously bound texture.

    PySide.QtOpenGL.QGLPixelBuffer. size ( )
    返回类型: PySide.QtCore.QSize

    Returns the size of the pbuffer.

    PySide.QtOpenGL.QGLPixelBuffer. toImage ( )
    返回类型: PySide.QtGui.QImage

    Returns the contents of the pbuffer as a PySide.QtGui.QImage .

    PySide.QtOpenGL.QGLPixelBuffer. updateDynamicTexture ( texture_id )
    参数: texture_id PySide.QtOpenGL.GLuint

    Copies the pbuffer contents into the texture specified with texture_id .

    The texture must be of the same size and format as the pbuffer.

    范例:

    pbuffer QGLPixelBuffer(...)
    ...
    pbuffer.makeCurrent()
    dynamicTexture = pbuffer.generateDynamicTexture()
    ...
    pbuffer.updateDynamicTexture(dynamicTexture)
    											

    An alternative on Windows and Mac OS X systems that support the render_texture extension is to use PySide.QtOpenGL.QGLPixelBuffer.bindToDynamicTexture() to get dynamic updates of the texture.