considering to become a goose farmer /s
This commit is contained in:
parent
d93d7f10b4
commit
b5fd2a7bd8
7 changed files with 100 additions and 50 deletions
2
moonhare_engine/src/winit/mod.rs
Normal file
2
moonhare_engine/src/winit/mod.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
pub mod winit_window;
|
||||
pub mod window_config;
|
||||
32
moonhare_engine/src/winit/window_config.rs
Normal file
32
moonhare_engine/src/winit/window_config.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
use glium::{backend::glutin::SimpleWindowBuilder, glutin::config::{ConfigTemplate, ConfigTemplateBuilder}, winit::window::WindowAttributes};
|
||||
|
||||
use crate::ENGINE_NAME;
|
||||
|
||||
/// General Config for [`WinitWindow`](crate::winit::winit_window::WinitWindow)
|
||||
pub struct WindowConfig {
|
||||
pub title: &'static str,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub visble: bool,
|
||||
pub decorations: bool,
|
||||
}
|
||||
|
||||
impl Default for WindowConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
title: ENGINE_NAME,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
visble: default_visibility(),
|
||||
decorations: default_decorations(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_visibility() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_decorations() -> bool {
|
||||
true
|
||||
}
|
||||
34
moonhare_engine/src/winit/winit_window.rs
Normal file
34
moonhare_engine/src/winit/winit_window.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
use glium::{backend::glutin::SimpleWindowBuilder, glutin::{display::GetGlDisplay, surface::WindowSurface}, winit::{self, dpi::LogicalSize, event_loop::{ActiveEventLoop, EventLoop}, raw_window_handle::HasDisplayHandle, window::{Window, WindowAttributes}}, Display};
|
||||
|
||||
use crate::winit::window_config::WindowConfig;
|
||||
|
||||
use crate::ENGINE_NAME;
|
||||
|
||||
pub struct WinitWindow {}
|
||||
|
||||
impl WinitWindow {
|
||||
/// constructs a new winit window
|
||||
pub fn construct_window(event_loop: &EventLoop<()>) -> (Window, Display<WindowSurface>) {
|
||||
let config = WindowConfig::default();
|
||||
|
||||
let mut window_attributes = WindowAttributes::default();
|
||||
|
||||
let logical_size = LogicalSize::new(config.width, config.height);
|
||||
window_attributes = window_attributes.with_inner_size(logical_size);
|
||||
window_attributes = window_attributes.with_max_inner_size(logical_size);
|
||||
|
||||
window_attributes = window_attributes.with_title(config.title)
|
||||
.with_fullscreen(None);
|
||||
|
||||
// Set Visible
|
||||
window_attributes = window_attributes.with_visible(true);
|
||||
|
||||
window_attributes = winit::platform::wayland::WindowAttributesExtWayland::with_name(window_attributes, ENGINE_NAME, "");
|
||||
|
||||
SimpleWindowBuilder::new().set_window_builder(window_attributes).build(event_loop)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue