render 5 triangles
This commit is contained in:
BIN
report/images/5_triangles.png
Normal file
BIN
report/images/5_triangles.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
31
src/main.rs
31
src/main.rs
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user