Trait egui_backend::GfxBackend
source · pub trait GfxBackend {
type Configuration: Default;
// Required methods
fn new(
window_backend: &mut impl WindowBackend,
config: Self::Configuration
) -> Self;
fn resize_framebuffer(&mut self, window_backend: &mut impl WindowBackend);
fn prepare_frame(&mut self, window_backend: &mut impl WindowBackend);
fn render_egui(
&mut self,
meshes: Vec<ClippedPrimitive>,
textures_delta: TexturesDelta,
logical_screen_size: [f32; 2]
);
fn present(&mut self, window_backend: &mut impl WindowBackend);
// Provided methods
fn suspend(&mut self, _window_backend: &mut impl WindowBackend) { ... }
fn resume(&mut self, _window_backend: &mut impl WindowBackend) { ... }
}
Expand description
Trait for Gfx backends. these could be Gfx APIs like opengl or vulkan or wgpu etc.. or higher level renderers like three-d or rend3 or custom renderers etc..
Required Associated Types§
sourcetype Configuration: Default
type Configuration: Default
similar to WindowBackendConfig. A custom config struct for the creation of GfxBackend
Required Methods§
sourcefn new(
window_backend: &mut impl WindowBackend,
config: Self::Configuration
) -> Self
fn new( window_backend: &mut impl WindowBackend, config: Self::Configuration ) -> Self
create a new GfxBackend using info from window backend and custom config struct
WindowBackend
trait provides the backend config, which can be used by the renderer to check
for compatibility.
for example, a glow renderer might want an opengl context. but if the window was created without one, the glow renderer should panic.
sourcefn resize_framebuffer(&mut self, window_backend: &mut impl WindowBackend)
fn resize_framebuffer(&mut self, window_backend: &mut impl WindowBackend)
called if framebuffer has been resized. use this to reconfigure your swapchain/surface/viewport..
sourcefn prepare_frame(&mut self, window_backend: &mut impl WindowBackend)
fn prepare_frame(&mut self, window_backend: &mut impl WindowBackend)
prepare the surface / swapchain etc.. by acquiring an image for the current frame.
use WindowBackend::get_live_physical_size_framebuffer
fn to resize your swapchain if it is out of date.
sourcefn render_egui(
&mut self,
meshes: Vec<ClippedPrimitive>,
textures_delta: TexturesDelta,
logical_screen_size: [f32; 2]
)
fn render_egui( &mut self, meshes: Vec<ClippedPrimitive>, textures_delta: TexturesDelta, logical_screen_size: [f32; 2] )
This is where the renderers will start creating renderpasses, issue draw calls etc.. using the data previously prepared.
sourcefn present(&mut self, window_backend: &mut impl WindowBackend)
fn present(&mut self, window_backend: &mut impl WindowBackend)
This is called at the end of the frame. after everything is drawn, you can now present
on opengl, renderer might call WindowBackend::swap_buffers
.
on wgpu / vulkan, renderer might submit commands to queues, present swapchain image etc..
Provided Methods§
sourcefn suspend(&mut self, _window_backend: &mut impl WindowBackend)
fn suspend(&mut self, _window_backend: &mut impl WindowBackend)
Android only. callend on app suspension, which destroys the window.
so, will need to destroy the Surface
and recreate during resume event.
Panic
Panic on other platforms
sourcefn resume(&mut self, _window_backend: &mut impl WindowBackend)
fn resume(&mut self, _window_backend: &mut impl WindowBackend)
Android Only. called when app is resumed after suspension.
On Android, window can only be created on resume event. so, you cannot create a Surface
before entering the event loop.
when this fn is called, we can create a new surface (swapchain) for the window.
doesn’t apply on other platforms.