QGLPixelBufferclass encapsulates an OpenGL pbuffer. 更多 …
def
bindTexture
(fileName)
def
bindTexture
(image[, target=GL_TEXTURE_2D])
def
bindTexture
(pixmap[, target=GL_TEXTURE_2D])
def
bindToDynamicTexture
(texture)
def
context
()
def
deleteTexture
(texture_id)
def
doneCurrent
()
def
drawTexture
(point, textureId[, textureTarget=GL_TEXTURE_2D])
def
drawTexture
(target, textureId[, textureTarget=GL_TEXTURE_2D])
def
format
()
def
generateDynamicTexture
()
def
handle
()
def
isValid
()
def
makeCurrent
()
def
releaseFromDynamicTexture
()
def
size
()
def
toImage
()
def
updateDynamicTexture
(texture_id)
def
hasOpenGLPbuffers
()
Rendering into a pbuffer is normally done using full hardware acceleration. This can be significantly faster than rendering into a
QPixmap.There are three approaches to using this class:
We can draw into the pbuffer and convert it to a
QImage使用toImage(). This is normally much faster than callingrenderPixmap().We can draw into the pbuffer and copy the contents into an OpenGL texture using
updateDynamicTexture(). This allows us to create dynamic textures and works on all systems with pbuffer support.On systems that support it, we can bind the pbuffer to an OpenGL texture. 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 macOS systems that provide the
render_textureextension. Note that under Windows, a multi-sampled pbuffer can’t be used in conjunction with therender_textureextension. If a multi-sampled pbuffer is requested under Windows, therender_textureextension is turned off for that pbuffer.注意
This class has been deprecated, use
QOpenGLFramebufferObjectfor offscreen rendering.
As of Qt 4.8, it’s possible to render into a
QGLPixelBuffer使用QPainterin a separate thread. Note that OpenGL 2.0 or OpenGL ES 2.0 is required for this to work.Pbuffers are provided by the OpenGL
pbufferextension; call hasOpenGLPbuffer() to find out if the system provides pbuffers.
QGLPixelBuffer
(
size
[
,
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
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
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).
PySide2.QtOpenGL.QGLPixelBuffer.
bindTexture
(
pixmap
[
,
target=GL_TEXTURE_2D
]
)
¶
pixmap
–
QPixmap
target
–
GLenum
GLuint
PySide2.QtOpenGL.QGLPixelBuffer.
bindTexture
(
fileName
)
¶
fileName – unicode
GLuint
这是重载函数。
Reads the DirectDrawSurface (DDS) compressed file
fileName
and generates a 2D GL texture from it.
相当于调用
bindTexture()
.
另请参阅
PySide2.QtOpenGL.QGLPixelBuffer.
bindTexture
(
image
[
,
target=GL_TEXTURE_2D
]
)
¶
image
–
QImage
target
–
GLenum
GLuint
PySide2.QtOpenGL.QGLPixelBuffer.
bindToDynamicTexture
(
texture
)
¶
texture
–
GLuint
bool
Binds the texture specified by
texture_id
to this pbuffer. Returns
true
当成功时;否则返回
false
.
The texture must be of the same size and format as the pbuffer.
To unbind the texture, call
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
updateDynamicTexture()
.
警告
For the call to succeed on the macOS, the pbuffer needs a shared context, i.e. the
QGLPixelBuffer
must be created with a share widget.
PySide2.QtOpenGL.QGLPixelBuffer.
context
(
)
¶
Returns the context of this pixelbuffer.
PySide2.QtOpenGL.QGLPixelBuffer.
deleteTexture
(
texture_id
)
¶
texture_id
–
GLuint
Removes the texture identified by
texture_id
from the texture cache.
相当于调用
deleteTexture()
.
PySide2.QtOpenGL.QGLPixelBuffer.
doneCurrent
(
)
¶
bool
Makes no context the current OpenGL context. Returns
true
当成功时;否则返回
false
.
PySide2.QtOpenGL.QGLPixelBuffer.
drawTexture
(
point
,
textureId
[
,
textureTarget=GL_TEXTURE_2D
]
)
¶
point
–
QPointF
textureId
–
GLuint
textureTarget
–
GLenum
PySide2.QtOpenGL.QGLPixelBuffer.
drawTexture
(
target
,
textureId
[
,
textureTarget=GL_TEXTURE_2D
]
)
¶
target
–
QRectF
textureId
–
GLuint
textureTarget
–
GLenum
PySide2.QtOpenGL.QGLPixelBuffer.
format
(
)
¶
Returns the format of the pbuffer. The format may be different from the one that was requested.
PySide2.QtOpenGL.QGLPixelBuffer.
generateDynamicTexture
(
)
¶
GLuint
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
bindToDynamicTexture()
and
updateDynamicTexture()
.
另请参阅
PySide2.QtOpenGL.QGLPixelBuffer.
handle
(
)
¶
Qt::HANDLE
Returns the native pbuffer handle.
PySide2.QtOpenGL.QGLPixelBuffer.
hasOpenGLPbuffers
(
)
¶
bool
返回
true
if the OpenGL
pbuffer
extension is present on this system; otherwise returns
false
.
PySide2.QtOpenGL.QGLPixelBuffer.
isValid
(
)
¶
bool
返回
true
if this pbuffer is valid; otherwise returns
false
.
PySide2.QtOpenGL.QGLPixelBuffer.
makeCurrent
(
)
¶
bool
Makes this pbuffer the current OpenGL rendering context. Returns true on success; otherwise returns
false
.
PySide2.QtOpenGL.QGLPixelBuffer.
releaseFromDynamicTexture
(
)
¶
Releases the pbuffer from any previously bound texture.
PySide2.QtOpenGL.QGLPixelBuffer.
size
(
)
¶
QSize
Returns the size of the pbuffer.
PySide2.QtOpenGL.QGLPixelBuffer.
toImage
(
)
¶
QImage
Returns the contents of the pbuffer as a
QImage
.
PySide2.QtOpenGL.QGLPixelBuffer.
updateDynamicTexture
(
texture_id
)
¶
texture_id
–
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 macOS systems that support the
render_texture
extension is to use
bindToDynamicTexture()
to get dynamic updates of the texture.