Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QOpenGLBuffer Class

The QOpenGLBuffer class provides functions for creating and managing OpenGL buffer objects. More...

 #include <QOpenGLBuffer>

This class was introduced in Qt 5.0.

Public Types

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

Public Functions

QOpenGLBuffer()
QOpenGLBuffer(QOpenGLBuffer::Type type)
QOpenGLBuffer(const QOpenGLBuffer & other)
~QOpenGLBuffer()
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(QOpenGLBuffer::Access access)
bool read(int offset, void * data, int count)
void release()
void setUsagePattern(QOpenGLBuffer::UsagePattern value)
int size() const
QOpenGLBuffer::Type type() const
bool unmap()
QOpenGLBuffer::UsagePattern usagePattern() const
void write(int offset, const void * data, int count)
QOpenGLBuffer & operator=(const QOpenGLBuffer & other)

Static Public Members

void release(QOpenGLBuffer::Type type)

Detailed Description

The QOpenGLBuffer class provides functions for creating and managing OpenGL buffer objects.

Buffer objects are created in the OpenGL server so that the client application can avoid uploading vertices, indices, texture image data, etc every time they are needed.

QOpenGLBuffer objects can be copied around as a reference to the underlying OpenGL buffer object:

 QOpenGLBuffer buffer1(QOpenGLBuffer::IndexBuffer);
 buffer1.create();

 QOpenGLBuffer buffer2 = buffer1;

QOpenGLBuffer 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.

Member Type Documentation

enum QOpenGLBuffer::Access

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

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

enum QOpenGLBuffer::Type

This enum defines the type of OpenGL buffer object to create with QOpenGLBuffer.

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

enum QOpenGLBuffer::UsagePattern

This enum defines the usage pattern of a QOpenGLBuffer object.

ConstantValueDescription
QOpenGLBuffer::StreamDraw0x88E0The data will be set once and used a few times for drawing operations. Under OpenGL/ES 1.1 this is identical to StaticDraw.
QOpenGLBuffer::StreamRead0x88E1The data will be set once and used a few times for reading data back from the OpenGL server. Not supported under OpenGL/ES.
QOpenGLBuffer::StreamCopy0x88E2The data will be set once and used a few times for reading data back from the OpenGL server for use in further drawing operations. Not supported under OpenGL/ES.
QOpenGLBuffer::StaticDraw0x88E4The data will be set once and used many times for drawing operations.
QOpenGLBuffer::StaticRead0x88E5The data will be set once and used many times for reading data back from the OpenGL server. Not supported under OpenGL/ES.
QOpenGLBuffer::StaticCopy0x88E6The data will be set once and used many times for reading data back from the OpenGL server for use in further drawing operations. Not supported under OpenGL/ES.
QOpenGLBuffer::DynamicDraw0x88E8The data will be modified repeatedly and used many times for drawing operations.
QOpenGLBuffer::DynamicRead0x88E9The data will be modified repeatedly and used many times for reading data back from the OpenGL server. Not supported under OpenGL/ES.
QOpenGLBuffer::DynamicCopy0x88EAThe data will be modified repeatedly and used many times for reading data back from the OpenGL server for use in further drawing operations. Not supported under OpenGL/ES.

Member Function Documentation

QOpenGLBuffer::QOpenGLBuffer()

Constructs a new buffer object of type QOpenGLBuffer::VertexBuffer.

Note: this constructor just creates the QOpenGLBuffer instance. The actual buffer object in the OpenGL server is not created until create() is called.

See also create().

QOpenGLBuffer::QOpenGLBuffer(QOpenGLBuffer::Type type)

Constructs a new buffer object of type.

Note: this constructor just creates the QOpenGLBuffer instance. The actual buffer object in the OpenGL server is not created until create() is called.

See also create().

QOpenGLBuffer::QOpenGLBuffer(const QOpenGLBuffer & other)

Constructs a shallow copy of other.

Note: QOpenGLBuffer does not implement copy-on-write semantics, so other will be affected whenever the copy is modified.

QOpenGLBuffer::~QOpenGLBuffer()

Destroys this buffer object, including the storage being used in the OpenGL server.

void QOpenGLBuffer::allocate(const void * data, int count)

Allocates count bytes of space to the buffer, initialized to the contents of data. Any previous contents will be removed.

It is assumed that create() has been called on this buffer and that it has been bound to the current context.

See also create(), read(), and write().

void QOpenGLBuffer::allocate(int count)

This is an overloaded function.

Allocates count bytes of space to the buffer. Any previous contents will be removed.

It is assumed that create() has been called on this buffer and that it has been bound to the current context.

See also create() and write().

bool QOpenGLBuffer::bind()

Binds the buffer associated with this object to the current OpenGL context. Returns false if binding was not possible, usually because type() is not supported on this OpenGL implementation.

The buffer must be bound to the same QOpenGLContext current when create() was called, or to another QOpenGLContext that is sharing with it. Otherwise, false will be returned from this function.

See also release() and create().

GLuint QOpenGLBuffer::bufferId() const

Returns the OpenGL identifier associated with this buffer; zero if the buffer has not been created.

See also isCreated().

bool QOpenGLBuffer::create()

Creates the buffer object in the OpenGL server. Returns true if the object was created; false otherwise.

This function must be called with a current QOpenGLContext. 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 OpenGL implementation does not support buffers, or there is no current QOpenGLContext.

See also isCreated(), allocate(), write(), and destroy().

void QOpenGLBuffer::destroy()

Destroys this buffer object, including the storage being used in the OpenGL server. All references to the buffer will become invalid.

bool QOpenGLBuffer::isCreated() const

Returns true if this buffer has been created; false otherwise.

See also create() and destroy().

void * QOpenGLBuffer::map(QOpenGLBuffer::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.

See also unmap(), create(), and bind().

bool QOpenGLBuffer::read(int offset, void * data, int count)

Reads the count bytes in this buffer starting at offset into data. Returns true on success; false if reading from the buffer is not supported. Buffer reading is not supported under OpenGL/ES.

It is assumed that this buffer has been bound to the current context.

See also write() and bind().

void QOpenGLBuffer::release()

Releases the buffer associated with this object from the current OpenGL context.

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

See also bind().

void QOpenGLBuffer::release(QOpenGLBuffer::Type type) [static]

Releases the buffer associated with type in the current QOpenGLContext.

This function is a direct call to glBindBuffer(type, 0) for use when the caller does not know which QOpenGLBuffer has been bound to the context but wants to make sure that it is released.

 QOpenGLBuffer::release(QOpenGLBuffer::VertexBuffer);

void QOpenGLBuffer::setUsagePattern(QOpenGLBuffer::UsagePattern value)

Sets the usage pattern for this buffer object to value. This function must be called before allocate() or write().

See also usagePattern(), allocate(), and write().

int QOpenGLBuffer::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.

See also isCreated() and bind().

QOpenGLBuffer::Type QOpenGLBuffer::type() const

Returns the type of buffer represented by this object.

bool QOpenGLBuffer::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.

See also map().

QOpenGLBuffer::UsagePattern QOpenGLBuffer::usagePattern() const

Returns the usage pattern for this buffer object. The default value is StaticDraw.

See also setUsagePattern().

void QOpenGLBuffer::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.

See also create(), read(), and allocate().

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

Assigns a shallow copy of other to this object.

Note: QOpenGLBuffer does not implement copy-on-write semantics, so other will be affected whenever the copy is modified.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web