#![allow(dead_code)] // use asbestos::{Shader, ShaderProgram}; use buffer::*; use phosphor::*; // use raw_gl_context::GlContext; fn main() { let my_program = MyProgram {}; let mut wm = WindowManager::with_program(my_program); wm.create_window(MainWindow::new()); wm.run() } struct MyProgram {} impl ProgramController for MyProgram {} struct MainWindow { // program: ShaderProgram, } impl MainWindow { pub fn new() -> Box { // let vertex_shader = Shader::vertex(include_str!("vertex.vert")); // let fragment_shader = Shader::fragment(include_str!("fragment.frag")); // let program = ShaderProgram::from_shaders(&[vertex_shader, fragment_shader]); // Box::new(Self { program }) Box::new(Self {}) } } impl WindowController for MainWindow { fn render(&mut self, buffer: &mut Buffer, _: RenderHint) { println!("Rendering..."); buffer.fill(Colour::TEAL); } // fn render_gl(&mut self, _context: &mut GlContext) { // println!("Rendering GL..."); // unsafe { // gl::ClearColor(1.0, 0.0, 1.0, 1.0); // gl::Clear(gl::COLOR_BUFFER_BIT); // } // } } // type Pos = [f32; 2]; // type Color = [f32; 3]; // #[repr(C, packed)] // struct Vertex(Pos, Color); // const VERTICES: [Vertex; 3] = [ // Vertex([-0.5, -0.5], [1.0, 0.0, 0.0]), // Vertex([0.5, -0.5], [0.0, 1.0, 0.0]), // Vertex([0.0, 0.5], [0.0, 0.0, 1.0]) // ]; // pub struct Buffer { // pub id: GLuint, // target: GLuint, // } // impl Buffer { // pub unsafe fn new(target: GLuint) -> Self { // let mut id: GLuint = 0; // gl::GenBuffers(1, &mut id); // Self { id, target } // } // pub unsafe fn bind(&self) { // gl::BindBuffer(self.target, self.id); // } // pub unsafe fn set_data(&self, data: &[D], usage: GLuint) { // self.bind(); // let (_, data_bytes, _) = data.align_to::(); // gl::BufferData( // self.target, // data_bytes.len() as GLsizeiptr, // data_bytes.as_ptr() as *const _, // usage, // ); // } // } // impl Drop for Buffer { // fn drop(&mut self) { // unsafe { // gl::DeleteBuffers(1, [self.id].as_ptr()); // } // } // }