Skip to content

Commit

Permalink
Extract window_wrapper and the update loop to their own modules
Browse files Browse the repository at this point in the history
  • Loading branch information
fredizzimo committed Jul 24, 2023
1 parent eeac6e7 commit b17fa15
Show file tree
Hide file tree
Showing 5 changed files with 573 additions and 480 deletions.
2 changes: 1 addition & 1 deletion src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub use rendered_window::{
LineFragment, RenderedWindow, WindowDrawCommand, WindowDrawDetails, WindowPadding,
};

pub use opengl::{build_context, Context as WindowedContext};
pub use opengl::{build_context, build_window, Context as WindowedContext};

#[derive(SettingGroup, Clone)]
pub struct RendererSettings {
Expand Down
13 changes: 9 additions & 4 deletions src/renderer/opengl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,25 @@ fn gen_config(mut config_iterator: Box<dyn Iterator<Item = Config> + '_>) -> Con
config_iterator.next().unwrap()
}

pub fn build_context<TE>(
cmd_line_settings: &CmdLineSettings,
pub fn build_window<TE>(
winit_window_builder: WindowBuilder,
event_loop: &EventLoop<TE>,
) -> Context {
) -> (Window, Config) {
let template_builder = ConfigTemplateBuilder::new()
.with_stencil_size(8)
.with_transparency(true);
let (window, config) = DisplayBuilder::new()
.with_window_builder(Some(winit_window_builder))
.build(event_loop, template_builder, gen_config)
.expect("Failed to create Window");
let window = window.expect("Could not create Window");
(window.expect("Could not create Window"), config)
}

pub fn build_context(
window: Window,
config: Config,
cmd_line_settings: &CmdLineSettings,
) -> Context {
let gl_display = config.display();
let raw_window_handle = window.raw_window_handle();

Expand Down

0 comments on commit b17fa15

Please sign in to comment.