You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I have been experimenting with Vello. As an initial project I decided to make an app with one circle at top.
Getting started, I realized that the Renderer can not render empty scenes or scenes with empty fragments added on the surface. However, if add fragment filled with circle into scene, scene would be rendered. This error also occurs when scene fragment added when creating window(fn new() called).
Where am I wrong, is it bug?
Error
Everything works fine if you uncomment these lines:
// let mut builder = SceneBuilder::for_scene(&mut self.scene);// builder.append(&self.fragment, None);
Code
#![allow(warnings, unused)]use glazier::{Application,WinHandler,WindowBuilder,WindowHandle,Scalable};use glazier::kurbo::{self,Affine,Circle,Point};use tokio::runtime::Runtime;use vello::peniko::{Color,BrushRef};use vello::{Renderer,RendererOptions,Scene,SceneBuilder,SceneFragment,RenderParams};use vello::util::{RenderContext,RenderSurface,DeviceHandle};structMainWin{handle:WindowHandle,rt:Runtime,renderer:Option<Renderer>,render_ctx:RenderContext,surface:Option<RenderSurface>,scene:Scene,fragment:SceneFragment,}implMainWin{fnnew() -> Self{letmut fragment = SceneFragment::default();// Fill scene fragment with circleSceneBuilder::for_fragment(&mut fragment).fill(
vello::peniko::Fill::EvenOdd,Affine::IDENTITY,BrushRef::Solid(Color::AQUA),None,&Circle::new(Point::new(50.0,50.0),20.0));let scene = Scene::default();// Error remains even after adding scene fragment.// SceneBuilder::for_scene(&mut self.scene)// .append(&self.fragment, None);Self{handle:WindowHandle::default(),rt:Runtime::new().unwrap(),renderer:None,render_ctx:RenderContext::new().unwrap(),surface:None,
scene,
fragment
}}}implWinHandlerforMainWin{fnconnect(&mutself,handle:&glazier::WindowHandle){self.handle = handle.clone();SceneBuilder::for_scene(&mutself.scene);}fnprepare_paint(&mutself){}fnpaint(&mutself,_invalid:&glazier::Region){// Create surface ifself.surface.is_none(){let kurbo::Size{ width, height } = self.handle.get_size();let surface = self.rt.block_on(self.render_ctx.create_surface(&self.handle, width asu32, height asu32)).unwrap();let dev_id = surface.dev_id;letDeviceHandle{ device, queue, .. } = &self.render_ctx.devices[dev_id];self.renderer = Some(Renderer::new(&device,&RendererOptions{surface_format:Some(surface.format),timestamp_period: queue.get_timestamp_period(),}).unwrap());self.surface = Some(surface);}// get window dimensionslet(width, height) = {let handle = &self.handle;let scale = handle.get_scale().unwrap_or_default();let insets = handle.content_insets().to_px(scale);let size = handle.get_size().to_px(scale);((size.width - insets.x_value())asu32,(size.height - insets.y_value())asu32)};ifletSome(surface) = &mutself.surface{// Resize surface if neededif surface.config.width != width || surface.config.height != height {self.render_ctx.resize_surface(surface, width, height);}// Append fragment with circle// Everything is file until scene has some fragment added// let mut builder = SceneBuilder::for_scene(&mut self.scene);// builder.append(&self.fragment, None);let surface_texture = surface
.surface.get_current_texture().expect("failed to acquire next swapchain texture");letDeviceHandle{ device, queue, .. } =
&self.render_ctx.devices[surface.dev_id];let renderer_options = RendererOptions{surface_format:Some(surface.format),timestamp_period: queue.get_timestamp_period(),};let render_params = RenderParams{base_color:Color::BLACK,
width,
height,};// Render empty scene to surfaceself.renderer.get_or_insert_with(|| Renderer::new(device,&renderer_options).unwrap()).render_to_surface(device, queue,&self.scene,&surface_texture,&render_params).expect("failed to render to surface");
surface_texture.present();
device.poll(wgpu::Maintain::Wait);}}fnas_any(&mutself) -> &mutdyn std::any::Any{self}fnrequest_close(&mutself){self.handle.close();Application::global().quit();}}fnmain(){let app = Application::new().unwrap();let win = WindowBuilder::new(app.clone()).handler(Box::new(MainWin::new())).resizable(false).build().unwrap();
win.show();
app.run(None);}
The text was updated successfully, but these errors were encountered:
Intro
Recently I have been experimenting with Vello. As an initial project I decided to make an app with one circle at top.
Getting started, I realized that the Renderer can not render empty scenes or scenes with empty fragments added on the surface. However, if add fragment filled with circle into scene, scene would be rendered. This error also occurs when scene fragment added when creating window(
fn new()
called).Where am I wrong, is it bug?
Error
Everything works fine if you uncomment these lines:
Code
The text was updated successfully, but these errors were encountered: