pub struct Renderer {Show 14 fields
pub surface: Option<Surface<'static>>,
pub instance: Instance,
pub adapter: Adapter,
pub device: Device,
pub queue: Queue,
pub config: SurfaceConfiguration<Vec<TextureFormat>>,
pub size: PhysicalSize<u32>,
pub texture_bind_group_layout: BindGroupLayout,
pub default_uniform_bind_group_layout: BindGroupLayout,
pub depth_buffer: (Texture, TextureView, Sampler),
pub default_data: Option<(BindGroup, RenderPipeline, BindGroup)>,
pub camera: Option<BindGroup>,
pub clear_color: Color,
pub scissor_rect: Option<(u32, u32, u32, u32)>,
}Expand description
Main renderer class. this will contain all methods and data related to the renderer
Fields§
§surface: Option<Surface<'static>>A wgpu::Surface represents a platform-specific surface
(e.g. a window) onto which rendered images may be presented.
instance: InstanceContext for all of the gpu objects
adapter: AdapterHandle to a physical graphics and/or compute device.
device: DeviceOpen connection to a graphics and/or compute device.
queue: QueueHandle to a command queue on a device.
config: SurfaceConfiguration<Vec<TextureFormat>>Describes a wgpu::Surface
size: PhysicalSize<u32>The size of the window
texture_bind_group_layout: BindGroupLayoutThe texture bind group layout
default_uniform_bind_group_layout: BindGroupLayoutThe uniform bind group layout
depth_buffer: (Texture, TextureView, Sampler)The depth buffer, used to render object depth
default_data: Option<(BindGroup, RenderPipeline, BindGroup)>The default data used within the renderer
camera: Option<BindGroup>The camera used in the engine
clear_color: ColorBackground clear color
scissor_rect: Option<(u32, u32, u32, u32)>Scissor cut section of the screen to render to (x, y, width, height)
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn build_pipeline(
&mut self,
shader: RenderPipeline,
vertex_buffer: VertexBuffers,
texture: BindGroup,
uniform: Option<BindGroup>,
) -> Pipeline
pub fn build_pipeline( &mut self, shader: RenderPipeline, vertex_buffer: VertexBuffers, texture: BindGroup, uniform: Option<BindGroup>, ) -> Pipeline
Creates a new render pipeline. Could be thought of as like materials in game engines.
Sourcepub fn build_shader(
&mut self,
name: impl StringBuffer,
shader_source: String,
uniform_layout: Option<&BindGroupLayout>,
settings: ShaderSettings,
) -> RenderPipeline
pub fn build_shader( &mut self, name: impl StringBuffer, shader_source: String, uniform_layout: Option<&BindGroupLayout>, settings: ShaderSettings, ) -> RenderPipeline
Creates a shader group, the input must be spir-v compiled vertex and fragment shader
Sourcepub fn build_texture(
&mut self,
name: impl StringBuffer,
texture_data: TextureData,
texture_mode: TextureMode,
) -> Result<BindGroup, Error>
pub fn build_texture( &mut self, name: impl StringBuffer, texture_data: TextureData, texture_mode: TextureMode, ) -> Result<BindGroup, Error>
Creates a new texture data
Sourcepub fn build_uniform_buffer_part<T>(
&self,
name: impl StringBuffer,
value: T,
) -> Buffer
pub fn build_uniform_buffer_part<T>( &self, name: impl StringBuffer, value: T, ) -> Buffer
Creates a new uniform buffer part
This function doesn’t build the entire uniform buffers list, but rather only one of them
Sourcepub fn build_uniform_buffer(
&mut self,
uniforms: &[Buffer],
) -> (BindGroup, BindGroupLayout)
pub fn build_uniform_buffer( &mut self, uniforms: &[Buffer], ) -> (BindGroup, BindGroupLayout)
Creates a new uniform buffer group, according to a list of types
Sourcepub fn build_vertex_buffer(
&mut self,
vertices: &Vec<Vertex>,
indices: &Vec<u16>,
) -> VertexBuffers
pub fn build_vertex_buffer( &mut self, vertices: &Vec<Vertex>, indices: &Vec<u16>, ) -> VertexBuffers
Creates a new vertex buffer and indices
Sourcepub fn build_instance(&self, instance_data: Vec<InstanceRaw>) -> Buffer
pub fn build_instance(&self, instance_data: Vec<InstanceRaw>) -> Buffer
Creates a new instance buffer for the object
Source§impl Renderer
Defines full axes rotation information
impl Renderer
Defines full axes rotation information
Sourcepub fn build_object(
&mut self,
name: impl StringBuffer,
vertices: Vec<Vertex>,
indices: Vec<u16>,
settings: ObjectSettings,
) -> Result<Object, Error>
pub fn build_object( &mut self, name: impl StringBuffer, vertices: Vec<Vertex>, indices: Vec<u16>, settings: ObjectSettings, ) -> Result<Object, Error>
Creates a new object
Is used to define a new object and add it to the storage. This offers full customizability and a framework for in-engine shapes to be developed.
§Arguments
name- The name of the object.vertices- A list of vertices for the object to draw withindices- A list of indices that references the vertices, defining draw ordersettings- The settings of the object
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl Unpin for Renderer
impl !UnwindSafe for Renderer
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
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more