Struct truck_platform::Scene [−][src]
Wraps wgpu
and provides an intuitive graphics API.
Scene
is the most important in truck-platform
.
This structure holds information about rendering and
serves as a bridge to the actual rendering of Rendered
objects.
Implementations
impl Scene
[src]
pub fn new(device_handler: DeviceHandler, scene_desc: &SceneDescriptor) -> Scene
[src]
constructor
pub fn device_handler(&self) -> &DeviceHandler
[src]
Returns the reference of its own DeviceHandler
.
pub fn device(&self) -> &Arc<Device>
[src]
Returns the reference of the device.
pub fn queue(&self) -> &Arc<Queue>
[src]
Returns the reference of the queue.
pub fn sc_desc(&self) -> SwapChainDescriptor
[src]
Returns the copy of swap chain descriptor.
pub fn lock_sc_desc(&self) -> LockResult<MutexGuard<'_, SwapChainDescriptor>>
[src]
Locks the swap chain descriptor.
pub fn elapsed(&self) -> Duration
[src]
Returns the elapsed time since the scene was created.
pub fn descriptor(&self) -> &SceneDescriptor
[src]
Returns the reference of the descriptor.
pub fn descriptor_mut(&mut self) -> &mut SceneDescriptor
[src]
Returns the mutable reference of the descriptor.
pub fn bind_group_layout(&self) -> &BindGroupLayout
[src]
Returns the bind group layout in the scene.
pub fn camera_buffer(&self) -> BufferHandler
[src]
Creates a UNIFORM
buffer of the camera.
The bind group provides Scene
holds this uniform buffer.
Shader Example
layout(set = 0, binding = 0) uniform Camera {
mat4 camera_matrix; // the camera matrix
mat4 camera_projection; // the projection into the normalized view volume
};
pub fn lights_buffer(&self) -> BufferHandler
[src]
Creates a STORAGE
buffer of all lights.
The bind group provides Scene
holds this uniform buffer.
Shader Example
struct Light {
vec4 position; // the position of light, position.w == 1.0
vec4 color; // the color of light, color.w == 1.0
uvec4 light_type; // Point => uvec4(0, 0, 0, 0), Uniform => uvec4(1, 0, 0, 0)
};
layout(set = 0, binding = 1) buffer Lights {
Light lights[]; // the number of lights must be gotten from another place
};
pub fn scene_status_buffer(&self) -> BufferHandler
[src]
Creates a UNIFORM
buffer of the scene status.
The bind group provides Scene
holds this uniform buffer.
Shader Example
layout(set = 0, binding = 2) uniform Scene {
float time; // elapsed time since the scene was created.
uint nlights; // the number of lights
};
pub fn scene_bind_group(&self) -> BindGroup
[src]
Creates bind group.
Shader Examples
Suppose binded as set = 0
.
layout(set = 0, binding = 0) uniform Camera {
mat4 camera_matrix; // the camera matrix
mat4 camera_projection; // the projection into the normalized view volume
};
struct Light {
vec4 position; // the position of light, position.w == 1.0
vec4 color; // the color of light, color.w == 1.0
uvec4 light_type; // Point => uvec4(0, 0, 0, 0), Uniform => uvec4(1, 0, 0, 0)
};
layout(set = 0, binding = 1) buffer Lights {
Light lights[];
};
layout(set = 0, binding = 2) uniform Scene {
float time; // elapsed time since the scene was created.
uint nlights; // the number of lights
};
pub fn add_object<R: Rendered>(&mut self, object: &R) -> bool
[src]
Adds a render object to the scene.
If there already exists a render object with the same ID, replaces the render object and returns false.
pub fn add_objects<'a, R, I>(&mut self, objects: I) -> bool where
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
[src]
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
Adds render objects to the scene.
If there already exists a render object with the same ID, replaces the render object and returns false.
pub fn remove_object<R: Rendered>(&mut self, object: &R) -> bool
[src]
Removes a render object from the scene.
If there does not exist the render object in the scene, does nothing and returns false.
pub fn remove_objects<'a, R, I>(&mut self, objects: I) -> bool where
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
[src]
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
Removes render objects from the scene.
If there exists a render object which does not exist in the scene, returns false.
pub fn clear_objects(&mut self)
[src]
Removes all render objects from the scene.
pub fn number_of_objects(&self) -> usize
[src]
Returns the number of the render objects in the scene.
pub fn update_vertex_buffer<R: Rendered>(&mut self, object: &R) -> bool
[src]
Syncronizes the information of vertices of object
in the CPU memory
and that in the GPU memory.
If there does not exist the render object in the scene, does nothing and returns false.
pub fn update_vertex_buffers<'a, R, I>(&mut self, objects: I) -> bool where
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
[src]
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
Syncronizes the information of vertices of objects
in the CPU memory
and that in the GPU memory.
If there exists a render object which does not exist in the scene, returns false.
pub fn update_bind_group<R: Rendered>(&mut self, object: &R) -> bool
[src]
Syncronizes the information of bind group of object
in the CPU memory
and that in the GPU memory.
If there does not exist the render object in the scene, does nothing and returns false.
pub fn update_bind_groups<'a, R, I>(&mut self, objects: I) -> bool where
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
[src]
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
Syncronizes the information of bind group of object
in the CPU memory
and that in the GPU memory.
If there exists a render object which does not exist in the scene, returns false.
pub fn update_pipeline<R: Rendered>(&mut self, object: &R) -> bool
[src]
Syncronizes the information of pipeline of object
in the CPU memory
and that in the GPU memory.
If there does not exist the render object in the scene, does nothing and returns false.
pub fn update_pipelines<'a, R, I>(&mut self, objects: I) -> bool where
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
[src]
R: 'a + Rendered,
I: IntoIterator<Item = &'a R>,
Syncronizes the information of pipeline of object
in the CPU memory
and that in the GPU memory.
If there exists a render object which does not exist in the scene, returns false.
pub fn render_scene(&mut self, view: &TextureView)
[src]
Renders the scene to view
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Scene
impl Send for Scene
impl Sync for Scene
impl Unpin for Scene
impl !UnwindSafe for Scene
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,