Member Function Documentation
QGLIndexBuffer::QGLIndexBuffer()
Creates a new index buffer.
QGLIndexBuffer::QGLIndexBuffer(const QGLIndexBuffer & other)
Creates a copy of other. Note that this just copies a reference to the index buffer. Any modifications to the copy will also affect the original object.
QGLIndexBuffer::~QGLIndexBuffer()
Destroys this index buffer if this object is the last reference to it.
void QGLIndexBuffer::append(const QGLIndexBuffer & buffer, uint offset)
Appends the contents of buffer to this index buffer and adds offset to all of the entries in buffer.
This function is typically used to combine multiple geometry meshes into a single mesh that can be bound as a single buffer.
The request is ignored if this index buffer or buffer have already been uploaded, or buffer is this index buffer.
See also isUploaded() and setIndexes().
void QGLIndexBuffer::append(const QGLIndexBuffer & buffer, uint offset, QGL::DrawingMode combineMode)
Appends the contents of buffer to this index buffer and adds offset to all of the entries in buffer.
The two buffers will be merged at the join point according to combineMode. For example, if combineMode is QGL::TriangleStrip, then the result will be a single triangle strip. Indexes are dropped from the front of buffer as necessary to correctly merge the buffers.
This function is typically used to combine multiple geometry meshes into a single mesh that can be bound as a single buffer.
The request is ignored if this index buffer or buffer have already been uploaded, or buffer is this index buffer.
See also isUploaded() and setIndexes().
bool QGLIndexBuffer::bind()
Binds this index buffer to the current GL context. Returns false if binding was not possible, usually because upload() has not been called.
The buffer must be bound to the same QOpenGLContext current when upload() was called, or to another QOpenGLContext that is sharing with it. Otherwise, false will be returned from this function.
See also release() and upload().
QOpenGLBuffer QGLIndexBuffer::buffer() const
Returns the QOpenGLBuffer in use by this index buffer object, so that its properties or contents can be modified directly.
See also isUploaded().
GLenum QGLIndexBuffer::elementType() const
Returns the element type for this index buffer, GL_UNSIGNED_SHORT or GL_UNSIGNED_INT.
int QGLIndexBuffer::indexCount() const
Returns the number of indexes in this index buffer.
QArray<uint> QGLIndexBuffer::indexesUInt() const
Returns the indexes in this buffer as an array of uint values.
Returns an empty array if type() is not GL_UNSIGNED_INT or the buffer has already been uploaded.
QArray<ushort> QGLIndexBuffer::indexesUShort() const
Returns the indexes in this buffer as an array of ushort values.
Returns an empty array if type() is not GL_UNSIGNED_SHORT or the buffer has already been uploaded.
bool QGLIndexBuffer::isEmpty() const
Returns true if indexCount() is zero; false otherwise.
bool QGLIndexBuffer::isUploaded() const
Returns true if the index data specified by previous a setIndexes() call has been uploaded into the GL server; false otherwise.
See also upload() and setIndexes().
void QGLIndexBuffer::release()
Releases this index buffer from the current GL context.
This function must be called with the same QOpenGLContext current as when bind() was called on the index buffer.
See also bind().
void QGLIndexBuffer::replaceIndexes(int index, const QArray<ushort> & values)
Replaces the elements of this index buffer, starting at index, with the contents of values. All other elements keep their current values.
If the index buffer has been uploaded to the GL server, then this function must be called with a current GL context that is compatible with the uploaded buffer.
The index buffer must have been originally created with the ushort element type.
See also setIndexes().
void QGLIndexBuffer::replaceIndexes(int index, const QArray<uint> & values)
Replaces the elements of this index buffer, starting at index, with the contents of values. All other elements keep their current values.
If the index buffer has been uploaded to the GL server, then this function must be called with a current GL context that is compatible with the uploaded buffer.
The index buffer must have been originally created with the int element type.
OpenGL/ES systems usually do not support 32-bit index values unless they have a special extension for that purpose. On systems without 32-bit index values, this function will need to convert all values to 16-bit which may incur a performance penalty and lose information.
See also setIndexes().
void QGLIndexBuffer::setIndexes(const QArray<ushort> & values)
Sets the index values in this index buffer, replacing the entire current contents.
If the index buffer has been uploaded to the GL server, then this function must be called with a current GL context that is compatible with the uploaded buffer.
See also replaceIndexes().
void QGLIndexBuffer::setIndexes(const QArray<uint> & values)
Sets the index values in this index buffer, replacing the entire current contents.
If the index buffer has been uploaded to the GL server, then this function must be called with a current GL context that is compatible with the uploaded buffer.
OpenGL/ES systems usually do not support 32-bit index values unless they have a special extension for that purpose. On systems without 32-bit index values, this function will need to convert all values to 16-bit which may incur a performance penalty and lose information.
See also replaceIndexes().
Sets the usage pattern for this index buffer to value. This function must be called before upload() for the value to take effect.
See also usagePattern() and upload().
bool QGLIndexBuffer::upload()
Uploads the index data specified by a previous setIndexes() call into the GL server as an index buffer object.
Returns true if the data could be uploaded; false if index buffer objects are not supported or there is insufficient memory to complete the request. Returns true if the data was already uploaded.
Once the index data has been uploaded, the client-side copies of the data arrays will be released. If the index data could not be uploaded, then it is retained client-side. This way, regardless of whether the data could be uploaded or not, QGLPainter::draw() can be used to support drawing of primitives using this object.
See also isUploaded(), setIndexes(), and QGLPainter::draw().
Returns the usage pattern for this index buffer. The default value is QOpenGLBuffer::StaticDraw.
See also setUsagePattern().
QGLIndexBuffer & QGLIndexBuffer::operator=(const QGLIndexBuffer & other)
Assigns other to this object. Note that this just assigns a reference to the other index buffer. Any modifications to this object will also affect other.