Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Extract window_wrapper and the update loop to their own modules #1939

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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