From 31c011a2f2b8d599ee3eb72f118b8409dec3af1c Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 19 Oct 2020 15:04:11 -0500 Subject: [PATCH] moving changes to laptop --- src/sim.cpp | 16 +++++++++++----- src/vecmath.cpp | 13 +++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/sim.cpp b/src/sim.cpp index 769b65d..018fba6 100644 --- a/src/sim.cpp +++ b/src/sim.cpp @@ -98,7 +98,8 @@ load_shader(GLenum shader_type, const char* shader_loc) GLint successful; glGetShaderiv(shader, GL_COMPILE_STATUS, &successful); - if (successful != GL_TRUE) { + if (successful != GL_TRUE) + { GLsizei log_length = 0; GLchar shader_log[1024]; glGetShaderInfoLog(shader, 1023, &log_length, shader_log); @@ -126,7 +127,8 @@ create_program(GLuint vertex_shader, GLuint fragment_shader) GLint successful; glGetProgramiv(program, GL_LINK_STATUS, &successful); - if (successful != GL_TRUE) { + if (successful != GL_TRUE) + { GLsizei log_length = 0; GLchar program_log[1024]; glGetProgramInfoLog(program, 1023, &log_length, program_log); @@ -157,7 +159,8 @@ create_circle_mesh() glBindVertexArray(vao); V2f circle_points[CIRCLE_POINT_COUNT] = {}; - foreach (i, 0, CIRCLE_POINT_COUNT) { + foreach (i, 0, CIRCLE_POINT_COUNT) + { f32 t = (f32) i / (f32) CIRCLE_POINT_COUNT; circle_points[i].x = cos(t * 2 * PI) * 40.0f + 400.0f; circle_points[i].y = sin(t * 2 * PI) * 40.0f + 200.0f; @@ -186,6 +189,7 @@ create_circle_mesh() + // NOTE(Brendan): dt is expected to be in units of "per second". internal void update(f64 dt) @@ -213,14 +217,16 @@ loop() f64 curr_time = last_time; f64 delta; - while (!glfwWindowShouldClose(window)) { + while (!glfwWindowShouldClose(window)) + { glfwPollEvents(); curr_time = glfwGetTime(); delta = curr_time - last_time; last_time = curr_time; - if (delta > 0.0) { + if (delta > 0.0) + { update(delta); draw(); } diff --git a/src/vecmath.cpp b/src/vecmath.cpp index 4d653be..2315d49 100644 --- a/src/vecmath.cpp +++ b/src/vecmath.cpp @@ -87,13 +87,10 @@ mat4_ortho(mat4 *mat, void mat4_mul(mat4 a, mat4 b, mat4* out) { - foreach(row, 0, 4) { - foreach(col, 0, 4) { - (*out)[row * 4 + col] = 0.0f; - - foreach(i, 0, 4) { - (*out)[row * 4 + col] += a[row * 4 + i] * b[i * 4 + col]; - } - } + foreach(row, 0, 4) foreach(col, 0, 4) + { + (*out)[row * 4 + col] = 0.0f; + + foreach(i, 0, 4) (*out)[row * 4 + col] += a[row * 4 + i] * b[i * 4 + col]; } } -- 2.25.1