Detailed Description
The QGLAttributeValue class encapsulates information about an OpenGL attribute value.
OpenGL has many functions that take a pointer to vertex attribute values: glVertexPointer(), glNormalPointer(), glVertexAttribPointer(), etc. These functions typically take four arguments: tuple size (1, 2, 3, or 4), component type (e.g. GL_FLOAT), stride, and data pointer (glNormalPointer() does not use tuple size, assuming that it is 3). When used with vertex buffers, the data pointer may be an offset into the vertex buffer instead.
QGLAttributeValue encapsulates these four values so that they can be easily manipulated as a set during OpenGL painting operations. Constructors are provided for converting QArray and QCustomDataArray objects into an attribute value.
Because the data() value is a raw pointer to arbitrary memory, care should be taken that the memory remains valid until the QGLAttributeValue is no longer required.
Member Function Documentation
QGLAttributeValue::QGLAttributeValue()
Constructs a null attribute value with default parameters of tupleSize(), and stride() set to zero, type() set to GL_FLOAT, and data() set to null.
See also isNull().
QGLAttributeValue::QGLAttributeValue(const QArray<float> & array)
Constructs an attribute value that refers to the contents of array, setting tupleSize() to 1, type() to GL_FLOAT, and stride() to zero.
The array must not be destroyed or modified until the attribute value is no longer required.
QGLAttributeValue::QGLAttributeValue(const QArray<QVector2D> & array)
Constructs an attribute value that refers to the contents of array, setting tupleSize() to 2, type() to GL_FLOAT, and stride() to zero.
The array must not be destroyed or modified until the attribute value is no longer required.
QGLAttributeValue::QGLAttributeValue(const QArray<QVector3D> & array)
Constructs an attribute value that refers to the contents of array, setting tupleSize() to 3, type() to GL_FLOAT, and stride() to zero.
The array must not be destroyed or modified until the attribute value is no longer required.
QGLAttributeValue::QGLAttributeValue(const QArray<QVector4D> & array)
Constructs an attribute value that refers to the contents of array, setting tupleSize() to 4, type() to GL_FLOAT, and stride() to zero.
The array must not be destroyed or modified until the attribute value is no longer required.
QGLAttributeValue::QGLAttributeValue(const QArray<QColor4ub> & array)
Constructs an attribute value that refers to the contents of array, setting tupleSize() to 4, type() to GL_UNSIGNED_BYTE, and stride() to zero.
The array must not be destroyed or modified until the attribute value is no longer required.
QGLAttributeValue::QGLAttributeValue(const QCustomDataArray & array)
Constructs an attribute value that refers to the contents of array. The tupleSize() and type() of the attribute value will be set according to the QCustomDataArray::elementType() of array.
The array must not be destroyed or modified until the attribute value is no longer required.
QGLAttributeValue::QGLAttributeValue(int tupleSize, GLenum type, int stride, const void * data, int count = 0)
Constructs an attribute value with the fields tupleSize, type, stride, data, and count.
QGLAttributeValue::QGLAttributeValue(int tupleSize, GLenum type, int stride, int offset, int count = 0)
Constructs an attribute value with the fields tupleSize, type, stride, offset, and count.
QGLAttributeValue::QGLAttributeValue(const QGLAttributeDescription & description, const void * data, int count = 0)
Constructs an attribute value with the supplied description, data, and count.
QGLAttributeValue::QGLAttributeValue(const QGLAttributeDescription & description, int offset, int count = 0)
Constructs an attribute value with the supplied description, offset, and count.
int QGLAttributeValue::count() const
Returns the count of vertex elements in this attribute value; zero if the count is unknown.
const void * QGLAttributeValue::data() const
Returns the data pointer for the elements in this attribute value.
Returns the description of this value, tagged with attribute.
See also type().
bool QGLAttributeValue::isNull() const
Returns true if tupleSize() is zero, which indicates an unset attribute value; false otherwise.
Note: it is possible for data() to be null, but isNull() returns true. This can happen when data() is actually a zero offset into a vertex buffer.
int QGLAttributeValue::sizeOfType() const
Returns the size in bytes of type().
See also type() and tupleSize().
int QGLAttributeValue::stride() const
Returns the stride in bytes from one vertex element to the next for this attribute value. The default value of 0 indicates that the elements are tightly packed within the data() array.
int QGLAttributeValue::tupleSize() const
Returns the tuple size of this attribute in components. For example, a return value of 3 indicates a vector of 3-dimensional values. If tupleSize() is zero, then this attribute value is null.
See also isNull() and sizeOfType().
GLenum QGLAttributeValue::type() const
Returns the component type for this attribute value. The default value is GL_FLOAT.
See also sizeOfType() and description().