[−][src]Struct web_glitz::buffer::BufferView
A view on a segment or the whole of a Buffer.
Methods
impl<'a, T> BufferView<'a, T> where
T: ?Sized,
[src]
T: ?Sized,
pub fn usage_hint(&self) -> UsageHint
[src]
Returns the UsageHint that was specified for the Buffer view by this BufferView when it was created.
See UsageHint for details.
impl<'a, T> BufferView<'a, T> where
T: Copy,
[src]
T: Copy,
pub fn upload_command<D>(&self, data: D) -> UploadCommand<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 data viewed by this BufferView
with the given data
.
This will modify the viewed Buffer, the buffer (and any other views on the same data) will be affected by this change.
pub fn download_command(&self) -> DownloadCommand<T>
[src]
Returns a command which, when executed will copy the data viewed by in this BufferView into a Box.
When the task is finished, the Box containing the copied data will be output.
impl<'a, T> BufferView<'a, [T]>
[src]
pub fn len(&self) -> usize
[src]
Returns the number of elements contained in this Buffer.
pub fn get<I>(&self, index: I) -> Option<BufferView<I::Output>> where
I: BufferViewSliceIndex<T>,
[src]
I: BufferViewSliceIndex<T>,
Returns a BufferView on an element or a sub-slice of the elements this Buffer, depending
on the type of index
.
- If given a position, returns a view on the element at that position or
None
if out of bounds. - If given a range, returns a view on the sub-slice of elements corresponding to that range,
or
None
if out of bounds.
Examples
use web_glitz::buffer::UsageHint; let buffer = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw); let view = buffer.view(); view.get(1); // Some BufferView<f32> containing `2.0` view.get(1..3); // Some BufferView<[f32]> containing `[2.0, 3.0]` view.get(..2); // Some BufferView<[f32]> containing `[1.0 2.0]` view.get(4); // None (index out of bounds)
pub unsafe fn get_unchecked<I>(&self, index: I) -> BufferView<I::Output> where
I: BufferViewSliceIndex<T>,
[src]
I: BufferViewSliceIndex<T>,
Returns a BufferView on an element or a sub-slice of the elements this BufferView,
depending on the type of index
, without doing bounds checking.
- If given a position, returns a view on the element at that position, without doing bounds checking.
- If given a range, returns a view on the slice of elements corresponding to that range, without doing bounds checking.
Examples
use web_glitz::buffer::UsageHint; let buffer = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw); let view = buffer.view(); unsafe { view.get_unchecked(1) }; // BufferView<f32> containing `2.0`
Unsafe
Only safe if index
is in bounds. See [get] for a safe alternative.
impl<'a, T> BufferView<'a, [T]> where
T: Copy,
[src]
T: Copy,
pub fn upload_command<D>(&self, data: D) -> UploadCommand<[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 elements viewed by this BufferView
with the elements in given data
.
If the data
contains fewer elements than the slice viewed by this BufferView, then only
the first N
elements will be replaced, where N
is the number of elements in the given
data
.
If the data
contains more elements than the slice viewed by this Buffer, then only the
first M
elements in the data
will be used to update this Buffer, where M
is the
number of elements in the slice viewed by the BufferView.
This will modify the viewed Buffer, the buffer (and any other views on the same data) will be affected by this change.
pub fn download_command(&self) -> DownloadCommand<[T]>
[src]
Returns a command which, when executed will copy the elements viewed by in this BufferView into a Box.
When the task is finished, the Box containing the copied elements will be output.
Trait Implementations
impl<'a, T> VertexBuffer for BufferView<'a, [T]> where
T: Vertex,
[src]
T: Vertex,
fn encode(self, encoding: &mut VertexBuffersEncoding)
[src]
impl<'a, T> TypedVertexBuffer for BufferView<'a, [T]> where
T: Vertex,
[src]
T: Vertex,
type Vertex = T
impl<'a, F> IndexBuffer for BufferView<'a, [F]> where
F: IndexFormat,
[src]
F: IndexFormat,
fn encode<'b>(
&self,
context: &'b mut IndexBufferEncodingContext
) -> IndexBufferEncoding<'b>
[src]
&self,
context: &'b mut IndexBufferEncodingContext
) -> IndexBufferEncoding<'b>
impl<'a, T> BufferResource for BufferView<'a, T> where
T: InterfaceBlock,
[src]
T: InterfaceBlock,
type Binding = BufferBinding<'a, T>
The type of binding for this resource.
fn into_binding(self, index: u32) -> Self::Binding
[src]
impl<'a, T> Into<BufferView<'a, T>> for &'a Buffer<T> where
T: ?Sized,
[src]
T: ?Sized,
fn into(self) -> BufferView<'a, T>
[src]
impl<'a, T> Clone for BufferView<'a, T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T> Clone for BufferView<'a, [T]>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T> Copy for BufferView<'a, T>
[src]
impl<'a, T> Copy for BufferView<'a, [T]>
[src]
Auto Trait Implementations
impl<'a, T> !Send for BufferView<'a, T>
impl<'a, T: ?Sized> Unpin for BufferView<'a, T>
impl<'a, T> !Sync for BufferView<'a, T>
impl<'a, T> !UnwindSafe for BufferView<'a, T>
impl<'a, T> !RefUnwindSafe for BufferView<'a, T>
Blanket Implementations
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, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static,
[src]
Rc: RenderingContext + Clone + 'static,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,