i'm blue dabededabeday
This commit is contained in:
parent
f5e9bca56b
commit
5a88e1c4c2
6 changed files with 66 additions and 19 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue