Qt 4.8
|
The QGLBuffer class provides functions for creating and managing GL buffer objects. More...
#include <qglbuffer.h>
Public Types | |
enum | Access { ReadOnly = 0x88B8, WriteOnly = 0x88B9, ReadWrite = 0x88BA } |
This enum defines the access mode for QGLBuffer::map(). More... | |
enum | Type { VertexBuffer = 0x8892, IndexBuffer = 0x8893, PixelPackBuffer = 0x88EB, PixelUnpackBuffer = 0x88EC } |
This enum defines the type of GL buffer object to create with QGLBuffer. More... | |
enum | UsagePattern { StreamDraw = 0x88E0, StreamRead = 0x88E1, StreamCopy = 0x88E2, StaticDraw = 0x88E4, StaticRead = 0x88E5, StaticCopy = 0x88E6, DynamicDraw = 0x88E8, DynamicRead = 0x88E9, DynamicCopy = 0x88EA } |
This enum defines the usage pattern of a QGLBuffer object. More... | |
Public Functions | |
void | allocate (const void *data, int count) |
Allocates count bytes of space to the buffer, initialized to the contents of data. More... | |
void | allocate (int count) |
Allocates count bytes of space to the buffer. More... | |
bool | bind () |
Binds the buffer associated with this object to the current GL context. More... | |
GLuint | bufferId () const |
Returns the GL identifier associated with this buffer; zero if the buffer has not been created. More... | |
bool | create () |
Creates the buffer object in the GL server. More... | |
void | destroy () |
Destroys this buffer object, including the storage being used in the GL server. More... | |
bool | isCreated () const |
Returns true if this buffer has been created; false otherwise. More... | |
void * | map (QGLBuffer::Access access) |
Maps the contents of this buffer into the application's memory space and returns a pointer to it. More... | |
QGLBuffer & | operator= (const QGLBuffer &other) |
Assigns a shallow copy of other to this object. More... | |
QGLBuffer () | |
Constructs a new buffer object of type QGLBuffer::VertexBuffer. More... | |
QGLBuffer (QGLBuffer::Type type) | |
Constructs a new buffer object of type. More... | |
QGLBuffer (const QGLBuffer &other) | |
Constructs a shallow copy of other. More... | |
bool | read (int offset, void *data, int count) |
Reads the count bytes in this buffer starting at offset into data. More... | |
void | release () |
Releases the buffer associated with this object from the current GL context. More... | |
void | setUsagePattern (QGLBuffer::UsagePattern value) |
Sets the usage pattern for this buffer object to value. More... | |
int | size () const |
Returns the size of the data in this buffer, for reading operations. More... | |
QGLBuffer::Type | type () const |
Returns the type of buffer represented by this object. More... | |
bool | unmap () |
Unmaps the buffer after it was mapped into the application's memory space with a previous call to map(). More... | |
QGLBuffer::UsagePattern | usagePattern () const |
Returns the usage pattern for this buffer object. More... | |
void | write (int offset, const void *data, int count) |
Replaces the count bytes of this buffer starting at offset with the contents of data. More... | |
~QGLBuffer () | |
Destroys this buffer object, including the storage being used in the GL server. More... | |
Static Public Functions | |
static void | release (QGLBuffer::Type type) |
Releases the buffer associated with type in the current QGLContext. More... | |
Properties | |
QGLBufferPrivate * | d_ptr |
The QGLBuffer class provides functions for creating and managing GL buffer objects.
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 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.
Definition at line 56 of file qglbuffer.h.
enum QGLBuffer::Access |
This enum defines the access mode for QGLBuffer::map().
Enumerator | |
---|---|
ReadOnly | |
WriteOnly | |
ReadWrite |
Definition at line 87 of file qglbuffer.h.
enum QGLBuffer::Type |
This enum defines the type of GL buffer object to create with QGLBuffer.
glDrawElements()
. glReadPixels()
). Not supported under OpenGL/ES. glTexImage2D()
). Not supported under OpenGL/ES. Enumerator | |
---|---|
VertexBuffer | |
IndexBuffer | |
PixelPackBuffer | |
PixelUnpackBuffer |
Definition at line 59 of file qglbuffer.h.
This enum defines the usage pattern of a QGLBuffer object.
Enumerator | |
---|---|
StreamDraw | |
StreamRead | |
StreamCopy | |
StaticDraw | |
StaticRead | |
StaticCopy | |
DynamicDraw | |
DynamicRead | |
DynamicCopy |
Definition at line 74 of file qglbuffer.h.
QGLBuffer::QGLBuffer | ( | ) |
Constructs a new buffer object of type QGLBuffer::VertexBuffer.
Note: this constructor just creates the QGLBuffer instance. The actual buffer object in the GL server is not created until create() is called.
Definition at line 169 of file qglbuffer.cpp.
|
explicit |
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 until create() is called.
Definition at line 182 of file qglbuffer.cpp.
QGLBuffer::QGLBuffer | ( | const QGLBuffer & | other | ) |
Constructs a shallow copy of other.
Note: QGLBuffer does not implement copy-on-write semantics, so other will be affected whenever the copy is modified.
Definition at line 193 of file qglbuffer.cpp.
QGLBuffer::~QGLBuffer | ( | ) |
Destroys this buffer object, including the storage being used in the GL server.
Definition at line 205 of file qglbuffer.cpp.
void QGLBuffer::allocate | ( | const void * | data, |
int | count | ||
) |
Allocates count bytes of space to the buffer, initialized to the contents of data.
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.
Definition at line 398 of file qglbuffer.cpp.
|
inline |
Allocates count bytes of space to the buffer.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
Definition at line 117 of file qglbuffer.h.
Referenced by allocate().
bool QGLBuffer::bind | ( | ) |
Binds the buffer associated with this object to the current GL context.
Returns false if binding was not possible, usually because type() is not supported on this GL implementation.
The buffer must be bound to the same QGLContext current when create() was called, or to another QGLContext that is sharing with it. Otherwise, false will be returned from this function.
Definition at line 436 of file qglbuffer.cpp.
GLuint QGLBuffer::bufferId | ( | ) | const |
Returns the GL identifier associated with this buffer; zero if the buffer has not been created.
Definition at line 509 of file qglbuffer.cpp.
Referenced by bind(), create(), and destroy().
bool QGLBuffer::create | ( | ) |
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.
Definition at line 290 of file qglbuffer.cpp.
void QGLBuffer::destroy | ( | ) |
Destroys this buffer object, including the storage being used in the GL server.
All references to the buffer will become invalid.
Definition at line 328 of file qglbuffer.cpp.
Referenced by operator=(), and ~QGLBuffer().
bool QGLBuffer::isCreated | ( | ) | const |
Returns true if this buffer has been created; false otherwise.
Definition at line 317 of file qglbuffer.cpp.
Referenced by allocate(), bind(), map(), release(), unmap(), and write().
void * QGLBuffer::map | ( | QGLBuffer::Access | access | ) |
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.
Definition at line 552 of file qglbuffer.cpp.
Assigns a shallow copy of other to this object.
Note: QGLBuffer does not implement copy-on-write semantics, so other will be affected whenever the copy is modified.
Definition at line 219 of file qglbuffer.cpp.
bool QGLBuffer::read | ( | int | offset, |
void * | data, | ||
int | count | ||
) |
Reads the count bytes in this buffer starting at offset into data.
Returns true 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.
Definition at line 351 of file qglbuffer.cpp.
void 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 when bind() was called on the buffer.
Definition at line 468 of file qglbuffer.cpp.
|
static |
Releases the buffer associated with type in the current QGLContext.
This function is a direct call to glBindBuffer(type, 0)
for use when the caller does not know which QGLBuffer has been bound to the context but wants to make sure that it is released.
Definition at line 494 of file qglbuffer.cpp.
void QGLBuffer::setUsagePattern | ( | QGLBuffer::UsagePattern | value | ) |
Sets the usage pattern for this buffer object to value.
This function must be called before allocate() or write().
Definition at line 259 of file qglbuffer.cpp.
int QGLBuffer::size | ( | ) | const |
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.
Definition at line 528 of file qglbuffer.cpp.
QGLBuffer::Type QGLBuffer::type | ( | ) | const |
Returns the type of buffer represented by this object.
Definition at line 235 of file qglbuffer.cpp.
bool QGLBuffer::unmap | ( | ) |
Unmaps the buffer after it was mapped into the application's memory space with a previous call to map().
Returns true 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.
Definition at line 583 of file qglbuffer.cpp.
QGLBuffer::UsagePattern QGLBuffer::usagePattern | ( | ) | const |
Returns the usage pattern for this buffer object.
The default value is StaticDraw.
Definition at line 247 of file qglbuffer.cpp.
void QGLBuffer::write | ( | int | offset, |
const void * | data, | ||
int | count | ||
) |
Replaces the count bytes of this buffer starting at offset with the contents of data.
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.
Definition at line 378 of file qglbuffer.cpp.
|
private |
Definition at line 123 of file qglbuffer.h.
Referenced by operator=(), QGLBuffer(), and ~QGLBuffer().