gtk window
This commit is contained in:
parent
30ff2325f2
commit
0c3a160dd5
12 changed files with 437 additions and 1714 deletions
|
|
@ -1,70 +1,3 @@
|
|||
use moonhare_window::{window_config, MoonhareWindow};
|
||||
use moonhare_window::{window_config, MoonhareWindow, WindowResult};
|
||||
|
||||
use crate::{basic::node::Node, Game};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct GameWindow {
|
||||
pub title: &'static str,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub visble: bool,
|
||||
pub decorations: bool,
|
||||
pub winit_window: Option<MoonhareWindow>,
|
||||
}
|
||||
|
||||
impl Node for GameWindow {
|
||||
}
|
||||
|
||||
impl Default for GameWindow {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
title: "window",
|
||||
width: default_game_window_width(),
|
||||
height: default_game_window_height(),
|
||||
visble: default_game_window_visibility(),
|
||||
decorations: default_game_window_decorations(),
|
||||
winit_window: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GameWindow {
|
||||
pub fn create() -> Self {
|
||||
let mut window_config = window_config::WindowConfig::default();
|
||||
moonhare_log::info(format!("creating window with config {:?}", window_config));
|
||||
let mut window = Self::default();
|
||||
window_config.title = window.title.to_owned();
|
||||
window_config.width = window.width;
|
||||
window_config.height = window.height;
|
||||
window_config.visble = window.visble;
|
||||
window_config.decorations = window.decorations;
|
||||
|
||||
let _w = moonhare_window::MoonhareWindow::define_context(moonhare_window::WindowRenderContext::OPENGL);
|
||||
_w.create_window_from_context();
|
||||
|
||||
window.winit_window = Some(_w);
|
||||
// todo: tell winit to create a window for us
|
||||
moonhare_log::info(format!("created window {:?}", window));
|
||||
window
|
||||
}
|
||||
}
|
||||
|
||||
fn default_game_window_title() -> String {
|
||||
"Moonhare Engine".to_owned()
|
||||
}
|
||||
|
||||
fn default_game_window_width() -> u32 {
|
||||
1280
|
||||
}
|
||||
|
||||
fn default_game_window_height() -> u32 {
|
||||
720
|
||||
}
|
||||
|
||||
fn default_game_window_visibility() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_game_window_decorations() -> bool {
|
||||
true
|
||||
}
|
||||
|
|
@ -1,22 +1,20 @@
|
|||
//! Base functionality for a Moonhare Game Engine Project
|
||||
|
||||
use moonhare_log::*;
|
||||
use moonhare_window::Window;
|
||||
|
||||
use crate::basic::game_window::GameWindow;
|
||||
pub mod basic;
|
||||
|
||||
/// Only one Game may exist per project
|
||||
#[derive(Debug)]
|
||||
pub struct Game {
|
||||
pub name: String,
|
||||
pub primary_window: Option<GameWindow>,
|
||||
}
|
||||
|
||||
impl Default for Game {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: default_game_name(),
|
||||
primary_window: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,10 +33,7 @@ impl Game {
|
|||
|
||||
pub fn add_window(&mut self) {
|
||||
moonhare_log::info(format!("Adding window to {:?}", self));
|
||||
if self.primary_window.is_none() {
|
||||
moonhare_log::trace("Primary Window is none");
|
||||
self.primary_window = Some(GameWindow::create());
|
||||
}
|
||||
Window::create();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue