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
sourceimpl Renderer
impl Renderer
sourcepub fn new(
iad: InstanceAdapterDevice,
handedness: Handedness,
aspect_ratio: Option<f32>
) -> Result<Arc<Self>, RendererInitializationError>
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.
sourcepub fn add_mesh(&self, mesh: Mesh) -> MeshHandle
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.
sourcepub fn add_skeleton(&self, skeleton: Skeleton) -> SkeletonHandle
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.
sourcepub fn add_texture_2d(&self, texture: Texture) -> TextureHandle
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.
sourcepub fn add_texture_2d_from_texture(
&self,
texture: TextureFromTexture
) -> TextureHandle
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.
sourcepub fn add_texture_cube(&self, texture: Texture) -> TextureHandle
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.
sourcepub fn add_material<M: Material>(&self, material: M) -> MaterialHandle
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.
sourcepub fn update_material<M: Material>(&self, handle: &MaterialHandle, material: M)
pub fn update_material<M: Material>(&self, handle: &MaterialHandle, material: M)
Updates a given material. Old references will be dropped.
sourcepub fn add_object(&self, object: Object) -> ObjectHandle
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.
sourcepub fn duplicate_object(
&self,
object_handle: &ObjectHandle,
change: ObjectChange
) -> ObjectHandle
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.
sourcepub fn set_object_transform(&self, handle: &ObjectHandle, transform: Mat4)
pub fn set_object_transform(&self, handle: &ObjectHandle, transform: Mat4)
Move the given object to a new transform location.
sourcepub fn set_skeleton_joint_transforms(
&self,
handle: &SkeletonHandle,
joint_global_transforms: &[Mat4],
inverse_bind_transforms: &[Mat4]
)
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 transforminverse_bind_poses
: Contains one inverse bind transform matrix per bone, that is, the inverse of the bone’s transformation at its rest position.
sourcepub fn set_skeleton_joint_matrices(
&self,
handle: &SkeletonHandle,
joint_matrices: Vec<Mat4>
)
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.
sourcepub fn add_directional_light(
&self,
light: DirectionalLight
) -> DirectionalLightHandle
pub fn add_directional_light(
&self,
light: DirectionalLight
) -> DirectionalLightHandle
Add a sun-like light into the world.
The handle will keep the light alive.
sourcepub fn update_directional_light(
&self,
handle: &DirectionalLightHandle,
change: DirectionalLightChange
)
pub fn update_directional_light(
&self,
handle: &DirectionalLightHandle,
change: DirectionalLightChange
)
Updates the settings for given directional light.
sourcepub fn set_aspect_ratio(&self, ratio: f32)
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.
sourcepub fn set_camera_data(&self, data: Camera)
pub fn set_camera_data(&self, data: Camera)
Sets the position, pov, or projection mode of the camera.
Auto Trait Implementations
impl !RefUnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl !Unpin for Renderer
impl !UnwindSafe for Renderer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more