[][src]Struct web_glitz::pipeline::graphics::IndexBufferView

pub struct IndexBufferView<'a, T> { /* fields omitted */ }

A view on a segment or the whole of an IndexBuffer.

Implementations

impl<'a, T> IndexBufferView<'a, T>[src]

pub fn size_in_bytes(&self) -> usize[src]

The size in bytes of the viewed index buffer region.

pub fn usage_hint(&self) -> UsageHint[src]

Returns the UsageHint that was specified for the IndexBuffer viewed by this IndexBufferView when it was created.

See UsageHint for details.

pub fn len(&self) -> usize[src]

Returns the number of elements viewed by this IndexBufferView.

pub fn get<R>(&self, range: R) -> Option<IndexBufferView<'_, T>> where
    R: IndexBufferViewSliceIndex<T>, 
[src]

Returns an IndexBufferView on a slice of the indices this IndexBuffer based on the given range or None if the range is out of bounds

Examples

use web_glitz::pipeline::graphics::{IndexBuffer, IndexBufferView};
use web_glitz::buffer::UsageHint;

let index_buffer: IndexBuffer<u16> = context.create_index_buffer([1, 2, 3, 4], UsageHint::StreamDraw);
let view = IndexBufferView::from(&index_buffer);

view.get(1..3); // Some IndexBufferView<[f32]> containing `[2.0, 3.0]`
view.get(..2); // Some IndexBufferView<[f32]> containing `[1.0 2.0]`

pub unsafe fn get_unchecked<R>(&self, range: R) -> IndexBufferView<'_, T> where
    R: IndexBufferViewSliceIndex<T>, 
[src]

Returns an IndexBufferView on a slice of the indices this IndexBuffer based on the given range, without performing any bounds checks

Examples

use web_glitz::pipeline::graphics::{IndexBuffer, IndexBufferView};
use web_glitz::buffer::UsageHint;

let index_buffer: IndexBuffer<u16> = context.create_index_buffer([1, 2, 3, 4], UsageHint::StreamDraw);
let view = IndexBufferView::from(&index_buffer);

unsafe { view.get_unchecked(1..3) }; // IndexBufferView<[f32]> containing `[2.0, 3.0]`

Unsafe

Only safe if range is in bounds. See [get] for a safe alternative.

impl<'a, T> IndexBufferView<'a, T> where
    T: IndexFormat
[src]

pub fn upload_command<D>(&self, data: D) -> IndexBufferUploadCommand<T, D> where
    D: Borrow<[T]> + Send + Sync + 'static, 
[src]

Returns a command which, when executed will replace the indices viewed contained by this IndexBufferView with the indices in given index_data.

If the index_data contains fewer elements than the slice viewed by this IndexBufferView, then only the first N elements will be replaced, where N is the number of elements in the given index_data.

If the index_data contains more elements than the slice viewed this IndexBufferView, then only the first M elements in the index_data will be used to update the index buffer, where M is the number of elements viewed by the IndexBufferView.

This will modify the viewed IndexBuffer, the buffer (and any other views on the same data) will be affected by this change.

impl<'a, T> IndexBufferView<'a, MaybeUninit<T>> where
    T: IndexFormat
[src]

pub fn upload_command<D>(
    &self,
    data: D
) -> IndexBufferUploadCommand<MaybeUninit<T>, D> where
    D: Borrow<[MaybeUninit<T>]> + Send + Sync + 'static, 
[src]

Returns a command which, when executed will replace the indices viewed contained by this IndexBufferView with the indices in given data.

If the data contains fewer elements than the slice viewed by this IndexBufferView, then only the first N elements will be replaced, where N is the number of elements in the given index_data.

If the index_data contains more elements than the slice viewed this IndexBufferView, then only the first M elements in the index_data will be used to update the index buffer, where M is the number of elements viewed by the IndexBufferView.

This will modify the viewed IndexBuffer, the buffer (and any other views on the same data) will be affected by this change.

impl<'a, T> IndexBufferView<'a, MaybeUninit<T>> where
    T: IndexFormat
[src]

pub unsafe fn assume_init(self) -> IndexBufferView<'a, T>[src]

Converts to IndexBufferView<T>.

Safety

Its up to the user to guarantee that any tasks that read buffer region viewed by this view, is only executed after the viewed region is initialized. Note that certain tasks may wait on GPU fences and allow a runtime to progress other tasks while its waiting on the fence. As such, submitting your initialization tasks as part of a task that includes fencing (these are typically tasks that include "download" commands), may not guarantee that the buffer was initialized before any tasks that are submitted later will begin executing.

Trait Implementations

impl<'a, T> Clone for IndexBufferView<'a, T>[src]

impl<'a, T> Copy for IndexBufferView<'a, T>[src]

impl<'a, T> From<&'a IndexBuffer<T>> for IndexBufferView<'a, T>[src]

impl<'a, T: Hash> Hash for IndexBufferView<'a, T>[src]

impl<'a, T> IndexData for IndexBufferView<'a, T> where
    T: IndexFormat
[src]

impl<'a, T: PartialEq> PartialEq<IndexBufferView<'a, T>> for IndexBufferView<'a, T>[src]

impl<'a, T> StructuralPartialEq for IndexBufferView<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for IndexBufferView<'a, T>

impl<'a, T> !Send for IndexBufferView<'a, T>

impl<'a, T> !Sync for IndexBufferView<'a, T>

impl<'a, T> Unpin for IndexBufferView<'a, T>

impl<'a, T> !UnwindSafe for IndexBufferView<'a, T>

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> From<T> for T[src]

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

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.