hmm
This commit is contained in:
parent
e48fff45f0
commit
2673a31b81
5 changed files with 37 additions and 14 deletions
|
|
@ -11,6 +11,9 @@ impl World {
|
||||||
Self { nodes: vec![] }
|
Self { nodes: vec![] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_nodes(self) -> Vec<Box<dyn Node>> {
|
||||||
|
self.nodes
|
||||||
|
}
|
||||||
pub fn add_node(&mut self, node: Box<dyn Node>) {
|
pub fn add_node(&mut self, node: Box<dyn Node>) {
|
||||||
self.nodes.push(node)
|
self.nodes.push(node)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,19 +26,34 @@ impl Default for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
fn init(&mut self) -> Self {
|
pub fn init(&mut self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
context: moonhare_window::WindowRenderContext::OPENGLGLFW,
|
context: moonhare_window::WindowRenderContext::OPENGLGLFW,
|
||||||
glfw_window: Some(moonhare_window::Window::create(self.context)),
|
glfw_window: Some(moonhare_window::Window::create(self.context)),
|
||||||
render_context: Some(moonhare_graphics::build_context(
|
render_context: match self.glfw_window {
|
||||||
self.glfw_window.clone().unwrap().glfw_window,
|
Some(window) => Some(moonhare_graphics::build_context(Box::new(window))),
|
||||||
)),
|
None => moonhare_log::error("No window"),
|
||||||
|
},
|
||||||
|
//Some(moonhare_graphics::build_context(
|
||||||
|
// self.glfw_window.clone().unwrap().glfw_window,
|
||||||
|
//)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn check_integ(&self) {
|
||||||
|
println!("{:?}, {:?}", self.context, self.glfw_window)
|
||||||
|
}
|
||||||
|
|
||||||
fn update(&mut self) {
|
fn update(&mut self) {
|
||||||
handle_window_event(&self.glfw_window.as_mut().unwrap());
|
match &self.glfw_window {
|
||||||
render(self.render_context.clone().unwrap());
|
Some(window) => handle_window_event(&window),
|
||||||
|
None => moonhare_log::warn("No Window!"),
|
||||||
|
}
|
||||||
|
|
||||||
|
match &self.render_context {
|
||||||
|
Some(context) => render(context.clone()),
|
||||||
|
None => moonhare_log::warn("No Render Context"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ use std::{
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use glium::SwapBuffersError;
|
use glium::{SwapBuffersError, winit::window::Window};
|
||||||
use moonhare_window::glfw::Context;
|
use moonhare_window::glfw::Context;
|
||||||
|
|
||||||
// adopted from the glium repo -> examples -> manual_creation.rs
|
// adopted from the glium repo -> examples -> manual_creation.rs
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Backend {
|
pub struct Backend {
|
||||||
pub gl_window: Rc<RefCell<moonhare_window::glfw::PWindow>>,
|
pub gl_window: Rc<RefCell<Box<Window>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl glium::backend::Backend for Backend {
|
unsafe impl glium::backend::Backend for Backend {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use std::{
|
||||||
use glium::{
|
use glium::{
|
||||||
Frame, Surface,
|
Frame, Surface,
|
||||||
backend::{Context, Facade},
|
backend::{Context, Facade},
|
||||||
|
winit::window::Window,
|
||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use moonhare_window::glfw::PWindow;
|
use moonhare_window::glfw::PWindow;
|
||||||
|
|
@ -21,8 +22,8 @@ use state::InitCell;
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
|
||||||
pub fn build_context(window: Rc<RefCell<PWindow>>) -> Rc<Context> {
|
pub fn build_context(window: Rc<RefCell<Box<Window>>>) -> Rc<Context> {
|
||||||
let gl_window: Rc<RefCell<PWindow>> = window;
|
let gl_window = window;
|
||||||
// now building the context
|
// now building the context
|
||||||
|
|
||||||
let context = unsafe {
|
let context = unsafe {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::fs::File;
|
use std::{any::Any, fmt::format, fs::File};
|
||||||
|
|
||||||
use moonhare_engine::{
|
use moonhare_engine::{
|
||||||
game::{Game, basic::world::World, nodes::window::Window},
|
game::{Game, basic::world::World, nodes::window::Window},
|
||||||
|
|
@ -7,13 +7,17 @@ use moonhare_engine::{
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = log::configere_logger();
|
let _ = log::configere_logger();
|
||||||
log::info("test");
|
|
||||||
|
|
||||||
let mut game = Game::new();
|
let mut game = Game::new();
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
|
|
||||||
let window = Window::default();
|
let mut window = Window::default();
|
||||||
|
window = Window::init(&mut window);
|
||||||
|
window.check_integ();
|
||||||
world.add_node(Box::new(window));
|
world.add_node(Box::new(window));
|
||||||
game.add_world(world.clone());
|
game.add_world(world.clone());
|
||||||
log::info(format!("{:?}", game.get_worlds()));
|
log::info(format!("{:?}", game));
|
||||||
|
log::info(format!("Nodes: {:#?}", world.get_nodes().type_id()));
|
||||||
|
|
||||||
|
game.run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue