render 5 triangles

This commit is contained in:
2025-08-26 21:50:51 +02:00
parent 03a4b1133e
commit 30dd5714c9
2 changed files with 9 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -59,20 +59,7 @@ fn offset<T>(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<f32>, indices: &Vec<u32>) -> 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<f32> = (-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<u32> = (0..vertices.len() as u32).collect();
let my_vao = unsafe { create_vao(&vertices, &indices) };
println!("created vao!");
// let my_vao = unsafe { 1337 };