[][src]Struct qt_gui::QOpenGLVertexArrayObject

#[repr(C)]
pub struct QOpenGLVertexArrayObject { /* fields omitted */ }

The QOpenGLVertexArrayObject class wraps an OpenGL Vertex Array Object.

C++ class: QOpenGLVertexArrayObject.

C++ documentation:

The QOpenGLVertexArrayObject class wraps an OpenGL Vertex Array Object.

A Vertex Array Object (VAO) is an OpenGL container object that encapsulates the state needed to specify per-vertex attribute data to the OpenGL pipeline. To put it another way, a VAO remembers the states of buffer objects (see QOpenGLBuffer) and their associated state (e.g. vertex attribute divisors). This allows a very easy and efficient method of switching between OpenGL buffer states for rendering different "objects" in a scene. The QOpenGLVertexArrayObject class is a thin wrapper around an OpenGL VAO.

For the desktop, VAOs are supported as a core feature in OpenGL 3.0 or newer and by the GL_ARB_vertex_array_object for older versions. On OpenGL ES 2, VAOs are provided by the optional GL_OES_vertex_array_object extension. You can check the version of OpenGL with QOpenGLContext::surfaceFormat() and check for the presence of extensions with QOpenGLContext::hasExtension().

As with the other Qt OpenGL classes, QOpenGLVertexArrayObject has a create() function to create the underlying OpenGL object. This is to allow the developer to ensure that there is a valid current OpenGL context at the time.

Once you have successfully created a VAO the typical usage pattern is:

  • In scene initialization function, for each visual object:
    • Bind the VAO
    • Set vertex data state for this visual object (vertices, normals, texture coordinates etc.)
    • Unbind (release()) the VAO
  • In render function, for each visual object:
    • Bind the VAO (and shader program if needed)
    • Call a glDraw*() function
    • Unbind (release()) the VAO

The act of binding the VAO in the render function has the effect of restoring all of the vertex data state setup in the initialization phase. In this way we can set a great deal of state when setting up a VAO and efficiently switch between state sets of objects to be rendered. Using VAOs also allows the OpenGL driver to amortise the validation checks of the vertex data.

Note: Vertex Array Objects, like all other OpenGL container objects, are specific to the context for which they were created and cannot be shared amongst a context group.

Methods

impl QOpenGLVertexArrayObject[src]

pub unsafe fn bind(&mut self)[src]

Binds this vertex array object to the OpenGL binding point. From this point on and until release() is called or another vertex array object is bound, any modifications made to vertex data state are stored inside this vertex array object.

Calls C++ function: void QOpenGLVertexArrayObject::bind().

C++ documentation:

Binds this vertex array object to the OpenGL binding point. From this point on and until release() is called or another vertex array object is bound, any modifications made to vertex data state are stored inside this vertex array object.

If another vertex array object is then bound you can later restore the set of state associated with this object by calling bind() on this object once again. This allows efficient changes between vertex data states in rendering functions.

pub unsafe fn create(&mut self) -> bool[src]

Creates the underlying OpenGL vertex array object. There must be a valid OpenGL context that supports vertex array objects current for this function to succeed.

Calls C++ function: bool QOpenGLVertexArrayObject::create().

C++ documentation:

Creates the underlying OpenGL vertex array object. There must be a valid OpenGL context that supports vertex array objects current for this function to succeed.

Returns true if the OpenGL vertex array object was successfully created.

When the return value is false, vertex array object support is not available. This is not an error: on systems with OpenGL 2.x or OpenGL ES 2.0 vertex array objects may not be supported. The application is free to continue execution in this case, but it then has to be prepared to operate in a VAO-less manner too. This means that instead of merely calling bind(), the value of isCreated() must be checked and the vertex arrays has to be initialized in the traditional way when there is no vertex array object present.

See also isCreated().

pub unsafe fn destroy(&mut self)[src]

Destroys the underlying OpenGL vertex array object. There must be a valid OpenGL context that supports vertex array objects current for this function to succeed.

Calls C++ function: void QOpenGLVertexArrayObject::destroy().

C++ documentation:

Destroys the underlying OpenGL vertex array object. There must be a valid OpenGL context that supports vertex array objects current for this function to succeed.

pub unsafe fn is_created(&self) -> bool[src]

Returns true is the underlying OpenGL vertex array object has been created. If this returns true and the associated OpenGL context is current, then you are able to bind() this object.

Calls C++ function: bool QOpenGLVertexArrayObject::isCreated() const.

C++ documentation:

Returns true is the underlying OpenGL vertex array object has been created. If this returns true and the associated OpenGL context is current, then you are able to bind() this object.

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QOpenGLVertexArrayObject::metaObject() const.

pub unsafe fn new_1a(
    parent: impl CastInto<MutPtr<QObject>>
) -> CppBox<QOpenGLVertexArrayObject>
[src]

Creates a QOpenGLVertexArrayObject with the given parent. You must call create() with a valid OpenGL context before using.

Calls C++ function: [constructor] void QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QObject* parent = …).

C++ documentation:

Creates a QOpenGLVertexArrayObject with the given parent. You must call create() with a valid OpenGL context before using.

pub unsafe fn new_0a() -> CppBox<QOpenGLVertexArrayObject>[src]

The QOpenGLVertexArrayObject class wraps an OpenGL Vertex Array Object.

Calls C++ function: [constructor] void QOpenGLVertexArrayObject::QOpenGLVertexArrayObject().

C++ documentation:

The QOpenGLVertexArrayObject class wraps an OpenGL Vertex Array Object.

A Vertex Array Object (VAO) is an OpenGL container object that encapsulates the state needed to specify per-vertex attribute data to the OpenGL pipeline. To put it another way, a VAO remembers the states of buffer objects (see QOpenGLBuffer) and their associated state (e.g. vertex attribute divisors). This allows a very easy and efficient method of switching between OpenGL buffer states for rendering different "objects" in a scene. The QOpenGLVertexArrayObject class is a thin wrapper around an OpenGL VAO.

For the desktop, VAOs are supported as a core feature in OpenGL 3.0 or newer and by the GL_ARB_vertex_array_object for older versions. On OpenGL ES 2, VAOs are provided by the optional GL_OES_vertex_array_object extension. You can check the version of OpenGL with QOpenGLContext::surfaceFormat() and check for the presence of extensions with QOpenGLContext::hasExtension().

As with the other Qt OpenGL classes, QOpenGLVertexArrayObject has a create() function to create the underlying OpenGL object. This is to allow the developer to ensure that there is a valid current OpenGL context at the time.

Once you have successfully created a VAO the typical usage pattern is:

  • In scene initialization function, for each visual object:
    • Bind the VAO
    • Set vertex data state for this visual object (vertices, normals, texture coordinates etc.)
    • Unbind (release()) the VAO
  • In render function, for each visual object:
    • Bind the VAO (and shader program if needed)
    • Call a glDraw*() function
    • Unbind (release()) the VAO

The act of binding the VAO in the render function has the effect of restoring all of the vertex data state setup in the initialization phase. In this way we can set a great deal of state when setting up a VAO and efficiently switch between state sets of objects to be rendered. Using VAOs also allows the OpenGL driver to amortise the validation checks of the vertex data.

Note: Vertex Array Objects, like all other OpenGL container objects, are specific to the context for which they were created and cannot be shared amongst a context group.

pub unsafe fn object_id(&self) -> u32[src]

Returns the id of the underlying OpenGL vertex array object.

Calls C++ function: GLuint QOpenGLVertexArrayObject::objectId() const.

C++ documentation:

Returns the id of the underlying OpenGL vertex array object.

pub unsafe fn qt_metacall(
    &mut self,
    arg1: Call,
    arg2: c_int,
    arg3: impl CastInto<MutPtr<*mut c_void>>
) -> c_int
[src]

Calls C++ function: virtual int QOpenGLVertexArrayObject::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(
    &mut self,
    arg1: impl CastInto<Ptr<c_char>>
) -> MutPtr<c_void>
[src]

Calls C++ function: virtual void* QOpenGLVertexArrayObject::qt_metacast(const char* arg1).

pub unsafe fn release(&mut self)[src]

Unbinds this vertex array object by binding the default vertex array object (id = 0).

Calls C++ function: void QOpenGLVertexArrayObject::release().

C++ documentation:

Unbinds this vertex array object by binding the default vertex array object (id = 0).

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn tr(
    s: impl CastInto<Ptr<c_char>>,
    c: impl CastInto<Ptr<c_char>>,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QOpenGLVertexArrayObject::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: impl CastInto<Ptr<c_char>>,
    c: impl CastInto<Ptr<c_char>>,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QOpenGLVertexArrayObject::trUtf8(const char* s, const char* c, int n).

Trait Implementations

impl CppDeletable for QOpenGLVertexArrayObject[src]

unsafe fn delete(&mut self)[src]

Destroys the QOpenGLVertexArrayObject and the underlying OpenGL resource.

Calls C++ function: virtual [destructor] void QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject().

C++ documentation:

Destroys the QOpenGLVertexArrayObject and the underlying OpenGL resource.

impl Deref for QOpenGLVertexArrayObject[src]

type Target = QObject

The resulting type after dereferencing.

fn deref(&self) -> &QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QOpenGLVertexArrayObject* ptr).

impl DerefMut for QOpenGLVertexArrayObject[src]

fn deref_mut(&mut self) -> &mut QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QOpenGLVertexArrayObject* ptr).

impl DynamicCast<QOpenGLVertexArrayObject> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QOpenGLVertexArrayObject>[src]

Calls C++ function: QOpenGLVertexArrayObject* dynamic_cast<QOpenGLVertexArrayObject*>(QObject* ptr).

unsafe fn dynamic_cast_mut(
    ptr: MutPtr<QObject>
) -> MutPtr<QOpenGLVertexArrayObject>
[src]

Calls C++ function: QOpenGLVertexArrayObject* dynamic_cast<QOpenGLVertexArrayObject*>(QObject* ptr).

impl StaticDowncast<QOpenGLVertexArrayObject> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QOpenGLVertexArrayObject>[src]

Calls C++ function: QOpenGLVertexArrayObject* static_cast<QOpenGLVertexArrayObject*>(QObject* ptr).

unsafe fn static_downcast_mut(
    ptr: MutPtr<QObject>
) -> MutPtr<QOpenGLVertexArrayObject>
[src]

Calls C++ function: QOpenGLVertexArrayObject* static_cast<QOpenGLVertexArrayObject*>(QObject* ptr).

impl StaticUpcast<QObject> for QOpenGLVertexArrayObject[src]

unsafe fn static_upcast(ptr: Ptr<QOpenGLVertexArrayObject>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QOpenGLVertexArrayObject* ptr).

unsafe fn static_upcast_mut(
    ptr: MutPtr<QOpenGLVertexArrayObject>
) -> MutPtr<QObject>
[src]

Calls C++ function: QObject* static_cast<QObject*>(QOpenGLVertexArrayObject* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.