[−][src]Struct web_glitz::pipeline::graphics::IndexBuffer
A GPU-accessible memory buffer that contains an indexed list for indexed drawing.
Very similar to a [Buffer] but exclusively for data used for indexed drawing. For security reasons, WebGL implementations require that index buffer never reference out of bounds vertices. To ensure this, the browser will perform additional checks on the indices in index buffers. To ensure that these checks needs only be done for index buffers (and not all buffers), a dichotomy was introduced that treats index buffers differently from buffers intended for different uses (e.g. a vertex data buffer, a uniform buffer, or a transform feedback buffer), where an index buffers may only ever be bound as an index buffer, never as a different kind of buffer, whereas other buffer kinds may be used for multiple ends. Additionally, index buffers are not allowed to perform GPU copy commands; only upload commands are permitted, where after each upload the browser will have to reevaluate the range of indices contained in the buffer (or buffer sub-region) when it is next used to draw. In short, for index data use an IndexBuffer; for all other ends use an ordinary [Buffer].
Example
use web_glitz::pipeline::graphics::IndexBuffer; use web_glitz::buffer::UsageHint; let index_buffer: IndexBuffer<u16> = context.create_index_buffer([1, 2, 3, 4], UsageHint::StreamDraw);
Implementations
impl<T> IndexBuffer<T>[src]
pub fn usage_hint(&self) -> UsageHint[src]
Returns the UsageHint that was specified for this IndexBuffer when it was created.
See UsageHint for details.
pub fn len(&self) -> usize[src]
Returns the number of indices contained in this IndexBuffer.
pub fn get<R>(&self, range: R) -> Option<IndexBufferView<'_, T>> where
R: IndexBufferSliceRange<T>, [src]
R: IndexBufferSliceRange<T>,
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; use web_glitz::buffer::UsageHint; let index_buffer: IndexBuffer<u16> = context.create_index_buffer([1, 2, 3, 4], UsageHint::StreamDraw); index_buffer.get(1..3); // Some IndexBufferView<[f32]> containing `[2.0, 3.0]` index_buffer.get(..2); // Some IndexBufferView<[f32]> containing `[1.0 2.0]`
pub unsafe fn get_unchecked<R>(&self, index: R) -> IndexBufferView<'_, T> where
R: IndexBufferSliceRange<T>, [src]
R: IndexBufferSliceRange<T>,
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; use web_glitz::buffer::UsageHint; let index_buffer: IndexBuffer<u16> = context.create_index_buffer([1, 2, 3, 4], UsageHint::StreamDraw); unsafe { index_buffer.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<T> IndexBuffer<T> where
T: IndexFormat, [src]
T: IndexFormat,
pub fn upload_command<D>(&self, index_data: D) -> IndexBufferUploadCommand<T, D> where
D: Borrow<[T]> + Send + Sync + 'static, [src]
D: Borrow<[T]> + Send + Sync + 'static,
Returns a command which, when executed will replace the indices contained in this
IndexBuffer with the indices in given index_data.
If the index_data contains fewer elements than this IndexBuffer, 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 this IndexBuffer, then only the first M
elements in the index_data will be used to update this IndexBuffer, where M is the
number of elements in the IndexBuffer.
impl<T> IndexBuffer<MaybeUninit<T>> where
T: IndexFormat, [src]
T: IndexFormat,
pub fn upload_command<D>(
&self,
index_data: D
) -> IndexBufferUploadCommand<MaybeUninit<T>, D> where
D: Borrow<[MaybeUninit<T>]> + Send + Sync + 'static, [src]
&self,
index_data: D
) -> IndexBufferUploadCommand<MaybeUninit<T>, D> where
D: Borrow<[MaybeUninit<T>]> + Send + Sync + 'static,
Returns a command which, when executed will replace the indices contained in this
IndexBuffer with the indices in given index_data.
If the index_data contains fewer elements than this IndexBuffer, 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 this IndexBuffer, then only the first M
elements in the index_data will be used to update this IndexBuffer, where M is the
number of elements in the IndexBuffer.
impl<T> IndexBuffer<MaybeUninit<T>> where
T: IndexFormat, [src]
T: IndexFormat,
pub unsafe fn assume_init(self) -> IndexBuffer<T>[src]
Converts to IndexBuffer<T>.
Safety
Any tasks that read from the buffer after assume_init was called, must only be executed
after the buffer was 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> From<&'a IndexBuffer<T>> for IndexBufferView<'a, T>[src]
fn from(buffer: &'a IndexBuffer<T>) -> IndexBufferView<'a, T>[src]
impl<T> Hash for IndexBuffer<T>[src]
fn hash<H: Hasher>(&self, state: &mut H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<'a, T> IndexData for &'a IndexBuffer<T> where
T: IndexFormat, [src]
T: IndexFormat,
fn descriptor(&self) -> IndexDataDescriptor[src]
impl<T> PartialEq<IndexBuffer<T>> for IndexBuffer<T>[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for IndexBuffer<T>
impl<T> !Send for IndexBuffer<T>
impl<T> !Sync for IndexBuffer<T>
impl<T> Unpin for IndexBuffer<T>
impl<T> !UnwindSafe for IndexBuffer<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static, [src]
D: Borrow<T> + 'static,
T: Copy + 'static,
fn into_buffer<Rc>(Self, &Rc, BufferId, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static, [src]
Rc: RenderingContext + Clone + 'static,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,