From a6e97019bd53e4478c846f8f636c18ecb53bece2 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 10 Oct 2023 14:56:04 +1300 Subject: First commit, before upgrading winit to version 28.1 --- src/bin/phosphor_test.rs | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/bin/phosphor_test.rs (limited to 'src/bin/phosphor_test.rs') diff --git a/src/bin/phosphor_test.rs b/src/bin/phosphor_test.rs new file mode 100644 index 0000000..40a8558 --- /dev/null +++ b/src/bin/phosphor_test.rs @@ -0,0 +1,89 @@ +#![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()); +// } +// } +// } -- cgit v1.2.3-70-g09d2