Struct qt_gui::QOpenGLBuffer

source ·
#[repr(C)]
pub struct QOpenGLBuffer { /* private fields */ }
Expand description

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

C++ class: QOpenGLBuffer.

C++ documentation:

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.

Implementations§

source§

impl QOpenGLBuffer

source

pub unsafe fn allocate_2a(&self, data: *const c_void, count: c_int)

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

Calls C++ function: void QOpenGLBuffer::allocate(const void* data, int count).

C++ documentation:

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().

source

pub unsafe fn allocate_1a(&self, count: c_int)

This is an overloaded function.

Calls C++ function: void QOpenGLBuffer::allocate(int count).

C++ documentation:

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().

source

pub unsafe fn bind(&self) -> bool

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.

Calls C++ function: bool QOpenGLBuffer::bind().

C++ documentation:

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().

source

pub unsafe fn buffer_id(&self) -> u32

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

Calls C++ function: GLuint QOpenGLBuffer::bufferId() const.

C++ documentation:

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

See also isCreated().

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QOpenGLBuffer>> ) -> Ref<QOpenGLBuffer>

Assigns a shallow copy of other to this object.

Calls C++ function: QOpenGLBuffer& QOpenGLBuffer::operator=(const QOpenGLBuffer& other).

C++ documentation:

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.

source

pub unsafe fn create(&self) -> bool

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

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

C++ documentation:

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().

source

pub unsafe fn destroy(&self)

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

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

C++ documentation:

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

source

pub unsafe fn is_created(&self) -> bool

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

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

C++ documentation:

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

See also create() and destroy().

source

pub unsafe fn map(&self, access: Access) -> *mut c_void

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.

Calls C++ function: void* QOpenGLBuffer::map(QOpenGLBuffer::Access access).

C++ documentation:

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.

Note: This function is only supported under OpenGL ES 2.0 or earlier if the GL_OES_mapbuffer extension is present.

Note: On OpenGL ES 3.0 and newer, or, in case if desktop OpenGL, if GL_ARB_map_buffer_range is supported, this function uses glMapBufferRange instead of glMapBuffer.

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

source

pub unsafe fn map_range( &self, offset: c_int, count: c_int, access: QFlags<RangeAccessFlag> ) -> *mut c_void

Maps the range specified by offset and count of 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 specifies a combination of access flags.

Calls C++ function: void* QOpenGLBuffer::mapRange(int offset, int count, QFlags<QOpenGLBuffer::RangeAccessFlag> access).

C++ documentation:

Maps the range specified by offset and count of 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 specifies a combination of access flags.

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

Note: This function is not available on OpenGL ES 2.0 and earlier.

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

source

pub unsafe fn new_0a() -> CppBox<QOpenGLBuffer>

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

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

C++ documentation:

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().

source

pub unsafe fn new_1a(type_: Type) -> CppBox<QOpenGLBuffer>

Constructs a new buffer object of type.

Calls C++ function: [constructor] void QOpenGLBuffer::QOpenGLBuffer(QOpenGLBuffer::Type type).

C++ documentation:

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().

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QOpenGLBuffer>> ) -> CppBox<QOpenGLBuffer>

Constructs a shallow copy of other.

Calls C++ function: [constructor] void QOpenGLBuffer::QOpenGLBuffer(const QOpenGLBuffer& other).

C++ documentation:

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.

source

pub unsafe fn read( &self, offset: c_int, data: *mut c_void, count: c_int ) -> bool

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.

Calls C++ function: bool QOpenGLBuffer::read(int offset, void* data, int count).

C++ documentation:

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().

source

pub unsafe fn release_mut(&self)

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

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

C++ documentation:

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().

source

pub unsafe fn release(type_: Type)

Releases the buffer associated with type in the current QOpenGLContext.

Calls C++ function: static void QOpenGLBuffer::release(QOpenGLBuffer::Type type).

C++ documentation:

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);

source

pub unsafe fn set_usage_pattern(&self, value: UsagePattern)

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

Calls C++ function: void QOpenGLBuffer::setUsagePattern(QOpenGLBuffer::UsagePattern value).

C++ documentation:

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().

source

pub unsafe fn size(&self) -> c_int

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.

Calls C++ function: int QOpenGLBuffer::size() const.

C++ documentation:

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().

source

pub unsafe fn type_(&self) -> Type

Returns the type of buffer represented by this object.

Calls C++ function: QOpenGLBuffer::Type QOpenGLBuffer::type() const.

C++ documentation:

Returns the type of buffer represented by this object.

source

pub unsafe fn unmap(&self) -> bool

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.

Calls C++ function: bool QOpenGLBuffer::unmap().

C++ documentation:

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().

Note: This function is only supported under OpenGL ES 2.0 and earlier if the GL_OES_mapbuffer extension is present.

See also map().

source

pub unsafe fn usage_pattern(&self) -> UsagePattern

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

Calls C++ function: QOpenGLBuffer::UsagePattern QOpenGLBuffer::usagePattern() const.

C++ documentation:

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

See also setUsagePattern().

source

pub unsafe fn write(&self, offset: c_int, data: *const c_void, count: c_int)

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.

Calls C++ function: void QOpenGLBuffer::write(int offset, const void* data, int count).

C++ documentation:

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().

Trait Implementations§

source§

impl CppDeletable for QOpenGLBuffer

source§

unsafe fn delete(&self)

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

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

C++ documentation:

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

source§

impl Size for QOpenGLBuffer

source§

unsafe fn size(&self) -> usize

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.

Calls C++ function: int QOpenGLBuffer::size() const.

C++ documentation:

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().

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.