diff --git a/report/images/5_triangles.png b/report/images/5_triangles.png new file mode 100644 index 0000000..7217eca Binary files /dev/null and b/report/images/5_triangles.png differ diff --git a/src/main.rs b/src/main.rs index 34ea73e..d22022b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,20 +59,7 @@ fn offset(n: u32) -> *const c_void { // Get a null pointer (equivalent to an offset of 0) // ptr::null() -// == // Generate your VAO here unsafe fn create_vao(vertices: &Vec, indices: &Vec) -> u32 { - // Implement me! - - // Also, feel free to delete comments :) - - // This should: - // * Generate a VAO and bind it - // * Generate a VBO and bind it - // * Fill it with data - // * Configure a VAP for the data and enable it - // * Generate a IBO and bind it - // * Fill it with data - // * Return the ID of the VAO let mut vao_id = 0; gl::GenVertexArrays(1, &mut vao_id); gl::BindVertexArray(vao_id); @@ -181,15 +168,15 @@ fn main() { // == // Set up your VAO around here - let vertices = vec![ - -0.6, -0.6, 0., - 0.6, -0.6, 0., - 0., 0.6, 0. - ]; - let indices = vec![0, 1, 2]; - let my_vao = unsafe { - create_vao(&vertices, &indices) - }; + let vertices: Vec = (-3..2) + .flat_map(|i| { + let a = 0.2 * i as f32; + vec![-0.1 + a, -0.1, 0., 0.1 + a, -0.1, 0., 0. + a, 0.1, 0.] + }) + .collect(); + + let indices: Vec = (0..vertices.len() as u32).collect(); + let my_vao = unsafe { create_vao(&vertices, &indices) }; println!("created vao!"); // let my_vao = unsafe { 1337 };