pub struct CandlManager<W: CandlWindow, S> { /* private fields */ }Expand description
The window manager
Second core element of this lib, the CandlManager is the tool to bring
all your app’s windows under its command. It’s main purpose is to remove
the burden of OpenGL contexts swapping, and a way to easily manage multiple
windows in a application. Its usage is pretty simple:
- create it
- insert new window in it
- call
get_current()to swap contexts and get the window you can work with - done
Check the candelabre examples to see it in action.
Implementations§
Source§impl<W: CandlWindow> CandlManager<W, ()>
impl<W: CandlWindow> CandlManager<W, ()>
Source§impl<R, D, M, S> CandlManager<CandlSurface<R, D, M>, S>where
R: CandlRenderer<R, D, M>,
D: CandlUpdate<M>,
impl<R, D, M, S> CandlManager<CandlSurface<R, D, M>, S>where
R: CandlRenderer<R, D, M>,
D: CandlUpdate<M>,
Sourcepub fn create_window_from_builder<T>(
&mut self,
builder: CandlSurfaceBuilder<'_, R, D, M>,
el: &EventLoopWindowTarget<T>,
) -> Result<WindowId, CandlError>
pub fn create_window_from_builder<T>( &mut self, builder: CandlSurfaceBuilder<'_, R, D, M>, el: &EventLoopWindowTarget<T>, ) -> Result<WindowId, CandlError>
create a new window from a CandlSurfaceBuilder
Sourcepub fn create_window_with_state<T>(
&mut self,
el: &EventLoopWindowTarget<T>,
video_mode: VideoMode,
dim: CandlDimension,
title: &str,
options: CandlOptions,
render: R,
init_state: D,
) -> Result<WindowId, CandlError>
pub fn create_window_with_state<T>( &mut self, el: &EventLoopWindowTarget<T>, video_mode: VideoMode, dim: CandlDimension, title: &str, options: CandlOptions, render: R, init_state: D, ) -> Result<WindowId, CandlError>
create a new window with surface associated state type
Source§impl<W: CandlWindow, S> CandlManager<W, S>
impl<W: CandlWindow, S> CandlManager<W, S>
Sourcepub fn create_window<T, E: CandlElement<W>>(
&mut self,
el: &EventLoopWindowTarget<T>,
video_mode: VideoMode,
dim: CandlDimension,
title: &str,
options: CandlOptions,
) -> Result<WindowId, CandlError>
pub fn create_window<T, E: CandlElement<W>>( &mut self, el: &EventLoopWindowTarget<T>, video_mode: VideoMode, dim: CandlDimension, title: &str, options: CandlOptions, ) -> Result<WindowId, CandlError>
create a new window, tracked by the manager
For internal reason, it isn’t possible to add a CandlSurface manually
created to the manager, it’s mandatory to use the create_window()
method instead.
This method is the most basic one, creating a surface with no state associated.
WARNING : the first surface created with the manager decide of all the surfaces state type of the manager, it isn’t in the scope of this lib to handle the complexity of multiple state type across an hashmap of surfaces.
Sourcepub fn new_with_state(init_state: S) -> Self
pub fn new_with_state(init_state: S) -> Self
constructor for the manager with state type link to it
Sourcepub fn list_window_ids(&self) -> Vec<WindowId>
pub fn list_window_ids(&self) -> Vec<WindowId>
vector with all the WindowId managed by the CandlManager
Sourcepub fn remove_window(&mut self, id: WindowId)
pub fn remove_window(&mut self, id: WindowId)
remove a window from the manager
If you don’t call this method after closing a window, the OpenGL context continue to exist, and can lead to memory leaks.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
check if there is still living windows, or if the manager is empty
The purpose of this method is to check if the application can be close, from an OpenGL perspective.
Sourcepub fn get_current(&mut self, id: WindowId) -> Result<&mut W, CandlError>
pub fn get_current(&mut self, id: WindowId) -> Result<&mut W, CandlError>
get a mutable reference to the current surface
This method is the most important of the manager. At first, there is a check for the asked window to see if it’s the current one, and if not the method try to swap the OpenGL contexts to make the asked window current, and make the old current context not current.