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
|
//! Base functionality for a Moonhare Game Engine Project
|
||||||
|
|
||||||
use moonhare_log::*;
|
use moonhare_log::*;
|
||||||
use moonhare_window::Window;
|
use moonhare_window::{Window, WindowRenderContext};
|
||||||
|
|
||||||
pub mod basic;
|
pub mod basic;
|
||||||
|
|
||||||
|
|
@ -9,12 +9,14 @@ pub mod basic;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Game {
|
pub struct Game {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub context: WindowRenderContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Game {
|
impl Default for Game {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: default_game_name(),
|
name: default_game_name(),
|
||||||
|
context: WindowRenderContext::OPENGLGTK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,8 +35,7 @@ impl Game {
|
||||||
|
|
||||||
pub fn add_window(&mut self) {
|
pub fn add_window(&mut self) {
|
||||||
moonhare_log::info(format!("Adding window to {:?}", 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)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum WindowRenderContext {
|
pub enum WindowRenderContext {
|
||||||
VULKAN, // TODO
|
VULKANGTK, // TODO
|
||||||
OPENGL,
|
|
||||||
OPENGLGTK,
|
OPENGLGTK,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,7 +32,12 @@ pub struct Window {
|
||||||
impl Window {
|
impl Window {
|
||||||
/// creates a gtk4 window
|
/// creates a gtk4 window
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn create() {
|
pub fn create(context: WindowRenderContext) {
|
||||||
|
match context {
|
||||||
|
WindowRenderContext::VULKANGTK => {
|
||||||
|
todo!()
|
||||||
|
},
|
||||||
|
WindowRenderContext::OPENGLGTK => {
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use gtk4::gio::prelude::ApplicationExtManual;
|
use gtk4::gio::prelude::ApplicationExtManual;
|
||||||
|
|
@ -45,6 +49,9 @@ impl Window {
|
||||||
let application = GTKWindow::init();
|
let application = GTKWindow::init();
|
||||||
application.get_application().run();
|
application.get_application().run();
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[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};
|
use crate::{window_config, MoonhareWindow};
|
||||||
|
|
||||||
|
|
@ -44,7 +44,5 @@ impl MoonhareWindow for GTKWindow {
|
||||||
|
|
||||||
fn shutdown() {
|
fn shutdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue