QGLBuffer Class

The QGLBuffer class provides functions for creating and managing GL buffer objects. More...

Header: #include <QGLBuffer>
qmake: QT += opengl
Since: Qt 4.7

This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

This class was introduced in Qt 4.7.

Public Types

enum Access { ReadOnly, WriteOnly, ReadWrite }
enum Type { VertexBuffer, IndexBuffer, PixelPackBuffer, PixelUnpackBuffer }
enum UsagePattern { StreamDraw, StreamRead, StreamCopy, StaticDraw, StaticRead, …, DynamicCopy }

Detailed Description

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 buffer1(QGLBuffer::IndexBuffer);
     buffer1.create();

     QGLBuffer buffer2 = buffer1;

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.

Note: This class has been deprecated in favor of QOpenGLBuffer.

Member Type Documentation

enum QGLBuffer::Access

This enum defines the access mode for QGLBuffer::map().

ConstantValueDescription
QGLBuffer::ReadOnly0x88B8The buffer will be mapped for reading only.
QGLBuffer::WriteOnly0x88B9The buffer will be mapped for writing only.
QGLBuffer::ReadWrite0x88BAThe buffer will be mapped for reading and writing.

enum QGLBuffer::Type

This enum defines the type of GL buffer object to create with QGLBuffer.

ConstantValueDescription
QGLBuffer::VertexBuffer0x8892Vertex buffer object for use when specifying vertex arrays.
QGLBuffer::IndexBuffer0x8893Index buffer object for use with glDrawElements().
QGLBuffer::PixelPackBuffer0x88EBPixel pack buffer object for reading pixel data from the GL server (for example, with glReadPixels()). Not supported under OpenGL/ES.
QGLBuffer::PixelUnpackBuffer0x88ECPixel unpack buffer object for writing pixel data to the GL server (for example, with glTexImage2D()). Not supported under OpenGL/ES.

enum QGLBuffer::UsagePattern

This enum defines the usage pattern of a QGLBuffer object.

ConstantValueDescription
QGLBuffer::StreamDraw0x88E0The data will be set once and used a few times for drawing operations. Under OpenGL/ES 1.1 this is identical to StaticDraw.
QGLBuffer::StreamRead0x88E1The data will be set once and used a few times for reading data back from the GL server. Not supported under OpenGL/ES.
QGLBuffer::StreamCopy0x88E2The 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::StaticDraw0x88E4The data will be set once and used many times for drawing operations.
QGLBuffer::StaticRead0x88E5The data will be set once and used many times for reading data back from the GL server. Not supported under OpenGL/ES.
QGLBuffer::StaticCopy0x88E6The 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::DynamicDraw0x88E8The data will be modified repeatedly and used many times for drawing operations.
QGLBuffer::DynamicRead0x88E9The data will be modified repeatedly and used many times for reading data back from the GL server. Not supported under OpenGL/ES.
QGLBuffer::DynamicCopy0x88EAThe 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.