Qt3D Reference Documentation

QGLVertexBundle Class Reference

The QGLVertexBundle class bundles vertex attribute arrays for efficient uploading into a GL server. More...

 #include <QGLVertexBundle>

This class was introduced in Qt3D 4.8.

Public Functions

QGLVertexBundle ()
QGLVertexBundle ( const QGLVertexBundle & other )
~QGLVertexBundle ()
void addAttribute ( QGL::VertexAttribute attribute, const QArray<float> & value )
void addAttribute ( QGL::VertexAttribute attribute, const QArray<QVector2D> & value )
void addAttribute ( QGL::VertexAttribute attribute, const QArray<QVector3D> & value )
void addAttribute ( QGL::VertexAttribute attribute, const QArray<QVector4D> & value )
void addAttribute ( QGL::VertexAttribute attribute, const QArray<QColor4ub> & value )
void addAttribute ( QGL::VertexAttribute attribute, const QCustomDataArray & value )
QGLAttributeValue attributeValue ( QGL::VertexAttribute attribute ) const
QGLAttributeSet attributes () const
bool bind ()
QGLBuffer buffer () const
bool isEmpty () const
bool isUploaded () const
void release ()
bool upload ()
int vertexCount () const
QGLVertexBundle & operator= ( const QGLVertexBundle & other )

Detailed Description

The QGLVertexBundle class bundles vertex attribute arrays for efficient uploading into a GL server.

QGLVertexBundle provides an implementation of a static vertex buffer, where the vertex attributes are supplied once at construction time and then never modified until the bundle is destroyed. When the vertex attributes are sent ot the GL server by upload(), they may be repacked for greater drawing efficiency.

For general-purpose vertex buffers that can be allocated and modified in-place, use QGLBuffer instead.

Member Function Documentation

QGLVertexBundle::QGLVertexBundle ()

Constructs a new vertex bundle.

QGLVertexBundle::QGLVertexBundle ( const QGLVertexBundle & other )

Creates a copy of other. Note that this just copies a reference to the vertex bundle. Any modifications to the copy will also affect the original object.

QGLVertexBundle::~QGLVertexBundle ()

Destroys this vertex bundle if this object is the last reference to it.

void QGLVertexBundle::addAttribute ( QGL::VertexAttribute attribute, const QArray<float> & value )

Adds the floating-point array value to this vertex bundle as the data for attribute.

See also upload().

void QGLVertexBundle::addAttribute ( QGL::VertexAttribute attribute, const QArray<QVector2D> & value )

Adds the 2D vector array value to this vertex bundle as the data for attribute.

See also upload().

void QGLVertexBundle::addAttribute ( QGL::VertexAttribute attribute, const QArray<QVector3D> & value )

Adds the 3D vector array value to this vertex bundle as the data for attribute.

See also upload().

void QGLVertexBundle::addAttribute ( QGL::VertexAttribute attribute, const QArray<QVector4D> & value )

Adds the 4D vector array value to this vertex bundle as the data for attribute.

See also upload().

void QGLVertexBundle::addAttribute ( QGL::VertexAttribute attribute, const QArray<QColor4ub> & value )

Adds the color array value to this vertex bundle as the data for attribute.

See also upload().

void QGLVertexBundle::addAttribute ( QGL::VertexAttribute attribute, const QCustomDataArray & value )

Adds the custom data array value to this vertex bundle as the data for attribute.

See also upload().

QGLAttributeValue QGLVertexBundle::attributeValue ( QGL::VertexAttribute attribute ) const

Returns the raw attribute value associated with attribute in this vertex bundle; null if attribute does not exist in the vertex bundle.

If isUploaded() is true, then the returned value will contain a buffer offset to the attribute. If isUploaded() is false, then the returned value will contain a client-side data pointer to the attribute.

See also addAttribute().

QGLAttributeSet QGLVertexBundle::attributes () const

Returns the set of attributes that are present in this vertex bundle.

bool QGLVertexBundle::bind ()

Binds the vertex buffer associated with this bundle 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 QGLContext current when upload() was called, or to another QGLContext that is sharing with it. Otherwise, false will be returned from this function.

See also release() and upload().

QGLBuffer QGLVertexBundle::buffer () const

Returns the QGLBuffer in use by this vertex bundle object, so that its properties or contents can be modified directly.

See also isUploaded().

bool QGLVertexBundle::isEmpty () const

Returns true if vertexCount() is zero; false otherwise.

bool QGLVertexBundle::isUploaded () const

Returns true if the vertex data specified by previous addAttribute() calls has been uploaded into the GL server; false otherwise.

See also upload() and addAttribute().

void QGLVertexBundle::release ()

Releases the vertex buffer associated with this bundle from the current GL context.

This function must be called with the same QGLContext current as when bind() was called on the vertex buffer.

See also bind().

bool QGLVertexBundle::upload ()

Uploads the vertex data specified by previous addAttribute() calls into the GL server as a vertex buffer object.

Returns true if the data could be uploaded; false if vertex buffer objects are not supported or there is insufficient memory to complete the request. Returns true if the data was already uploaded.

Once the vertex data has been uploaded, the client-side copies of the data arrays will be released. If the vertex data could not be uploaded, then it is retained client-side. This way, regardless of whether the data could be uploaded or not, QGLPainter::setVertexBundle() can be used to support drawing of primitives using this object.

See also isUploaded(), addAttribute(), and QGLPainter::setVertexBundle().

int QGLVertexBundle::vertexCount () const

Returns the number of vertices that were defined by previous called to addAttribute().

See also addAttribute().

QGLVertexBundle & QGLVertexBundle::operator= ( const QGLVertexBundle & other )

Assigns other to this object. Note that this just assigns a reference to the other vertex bundle. Any modifications to this object will also affect other.