Skip to content

Commit

Permalink
commented out unused stuff to pass the pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbrusegard committed Aug 20, 2024
1 parent 2db8932 commit 46822e7
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 174 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
with:
components: clippy
- name: Run Clippy
run: cargo clippy --workspace
run: cargo clippy --workspace -D warnings
7 changes: 0 additions & 7 deletions gloom-rs/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
edition = "2021"
max_width = 110
hard_tabs = false
tab_spaces = 3
newline_style = "Unix"
use_small_heuristics = "Max"
indent_style = "Block"
trailing_comma = "Always"
space_around_ranges = true
reorder_imports = true
max_blank_lines = 1
spaces_around_comments = true
72 changes: 38 additions & 34 deletions gloom-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
*/
extern crate nalgebra_glm as glm;
use std::sync::{Arc, Mutex};
use std::{mem, os::raw::c_void, ptr};
use std::{
// mem,
// os::raw::c_void,
ptr,
};

mod shader;
mod util;
Expand All @@ -31,48 +35,48 @@ const INITIAL_SCREEN_H: u32 = 600;

// Get the size of an arbitrary array of numbers measured in bytes
// Example usage: byte_size_of_array(my_array)
fn byte_size_of_array<T>(val: &[T]) -> isize {
std::mem::size_of_val(&val[..]) as isize
}
// fn byte_size_of_array<T>(val: &[T]) -> isize {
// std::mem::size_of_val(&val[..]) as isize
// }

// Get the OpenGL-compatible pointer to an arbitrary array of numbers
// Example usage: pointer_to_array(my_array)
fn pointer_to_array<T>(val: &[T]) -> *const c_void {
&val[0] as *const T as *const c_void
}
// fn pointer_to_array<T>(val: &[T]) -> *const c_void {
// &val[0] as *const T as *const c_void
// }

// Get the size of the given type in bytes
// Example usage: size_of::<u64>()
fn size_of<T>() -> i32 {
mem::size_of::<T>() as i32
}
// fn size_of<T>() -> i32 {
// mem::size_of::<T>() as i32
// }

// Get an offset in bytes for n units of type T, represented as a relative pointer
// Example usage: offset::<u64>(4)
fn offset<T>(n: u32) -> *const c_void {
(n * mem::size_of::<T>() as u32) as *const T as *const c_void
}
// fn offset<T>(n: u32) -> *const c_void {
// (n * mem::size_of::<T>() as u32) as *const T as *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

0
}
// 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
//
// 0
// }

fn main() {
// Set up the necessary objects to deal with windows and event handling
Expand Down Expand Up @@ -100,7 +104,7 @@ fn main() {
// Set up shared tuple for tracking changes to the window size
let arc_window_size = Arc::new(Mutex::new((INITIAL_SCREEN_W, INITIAL_SCREEN_H, false)));

let mut window_aspect_ratio = INITIAL_SCREEN_W as f32 / INITIAL_SCREEN_H as f32;
// let mut window_aspect_ratio = INITIAL_SCREEN_W as f32 / INITIAL_SCREEN_H as f32;

// Set up openGL
unsafe {
Expand Down Expand Up @@ -200,7 +204,7 @@ fn main() {
Event::MainEventsCleared => {
// == // Set up your VAO around here

let my_vao = unsafe { 1337 };
// let my_vao = unsafe { 1337 };

// == // Set up your shaders here

Expand All @@ -224,15 +228,15 @@ fn main() {

// Compute time passed since the previous frame and since the start of the program
let now = std::time::Instant::now();
let elapsed = now.duration_since(first_frame_time).as_secs_f32();
// let elapsed = now.duration_since(first_frame_time).as_secs_f32();
let delta_time = now.duration_since(previous_frame_time).as_secs_f32();
previous_frame_time = now;

if let Ok(mut new_size) = arc_window_size.lock() {
if new_size.2 {
context.resize(glutin::dpi::PhysicalSize::new(new_size.0, new_size.1));
window_aspect_ratio = new_size.0 as f32 / new_size.1 as f32;
(*new_size).2 = false;
// window_aspect_ratio = new_size.0 as f32 / new_size.1 as f32;
new_size.2 = false;
println!("Window was resized to {}x{}", new_size.0, new_size.1);
unsafe {
gl::Viewport(0, 0, new_size.0 as i32, new_size.1 as i32);
Expand Down
Loading

0 comments on commit 46822e7

Please sign in to comment.