Struct BufferData

Source
pub struct BufferData<'a, R: Renderable> { /* private fields */ }
Expand description

A data buffer for use with vertex data. It may be indices or vertex coordinates etc.

A data buffer may contain a lot of data per vertex, such as position, normal, tangent, color etc. a GPU BufferView on the data is then a subset of this data - perhaps picking out just the position, for example, for a set of vertices

The data buffer may, indeed, contain data for more than one object

  • and the objects may have different data per vertex.

A data buffer may then be used by many GPU BufferViews. Each BufferView may be used by many primitives for a single model; alternatively, primitives may have their own individual BufferViews.

To allow a Renderable to use the BufferData for multiple views, it supports a ‘client’ field that can be initialized using the ‘init_buffer_data_client’ method of the Renderable, and then borrowed as required during render programming.

Implementations§

Source§

impl<'a, R: Renderable> BufferData<'a, R>

Source

pub fn byte_length(&self) -> u32

Get the byte length of the BufferData

Source

pub fn byte_offset(&self) -> u32

Get the byte offset within the underlying data of the BufferData

Source

pub fn new<B: ByteBuffer + ?Sized>( data: &'a B, byte_offset: u32, byte_length: u32, ) -> Self

Create a new BufferData given a buffer, offset and length; if the length is zero then the whole of the data buffer post offset is used

If offset and length are both zero, then all the data is used

Source

pub fn create_client(&self, renderable: &mut R)

Replace the client data with one of this data

Source

pub fn borrow_client(&self) -> Ref<'_, R::Buffer>

Borrow the client immutably

Trait Implementations§

Source§

impl<'a, R> AsRef<[u8]> for BufferData<'a, R>
where R: Renderable,

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, R: Renderable> Debug for BufferData<'a, R>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, R: Renderable> Display for BufferData<'a, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, R: Renderable> DefaultIndentedDisplay for BufferData<'a, R>

Auto Trait Implementations§

§

impl<'a, R> !Freeze for BufferData<'a, R>

§

impl<'a, R> !RefUnwindSafe for BufferData<'a, R>

§

impl<'a, R> Send for BufferData<'a, R>
where <R as Renderable>::Buffer: Send,

§

impl<'a, R> !Sync for BufferData<'a, R>

§

impl<'a, R> Unpin for BufferData<'a, R>
where <R as Renderable>::Buffer: Unpin,

§

impl<'a, R> UnwindSafe for BufferData<'a, R>
where <R as Renderable>::Buffer: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, O, T> IndentedDisplay<'a, O> for T

Source§

fn indent(&self, ind: &mut Indenter<'a, O>) -> Result<(), Error>

Display for humans with indent
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.