QGLBuffer¶
New in version 4.7.
Synopsis¶
Functions¶
def
allocate
(count)def
allocate
(data[, count=-1])def
bind
()def
bufferId
()def
create
()def
destroy
()def
isCreated
()def
map
(access)def
read
(offset, count)def
release
()def
setUsagePattern
(value)def
size
()def
type
()def
unmap
()def
usagePattern
()def
write
(offset, data[, count=-1])
Static functions¶
def
release
(type)
Detailed Description¶
Buffer objects are created in the GL server so that the client application can avoid uploading vertices, indices, texture image data, etc every time they are needed.
QGLBuffer
objects can be copied around as a reference to the underlying GL buffer object:QGLBuffer buffer1(QGLBuffer::IndexBuffer); buffer1.create(); QGLBuffer buffer2 = buffer1;
QGLBuffer
performs a shallow copy when objects are copied in this manner, but does not implement copy-on-write semantics. The original object will be affected whenever the copy is modified.Note
This class has been deprecated in favor of
QOpenGLBuffer
.
- class PySide2.QtOpenGL.QGLBuffer¶
PySide2.QtOpenGL.QGLBuffer(type)
PySide2.QtOpenGL.QGLBuffer(other)
- param type:
- param other:
Constructs a new buffer object of type
VertexBuffer
.Note: this constructor just creates the
QGLBuffer
instance. The actual buffer object in the GL server is not created untilcreate()
is called.See also
Constructs a new buffer object of
type
.Note: this constructor just creates the
QGLBuffer
instance. The actual buffer object in the GL server is not created untilcreate()
is called.See also
- PySide2.QtOpenGL.QGLBuffer.Type¶
This enum defines the type of GL buffer object to create with
QGLBuffer
.Constant
Description
QGLBuffer.VertexBuffer
Vertex buffer object for use when specifying vertex arrays.
QGLBuffer.IndexBuffer
Index buffer object for use with
glDrawElements()
.QGLBuffer.PixelPackBuffer
Pixel pack buffer object for reading pixel data from the GL server (for example, with
glReadPixels()
). Not supported under OpenGL/ES.QGLBuffer.PixelUnpackBuffer
Pixel unpack buffer object for writing pixel data to the GL server (for example, with
glTexImage2D()
). Not supported under OpenGL/ES.
New in version 4.7.
- PySide2.QtOpenGL.QGLBuffer.UsagePattern¶
This enum defines the usage pattern of a
QGLBuffer
object.Constant
Description
QGLBuffer.StreamDraw
The data will be set once and used a few times for drawing operations. Under OpenGL/ES 1.1 this is identical to .
QGLBuffer.StreamRead
The data will be set once and used a few times for reading data back from the GL server. Not supported under OpenGL/ES.
QGLBuffer.StreamCopy
The data will be set once and used a few times for reading data back from the GL server for use in further drawing operations. Not supported under OpenGL/ES.
QGLBuffer.StaticDraw
The data will be set once and used many times for drawing operations.
QGLBuffer.StaticRead
The data will be set once and used many times for reading data back from the GL server. Not supported under OpenGL/ES.
QGLBuffer.StaticCopy
The data will be set once and used many times for reading data back from the GL server for use in further drawing operations. Not supported under OpenGL/ES.
QGLBuffer.DynamicDraw
The data will be modified repeatedly and used many times for drawing operations.
QGLBuffer.DynamicRead
The data will be modified repeatedly and used many times for reading data back from the GL server. Not supported under OpenGL/ES.
QGLBuffer.DynamicCopy
The data will be modified repeatedly and used many times for reading data back from the GL server for use in further drawing operations. Not supported under OpenGL/ES.
New in version 4.7.
- PySide2.QtOpenGL.QGLBuffer.Access¶
This enum defines the access mode for
map()
.Constant
Description
QGLBuffer.ReadOnly
The buffer will be mapped for reading only.
QGLBuffer.WriteOnly
The buffer will be mapped for writing only.
QGLBuffer.ReadWrite
The buffer will be mapped for reading and writing.
New in version 4.7.
- PySide2.QtOpenGL.QGLBuffer.allocate(data[, count=-1])¶
- Parameters:
data –
void
count – int
Allocates
count
bytes of space to the buffer, initialized to the contents ofdata
. Any previous contents will be removed.It is assumed that
create()
has been called on this buffer and that it has been bound to the current context.
- PySide2.QtOpenGL.QGLBuffer.allocate(count)
- Parameters:
count – int
This is an overloaded function.
Allocates
count
bytes of space to the buffer. Any previous contents will be removed.It is assumed that
create()
has been called on this buffer and that it has been bound to the current context.
- PySide2.QtOpenGL.QGLBuffer.bind()¶
- Return type:
bool
Binds the buffer associated with this object to the current GL context. Returns
false
if binding was not possible, usually becausetype()
is not supported on this GL implementation.The buffer must be bound to the same
QGLContext
current whencreate()
was called, or to anotherQGLContext
that is sharing with it. Otherwise, false will be returned from this function.
- PySide2.QtOpenGL.QGLBuffer.bufferId()¶
- Return type:
GLuint
Returns the GL identifier associated with this buffer; zero if the buffer has not been created.
See also
- PySide2.QtOpenGL.QGLBuffer.create()¶
- Return type:
bool
Creates the buffer object in the GL server. Returns
true
if the object was created; false otherwise.This function must be called with a current
QGLContext
. The buffer will be bound to and can only be used in that context (or any other context that is shared with it).This function will return false if the GL implementation does not support buffers, or there is no current
QGLContext
.See also
- PySide2.QtOpenGL.QGLBuffer.destroy()¶
Destroys this buffer object, including the storage being used in the GL server. All references to the buffer will become invalid.
- PySide2.QtOpenGL.QGLBuffer.isCreated()¶
- Return type:
bool
Returns
true
if this buffer has been created; false otherwise.
- PySide2.QtOpenGL.QGLBuffer.map(access)¶
- Parameters:
access –
Access
- Return type:
void
Maps the contents of this buffer into the application’s memory space and returns a pointer to it. Returns null if memory mapping is not possible. The
access
parameter indicates the type of access to be performed.It is assumed that
create()
has been called on this buffer and that it has been bound to the current context.This function is only supported under OpenGL/ES if the
GL_OES_mapbuffer
extension is present.
- PySide2.QtOpenGL.QGLBuffer.read(offset, count)¶
- Parameters:
offset – int
count – int
- Return type:
(retval, data)
Reads the
count
bytes in this buffer starting atoffset
intodata
. Returnstrue
on success; false if reading from the buffer is not supported. Buffer reading is not supported under OpenGL/ES.It is assumed that this buffer has been bound to the current context.
- PySide2.QtOpenGL.QGLBuffer.release()¶
Releases the buffer associated with this object from the current GL context.
This function must be called with the same
QGLContext
current as whenbind()
was called on the buffer.See also
- static PySide2.QtOpenGL.QGLBuffer.release(type)
- Parameters:
type –
Type
Releases the buffer associated with
type
in the currentQGLContext
.This function is a direct call to
glBindBuffer(type, 0)
for use when the caller does not know whichQGLBuffer
has been bound to the context but wants to make sure that it is released.QGLBuffer::release(QGLBuffer::VertexBuffer);
- PySide2.QtOpenGL.QGLBuffer.setUsagePattern(value)¶
- Parameters:
value –
UsagePattern
Sets the usage pattern for this buffer object to
value
. This function must be called beforeallocate()
orwrite()
.See also
- PySide2.QtOpenGL.QGLBuffer.size()¶
- Return type:
int
Returns the size of the data in this buffer, for reading operations. Returns -1 if fetching the buffer size is not supported, or the buffer has not been created.
It is assumed that this buffer has been bound to the current context.
See also
- PySide2.QtOpenGL.QGLBuffer.type()¶
- Return type:
Returns the type of buffer represented by this object.
- PySide2.QtOpenGL.QGLBuffer.unmap()¶
- Return type:
bool
Unmaps the buffer after it was mapped into the application’s memory space with a previous call to
map()
. Returnstrue
if the unmap succeeded; false otherwise.It is assumed that this buffer has been bound to the current context, and that it was previously mapped with
map()
.This function is only supported under OpenGL/ES if the
GL_OES_mapbuffer
extension is present.See also
- PySide2.QtOpenGL.QGLBuffer.usagePattern()¶
- Return type:
Returns the usage pattern for this buffer object. The default value is
StaticDraw
.See also
- PySide2.QtOpenGL.QGLBuffer.write(offset, data[, count=-1])¶
- Parameters:
offset – int
data –
void
count – int
Replaces the
count
bytes of this buffer starting atoffset
with the contents ofdata
. Any other bytes in the buffer will be left unmodified.It is assumed that
create()
has been called on this buffer and that it has been bound to the current context.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.