diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2023-10-11 08:21:10 +1300 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2023-10-11 08:21:10 +1300 |
commit | 8e08d723ff7a853f2b10dc0f1408911d5801cea8 (patch) | |
tree | 50efd2967e93f8bc1009f242a405ec18335f0aa6 /src/bin/phosphor_test.rs | |
parent | a6e97019bd53e4478c846f8f636c18ecb53bece2 (diff) | |
download | phosphor-8e08d723ff7a853f2b10dc0f1408911d5801cea8.zip |
Rewrite phosphor
This has been a long-awaited task, the code has been accumulating small
changes for a while now. This commit consolidates all these changes in
order to make the code more readable and maintainable for the future.
Notable changes:
- Remove the concept of a ProgramController
- Remove all of the dead OpenGL stub code
- Update winit to version 28.1, from 27.4
- Use softbuffer for writing pixels to the native display server
Diffstat (limited to 'src/bin/phosphor_test.rs')
-rw-r--r-- | src/bin/phosphor_test.rs | 97 |
1 files changed, 22 insertions, 75 deletions
diff --git a/src/bin/phosphor_test.rs b/src/bin/phosphor_test.rs index 40a8558..c3b307d 100644 --- a/src/bin/phosphor_test.rs +++ b/src/bin/phosphor_test.rs @@ -1,89 +1,36 @@ -#![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()); + let mut wm = WindowManager::new(std::time::Duration::from_micros(16666)); + wm.add_window(Box::new(Window {})); wm.run() } -struct MyProgram {} -impl ProgramController for MyProgram {} - -struct MainWindow { - // program: ShaderProgram, -} -impl MainWindow { - pub fn new() -> Box<Self> { - // 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 {}) +struct Window {} +impl WindowController for Window { + fn minimum_size(&self) -> Option<phosphor::Dimensions> { + Some(phosphor::Dimensions::new(200, 200)) } -} -impl WindowController for MainWindow { - fn render(&mut self, buffer: &mut Buffer, _: RenderHint) { - println!("Rendering..."); - buffer.fill(Colour::TEAL); + fn maximum_size(&self) -> Option<phosphor::Dimensions> { + Some(phosphor::Dimensions::new(400, 400)) } - // 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]) -// ]; + fn render_request(&self) -> RenderRequest { + RenderRequest::None + } -// 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 } -// } + fn is_resizable(&self) -> bool { + false + } -// pub unsafe fn bind(&self) { -// gl::BindBuffer(self.target, self.id); -// } + fn on_resize(&mut self, size: phosphor::Dimensions) { + println!("RESIZE: {size:?}"); + } -// pub unsafe fn set_data<D>(&self, data: &[D], usage: GLuint) { -// self.bind(); -// let (_, data_bytes, _) = data.align_to::<u8>(); -// gl::BufferData( -// self.target, -// data_bytes.len() as GLsizeiptr, -// data_bytes.as_ptr() as *const _, -// usage, -// ); -// } -// } + fn on_render(&mut self, buffer: &mut Buffer, _: RenderHint) { + println!("RENDER"); + buffer.fill(Colour::TEAL); + } +} -// impl Drop for Buffer { -// fn drop(&mut self) { -// unsafe { -// gl::DeleteBuffers(1, [self.id].as_ptr()); -// } -// } -// } |