i'm blue dabededabeday

This commit is contained in:
LunarAkai 2025-08-03 19:00:45 +02:00
commit 5a88e1c4c2
6 changed files with 66 additions and 19 deletions

View file

@ -6,8 +6,8 @@ use moonhare_window::glfw::Context;
// adopted from the glium repo -> examples -> manual_creation.rs
#[derive(Clone)]
struct Backend {
gl_window: Rc<RefCell<moonhare_window::glfw::Window>>,
pub struct Backend {
pub gl_window: Rc<RefCell<moonhare_window::glfw::PWindow>>,
}
unsafe impl glium::backend::Backend for Backend {

View file

@ -1,3 +1,32 @@
//! Crate for providing an abstraction layer over different graphics APIs
use std::{cell::RefCell, rc::Rc};
use glium::{backend::Context, Surface};
use moonhare_window::glfw::{PWindow, Window};
pub mod shader;
pub mod backend;
pub mod backend;
pub use glium;
pub fn build_context(window: PWindow) -> Rc<Context>{
let gl_window = Rc::new(RefCell::new(window));
// now building the context
let context = unsafe {
// The first parameter is our backend.
//
// The second parameter tells glium whether or not it should regularly call `is_current`
// on the backend to make sure that the OpenGL context is still the current one.
//
// It is recommended to pass `true`, but you can pass `false` if you are sure that no
// other OpenGL context will be made current in this thread.
let backend = backend::Backend {
gl_window: gl_window,
};
glium::backend::Context::new(backend, true, Default::default())
}
.unwrap();
context
}