Skip to main content

GpuFrameView

Struct GpuFrameView 

Source
pub struct GpuFrameView<'a> { /* private fields */ }
Expand description

GPU-oriented access to static primitive buffers and dynamic frame data.

Implementations§

Source§

impl<'a> GpuFrameView<'a>

Source

pub fn draws(self) -> impl ExactSizeIterator<Item = GpuDraw<'a>> + 'a

Iterates over renderer-ready draw records for every primitive.

Examples found in repository?
examples/vrma.rs (line 35)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9    let mut arguments = std::env::args().skip(1);
10    let avatar_path = arguments
11        .next()
12        .expect("usage: vrma <avatar.vrm> <motion.vrma>");
13    let animation_path = arguments
14        .next()
15        .expect("usage: vrma <avatar.vrm> <motion.vrma>");
16
17    let avatar = AvatarAsset::load(avatar_path)?;
18    let animation = VrmAnimation::load(animation_path)?;
19    let duration = animation.duration();
20    let mut runtime = AvatarRuntime::new(avatar);
21
22    runtime.play(
23        animation,
24        PlaybackOptions {
25            mode: PlaybackMode::Once,
26            ..PlaybackOptions::default()
27        },
28    )?;
29
30    let delta_seconds = 1.0 / 60.0;
31    let frame_count = ((duration / delta_seconds).ceil() as usize).max(1) + 1;
32    for frame_index in 0..frame_count {
33        let (draw_count, bone_update_count) = {
34            let frame = runtime.update(delta_seconds)?;
35            (frame.gpu().draws().len(), frame.bone_updates().len())
36        };
37
38        if frame_index % 60 == 0 || !runtime.is_playing() {
39            println!(
40                "time={:.3}s draws={} bone_updates={}",
41                runtime.playback_time().unwrap_or(0.0),
42                draw_count,
43                bone_update_count,
44            );
45        }
46        if !runtime.is_playing() {
47            break;
48        }
49    }
50
51    Ok(())
52}

Trait Implementations§

Source§

impl<'a> Clone for GpuFrameView<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for GpuFrameView<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for GpuFrameView<'a>

§

impl<'a> RefUnwindSafe for GpuFrameView<'a>

§

impl<'a> Send for GpuFrameView<'a>

§

impl<'a> Sync for GpuFrameView<'a>

§

impl<'a> Unpin for GpuFrameView<'a>

§

impl<'a> UnsafeUnpin for GpuFrameView<'a>

§

impl<'a> UnwindSafe for GpuFrameView<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.