Struct Renderer

Source
pub struct Renderer {
    pub profile: RendererProfile,
    pub adapter_info: ExtendedAdapterInfo,
    pub queue: Arc<Queue>,
    pub device: Arc<Device>,
    pub features: Features,
    pub limits: Limits,
    pub downlevel: DownlevelCapabilities,
    pub handedness: Handedness,
    pub data_core: Mutex<RendererDataCore>,
    pub mipmap_generator: MipmapGenerator,
    /* private fields */
}
Expand description

Core struct which contains the renderer world. Primary way to interact with the world.

Fields§

§profile: RendererProfile

The rendering profile used.

§adapter_info: ExtendedAdapterInfo

Information about the adapter.

§queue: Arc<Queue>

Queue all command buffers will be submitted to.

§device: Arc<Device>

Device all objects will be created with.

§features: Features

Features of the device

§limits: Limits

Limits of the device

§downlevel: DownlevelCapabilities

Downlevel limits of the device

§handedness: Handedness

Handedness of all parts of this renderer.

§data_core: Mutex<RendererDataCore>

All the lockable data

§mipmap_generator: MipmapGenerator

Tool which generates mipmaps from a texture.

Implementations§

Source§

impl Renderer

Source

pub fn new( iad: InstanceAdapterDevice, handedness: Handedness, aspect_ratio: Option<f32>, ) -> Result<Arc<Self>, RendererInitializationError>

Create a new renderer with the given IAD.

You can create your own IAD or call create_iad.

The aspect ratio is that of the window. This automatically configures the camera. If None is passed, an aspect ratio of 1.0 is assumed.

Source

pub fn add_mesh(&self, mesh: Mesh) -> MeshHandle

Adds a 3D mesh to the renderer. This doesn’t instantiate it to world. To show this in the world, you need to create an Object using this mesh.

The handle will keep the mesh alive. All objects created will also keep the mesh alive.

Source

pub fn add_skeleton(&self, skeleton: Skeleton) -> SkeletonHandle

Adds a skeleton into the renderer. This combines a Mesh with a set of joints that can be used to animate that mesh.

The handle will keep the skeleton alive. All objects created will also keep the skeleton alive. The skeleton will also keep the mesh it references alive.

Source

pub fn add_texture_2d(&self, texture: Texture) -> TextureHandle

Add a 2D texture to the renderer. This can be used in a Material.

The handle will keep the texture alive. All materials created with this texture will also keep the texture alive.

Source

pub fn add_texture_2d_from_texture( &self, texture: TextureFromTexture, ) -> TextureHandle

Add a 2D texture to the renderer by copying a set of mipmaps from an existing texture. This new can be used in a Material.

The handle will keep the texture alive. All materials created with this texture will also keep the texture alive.

Source

pub fn add_texture_cube(&self, texture: Texture) -> TextureHandle

Adds a Cube texture to the renderer. This can be used as a cube environment map by a render routine.

The handle will keep the texture alive.

Source

pub fn add_material<M: Material>(&self, material: M) -> MaterialHandle

Adds a material to the renderer. This can be used in an Object.

The handle will keep the material alive. All objects created with this material will also keep this material alive.

The material will keep the inside textures alive.

Source

pub fn update_material<M: Material>(&self, handle: &MaterialHandle, material: M)

Updates a given material. Old references will be dropped.

Source

pub fn add_object(&self, object: Object) -> ObjectHandle

Adds an object to the renderer. This will create a visible object using the given mesh and materal.

The handle will keep the material alive.

The object will keep all materials, textures, and meshes alive.

Source

pub fn duplicate_object( &self, object_handle: &ObjectHandle, change: ObjectChange, ) -> ObjectHandle

Duplicates an existing object in the renderer, returning the new object’s handle. Any changes specified in the change struct will be applied to the duplicated object, and the same mesh, material and transform as the original object will be used otherwise.

Source

pub fn set_object_transform(&self, handle: &ObjectHandle, transform: Mat4)

Move the given object to a new transform location.

Source

pub fn set_skeleton_joint_transforms( &self, handle: &SkeletonHandle, joint_global_transforms: &[Mat4], inverse_bind_transforms: &[Mat4], )

Sets the joint positions for a skeleton. See Renderer::set_skeleton_joint_matrices to set the vertex transformations directly, without having to supply two separate matrix vectors.

§Inputs
  • joint_global_positions: Contains one transform matrix per bone, containing that bone’s current clobal transform
  • inverse_bind_poses: Contains one inverse bind transform matrix per bone, that is, the inverse of the bone’s transformation at its rest position.
Source

pub fn set_skeleton_joint_matrices( &self, handle: &SkeletonHandle, joint_matrices: Vec<Mat4>, )

Sets the joint matrices for a skeleton. The joint matrix is the transformation that will be applied to a vertex affected by a joint. Note that this is not the same as the joint’s transformation. See Renderer::set_skeleton_joint_transforms for an alternative method that allows setting the joint transformation instead.

Source

pub fn add_directional_light( &self, light: DirectionalLight, ) -> DirectionalLightHandle

Add a sun-like light into the world.

The handle will keep the light alive.

Source

pub fn update_directional_light( &self, handle: &DirectionalLightHandle, change: DirectionalLightChange, )

Updates the settings for given directional light.

Source

pub fn set_aspect_ratio(&self, ratio: f32)

Sets the aspect ratio of the camera. This should correspond with the aspect ratio of the user.

Source

pub fn set_camera_data(&self, data: Camera)

Sets the position, pov, or projection mode of the camera.

Source

pub fn ready(&self) -> (Vec<CommandBuffer>, ReadyData)

Render a frame of the scene onto the given output, using the given RenderRoutine.

The RendererStatistics may not be the results from this frame, but might be the results from multiple frames ago.

Auto Trait Implementations§

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

Source§

fn downcast(&self) -> &T

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, 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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> AnyBound<dyn Any> for T
where T: Any,

Source§

impl<T> AnyBound<dyn Any + Send> for T
where T: Any + Send,

Source§

impl<T> AnyBound<dyn Any + Send + Sync> for T
where T: Any + Send + Sync,

Source§

impl<T> AnyBound<dyn Any + Sync> for T
where T: Any + Sync,