pub struct Renderer { /* private fields */ }
wgpu
only.Expand description
Renders a scene into a texture or surface.
Currently, each renderer only supports a single surface format, if it supports drawing to surfaces at all. This is an assumption which is known to be limiting, and is planned to change.
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn new(device: &Device, options: RendererOptions) -> Result<Self, Error>
pub fn new(device: &Device, options: RendererOptions) -> Result<Self, Error>
Creates a new renderer for the specified device.
Sourcepub fn render_to_texture(
&mut self,
device: &Device,
queue: &Queue,
scene: &Scene,
texture: &TextureView,
params: &RenderParams,
) -> Result<(), Error>
pub fn render_to_texture( &mut self, device: &Device, queue: &Queue, scene: &Scene, texture: &TextureView, params: &RenderParams, ) -> Result<(), Error>
Renders a scene to the target texture.
The texture is assumed to be of the specified dimensions and have been created with
the wgpu::TextureFormat::Rgba8Unorm
format and the wgpu::TextureUsages::STORAGE_BINDING
flag set.
If you want to render Vello content to a surface (such as in a UI toolkit), you have two options:
- Render to an intermediate texture, which is the same size as the surface.
You would then use
TextureBlitter
to blit the rendered result from that texture to the surface. This pattern is supported by theutil
module. - Call
render_to_texture
directly on theSurfaceTexture
’s texture, if it has the right usages. This should generally be avoided, as some GPUs assume that you will not be rendering to the surface using a compute pipeline, and optimise accordingly.
Sourcepub fn override_image(
&mut self,
image: &Image,
texture: Option<TexelCopyTextureInfoBase<Texture>>,
) -> Option<TexelCopyTextureInfoBase<Texture>>
pub fn override_image( &mut self, image: &Image, texture: Option<TexelCopyTextureInfoBase<Texture>>, ) -> Option<TexelCopyTextureInfoBase<Texture>>
Overwrite image
with texture
.
Whenever image
would be rendered, instead the given Texture
will be used.
Correct behaviour is not guaranteed if the texture does not have the same dimensions as the image, nor if an image which uses the same data but different dimensions would be rendered.