damn, rust borrow checker got tamed >:3
This commit is contained in:
parent
1c75b7ac87
commit
78b5348b92
2 changed files with 18 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::sync::Arc;
|
||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||
|
||||
use glfw::{Context, Glfw, GlfwReceiver, PWindow, Window, WindowEvent};
|
||||
use moonhare_event::{event::Event, events::window_events::window_close_event::WindowCloseEvent};
|
||||
|
|
@ -7,14 +7,20 @@ use crate::{window_config, MoonhareWindow};
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct GLFWWindow {
|
||||
pub glfw_window: PWindow,
|
||||
pub events: GlfwReceiver<(f64, WindowEvent)>,
|
||||
pub glfw_window: Rc<RefCell<PWindow>>,
|
||||
pub events: Rc<RefCell<GlfwReceiver<(f64, WindowEvent)>>>,
|
||||
pub glfw: Glfw,
|
||||
pub is_running: bool,
|
||||
}
|
||||
|
||||
const APP_ID: &str = "de.lunarakai.moonhare_engine";
|
||||
|
||||
impl Clone for GLFWWindow {
|
||||
fn clone(&self) -> Self {
|
||||
Self { glfw_window: self.glfw_window.clone(), events: self.events.clone(), glfw: self.glfw.clone(), is_running: self.is_running.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
impl GLFWWindow {
|
||||
fn new() -> Self {
|
||||
let mut glfw = glfw::init(glfw::fail_on_errors).unwrap();
|
||||
|
|
@ -30,8 +36,8 @@ impl GLFWWindow {
|
|||
window.make_current();
|
||||
|
||||
Self {
|
||||
glfw_window: window.try_into().unwrap(),
|
||||
events: events,
|
||||
glfw_window: Rc::new(RefCell::new(window)),
|
||||
events: Rc::new(RefCell::new(events)),
|
||||
glfw: glfw,
|
||||
is_running: true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue