CopperSpice API
1.9.1
|
The QGLBuffer class provides functions for creating and managing GL buffer objects. More...
Public Types | |
enum | Access |
enum | Type |
enum | UsagePattern |
Public Methods | |
QGLBuffer () | |
QGLBuffer (const QGLBuffer &other) | |
QGLBuffer (QGLBuffer::Type type) | |
~QGLBuffer () | |
void | allocate (const void *data, int count) |
void | allocate (int count) |
bool | bind () |
GLuint | bufferId () const |
bool | create () |
void | destroy () |
bool | isCreated () const |
void * | map (QGLBuffer::Access access) |
QGLBuffer & | operator= (const QGLBuffer &other) |
bool | read (int offset, void *data, int count) |
void | release () |
void | setUsagePattern (QGLBuffer::UsagePattern value) |
int | size () const |
QGLBuffer::Type | type () const |
bool | unmap () |
QGLBuffer::UsagePattern | usagePattern () const |
void | write (int offset, const void *data, int count) |
Static Public Methods | |
static void | release (QGLBuffer::Type type) |
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.
enum QGLBuffer::Access |
This enum defines the access mode for QGLBuffer::map().
Constant | Value | Description |
---|---|---|
QGLBuffer::ReadOnly | 0x88B8 | The buffer will be mapped for reading only. |
QGLBuffer::WriteOnly | 0x88B9 | The buffer will be mapped for writing only. |
QGLBuffer::ReadWrite | 0x88BA | The buffer will be mapped for reading and writing. |
enum QGLBuffer::Type |
This enum defines the type of GL buffer object to create with QGLBuffer.
Constant | Value | Description |
---|---|---|
QGLBuffer::VertexBuffer | 0x8892 | Vertex buffer object for use when specifying vertex arrays. |
QGLBuffer::IndexBuffer | 0x8893 | Index buffer object for use with glDrawElements() . |
QGLBuffer::PixelPackBuffer | 0x88EB | Pixel pack buffer object for reading pixel data from the GL server (for example, with glReadPixels() ). Not supported under OpenGL/ES. |
QGLBuffer::PixelUnpackBuffer | 0x88EC | Pixel unpack buffer object for writing pixel data to the GL server (for example, with glTexImage2D() ). Not supported under OpenGL/ES. |
This enum defines the usage pattern of a QGLBuffer object.
Constant | Value | Description |
---|---|---|
QGLBuffer::StreamDraw | 0x88E0 | The data will be set once and used a few times for drawing operations. Under OpenGL/ES 1.1 this is identical to StaticDraw. |
QGLBuffer::StreamRead | 0x88E1 | 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 | 0x88E2 | 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 | 0x88E4 | The data will be set once and used many times for drawing operations. |
QGLBuffer::StaticRead | 0x88E5 | 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 | 0x88E6 | 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 | 0x88E8 | The data will be modified repeatedly and used many times for drawing operations. |
QGLBuffer::DynamicRead | 0x88E9 | 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 | 0x88EA | 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. |
QGLBuffer::QGLBuffer | ( | ) |
|
explicit |
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.
QGLBuffer::~QGLBuffer | ( | ) |
Destroys this buffer object, including the storage being used in the GL server.
void QGLBuffer::allocate | ( | const void * | data, |
int | count | ||
) |
|
inline |
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.
GLuint QGLBuffer::bufferId | ( | ) | const |
Returns the GL identifier associated with this buffer; zero if the buffer has not been created.
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.
void QGLBuffer::destroy | ( | ) |
Destroys this buffer object, including the storage being used in the GL server. All references to the buffer will become invalid.
bool QGLBuffer::isCreated | ( | ) | const |
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.
QGLBuffer & QGLBuffer::operator= | ( | const QGLBuffer & | other | ) |
Assigns a shallow copy of other to this object.
bool QGLBuffer::read | ( | int | offset, |
void * | data, | ||
int | count | ||
) |
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.
|
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.
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().
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.
QGLBuffer::Type QGLBuffer::type | ( | ) | const |
Returns the type of buffer represented by this object.
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.
QGLBuffer::UsagePattern QGLBuffer::usagePattern | ( | ) | const |
Returns the usage pattern for this buffer object. The default value is StaticDraw.
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.