pub struct WindowScene { /* private fields */ }Expand description
Utility for wrapper
Implementations§
Source§impl WindowScene
impl WindowScene
Sourcepub async fn from_window(
window: Arc<Window>,
scene_desc: &WindowSceneDescriptor,
) -> Self
pub async fn from_window( window: Arc<Window>, scene_desc: &WindowSceneDescriptor, ) -> Self
Initialize scene compatible with window.
Sourcepub fn size_alignment(&mut self)
pub fn size_alignment(&mut self)
Adjusts the size of the backend buffers (depth or sampling buffer) to the size of the window.
Sourcepub fn render_frame(&mut self)
pub fn render_frame(&mut self)
Render scene to initializing window.
Methods from Deref<Target = Scene>§
Sourcepub fn compatible_texture(&self) -> Texture
pub fn compatible_texture(&self) -> Texture
Creates compatible texture for render attachment.
§Remarks
The usage of texture is TextureUsages::RENDER_ATTACHMENT | TetureUsages::COPY_SRC.
Sourcepub fn device_handler(&self) -> &DeviceHandler
pub fn device_handler(&self) -> &DeviceHandler
Returns the reference of its own DeviceHandler.
Sourcepub fn descriptor(&self) -> &SceneDescriptor
pub fn descriptor(&self) -> &SceneDescriptor
Returns the reference of the descriptor.
Sourcepub fn descriptor_mut(&mut self) -> SceneDescriptorMut<'_>
pub fn descriptor_mut(&mut self) -> SceneDescriptorMut<'_>
Returns the mutable reference of the descriptor.
§Remarks
When the return value is dropped, the depth buffer and sampling buffer are automatically updated.
Use studio_config_mut if you only want to update the colors of the camera, lights, and background.
Sourcepub fn studio_config(&self) -> &StudioConfig
pub fn studio_config(&self) -> &StudioConfig
Returns the reference of the studio configuration.
Sourcepub fn studio_config_mut(&mut self) -> &mut StudioConfig
pub fn studio_config_mut(&mut self) -> &mut StudioConfig
Returns the mutable reference of the studio configuration.
Sourcepub fn bind_group_layout(&self) -> &BindGroupLayout
pub fn bind_group_layout(&self) -> &BindGroupLayout
Returns the bind group layout in the scene.
Sourcepub fn camera_buffer(&self) -> BufferHandler
pub fn camera_buffer(&self) -> BufferHandler
Sourcepub fn lights_buffer(&self) -> BufferHandler
pub fn lights_buffer(&self) -> BufferHandler
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
};Sourcepub fn scene_status_buffer(&self) -> BufferHandler
pub fn scene_status_buffer(&self) -> BufferHandler
Sourcepub fn scene_bind_group(&self) -> BindGroup
pub fn scene_bind_group(&self) -> BindGroup
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
};Sourcepub fn add_object<R: Rendered>(&mut self, object: &R) -> bool
pub fn add_object<R: Rendered>(&mut self, object: &R) -> bool
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.
Sourcepub fn set_visibility<R: Rendered>(&mut self, object: &R, visible: bool) -> bool
pub fn set_visibility<R: Rendered>(&mut self, object: &R, visible: bool) -> bool
Sets the visibility of a render object.
If there does not exist the render object in the scene, does nothing and returns false.
Sourcepub fn add_objects<'a, R, I>(&mut self, objects: I) -> bool
pub fn add_objects<'a, R, I>(&mut self, objects: I) -> bool
Adds render objects to the scene.
If there already exists a render object with the same ID, replaces the render object and returns false.
Sourcepub fn remove_object<R: Rendered>(&mut self, object: &R) -> bool
pub fn remove_object<R: Rendered>(&mut self, object: &R) -> bool
Removes a render object from the scene.
If there does not exist the render object in the scene, does nothing and returns false.
Sourcepub fn remove_objects<'a, R, I>(&mut self, objects: I) -> bool
pub fn remove_objects<'a, R, I>(&mut self, objects: I) -> bool
Removes render objects from the scene.
If there exists a render object which does not exist in the scene, returns false.
Sourcepub fn clear_objects(&mut self)
pub fn clear_objects(&mut self)
Removes all render objects from the scene.
Sourcepub fn number_of_objects(&self) -> usize
pub fn number_of_objects(&self) -> usize
Returns the number of the render objects in the scene.
Sourcepub fn update_vertex_buffer<R: Rendered>(&mut self, object: &R) -> bool
pub fn update_vertex_buffer<R: Rendered>(&mut self, object: &R) -> bool
Synchronizes 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.
Sourcepub fn update_vertex_buffers<'a, R, I>(&mut self, objects: I) -> bool
pub fn update_vertex_buffers<'a, R, I>(&mut self, objects: I) -> bool
Synchronizes 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.
Sourcepub fn update_bind_group<R: Rendered>(&mut self, object: &R) -> bool
pub fn update_bind_group<R: Rendered>(&mut self, object: &R) -> bool
Synchronizes 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.
Sourcepub fn update_bind_groups<'a, R, I>(&mut self, objects: I) -> bool
pub fn update_bind_groups<'a, R, I>(&mut self, objects: I) -> bool
Synchronizes 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.
Sourcepub fn update_pipeline<R: Rendered>(&mut self, object: &R) -> bool
pub fn update_pipeline<R: Rendered>(&mut self, object: &R) -> bool
Synchronizes 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.
Sourcepub fn update_pipelines<'a, R, I>(&mut self, objects: I) -> bool
pub fn update_pipelines<'a, R, I>(&mut self, objects: I) -> bool
Synchronizes 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.
Sourcepub fn render(&self, view: &TextureView)
pub fn render(&self, view: &TextureView)
Renders the scene to view.
Sourcepub async fn render_to_buffer(&self) -> Vec<u8> ⓘ
pub async fn render_to_buffer(&self) -> Vec<u8> ⓘ
Render image to buffer.
Trait Implementations§
Source§impl Debug for WindowScene
impl Debug for WindowScene
Source§impl Deref for WindowScene
impl Deref for WindowScene
Auto Trait Implementations§
impl !RefUnwindSafe for WindowScene
impl !UnwindSafe for WindowScene
impl Freeze for WindowScene
impl Send for WindowScene
impl Sync for WindowScene
impl Unpin for WindowScene
impl UnsafeUnpin for WindowScene
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.