gtk opengl render context
This commit is contained in:
parent
c65b922a45
commit
636bf2a75f
3 changed files with 24 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
//! Base functionality for a Moonhare Game Engine Project
|
||||
|
||||
use moonhare_log::*;
|
||||
use moonhare_window::Window;
|
||||
use moonhare_window::{Window, WindowRenderContext};
|
||||
|
||||
pub mod basic;
|
||||
|
||||
|
|
@ -9,12 +9,14 @@ pub mod basic;
|
|||
#[derive(Debug)]
|
||||
pub struct Game {
|
||||
pub name: String,
|
||||
pub context: WindowRenderContext,
|
||||
}
|
||||
|
||||
impl Default for Game {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: default_game_name(),
|
||||
context: WindowRenderContext::OPENGLGTK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -33,8 +35,7 @@ impl Game {
|
|||
|
||||
pub fn add_window(&mut self) {
|
||||
moonhare_log::info(format!("Adding window to {:?}", self));
|
||||
Window::create();
|
||||
|
||||
Window::create(self.context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ pub mod platforms;
|
|||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum WindowRenderContext {
|
||||
VULKAN, // TODO
|
||||
OPENGL,
|
||||
VULKANGTK, // TODO
|
||||
OPENGLGTK,
|
||||
}
|
||||
|
||||
|
|
@ -33,18 +32,26 @@ pub struct Window {
|
|||
impl Window {
|
||||
/// creates a gtk4 window
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn create() {
|
||||
use std::thread;
|
||||
pub fn create(context: WindowRenderContext) {
|
||||
match context {
|
||||
WindowRenderContext::VULKANGTK => {
|
||||
todo!()
|
||||
},
|
||||
WindowRenderContext::OPENGLGTK => {
|
||||
use std::thread;
|
||||
|
||||
use gtk4::gio::prelude::ApplicationExtManual;
|
||||
use gtk4::gio::prelude::ApplicationExtManual;
|
||||
|
||||
use crate::platforms::gtk_window::GTKWindow;
|
||||
|
||||
thread::spawn(|| {
|
||||
moonhare_log::info("Created Window thread");
|
||||
let application = GTKWindow::init();
|
||||
application.get_application().run();
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
use crate::platforms::gtk_window::GTKWindow;
|
||||
|
||||
thread::spawn(|| {
|
||||
moonhare_log::info("Created Window thread");
|
||||
let application = GTKWindow::init();
|
||||
application.get_application().run();
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use gtk4::{gio::prelude::ApplicationExt, prelude::{GtkWindowExt, WidgetExt}, Application, ApplicationWindow};
|
||||
use gtk4::{gio::prelude::ApplicationExt, glib, prelude::{GtkWindowExt, WidgetExt}, Application, ApplicationWindow};
|
||||
|
||||
use crate::{window_config, MoonhareWindow};
|
||||
|
||||
|
|
@ -44,7 +44,5 @@ impl MoonhareWindow for GTKWindow {
|
|||
|
||||
fn shutdown() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue