From: Brendan Hansen Date: Mon, 19 Oct 2020 23:34:05 +0000 (-0500) Subject: small changes; moving to desktop X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=a4b820fa329aa887fda8b703c0148aba78e7767d;p=csc718.git small changes; moving to desktop --- diff --git a/include/physics.h b/include/physics.h index 881dfa4..1acfc6e 100644 --- a/include/physics.h +++ b/include/physics.h @@ -11,4 +11,6 @@ struct Body f32 mass; }; +Body* make_bodies(i32 body_count = 1); + #endif //PHYSICS_H \ No newline at end of file diff --git a/include/utils.h b/include/utils.h index 15ebbdd..8c4ee7c 100644 --- a/include/utils.h +++ b/include/utils.h @@ -48,7 +48,7 @@ operator*(defer_dummy, F f) } #define DEFER_(LINE) zz_defer##LINE -#define DEFER(LINE_) DEFER_(LINE) +#define DEFER(LINE) DEFER_(LINE) #define defer auto DEFER(__LINE__) = defer_dummy{} * [&]() #endif // defer diff --git a/src/physics.cpp b/src/physics.cpp index 5f4f488..44885cc 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -1,2 +1,7 @@ #include "physics.h" +#include "utils.h" +#include "types.h" +Body* make_bodies(i32 body_count) { + return alloc(body_count); +} \ No newline at end of file diff --git a/src/sim.cpp b/src/sim.cpp index b8bbbc6..4e9a313 100644 --- a/src/sim.cpp +++ b/src/sim.cpp @@ -253,7 +253,7 @@ main(i32 argc, char* argv[]) GLuint ortho_mat_loc = glGetUniformLocation(program, "u_proj"); glUniformMatrix4fv(ortho_mat_loc, 1, false, (f32 *) ortho_mat); - auto bodies = alloc(128); + auto bodies = make_bodies(128); foreach(i, 0, 128) { bodies[i].pos = V2f{ randf(0, 800), randf(0, 800) }; @@ -263,7 +263,7 @@ main(i32 argc, char* argv[]) { glBindVertexArray(circle_mesh); - // defer { glBindVertexArray(-1); }; + defer { glBindVertexArray(-1); }; GLuint body_buffer; glGenBuffers(1, &body_buffer); @@ -276,8 +276,6 @@ main(i32 argc, char* argv[]) glVertexAttribPointer(1, 2, GL_FLOAT, false, sizeof(Body), (void *) offset_of(Body, pos.x)); glVertexAttribPointer(2, 1, GL_FLOAT, false, sizeof(Body), (void *) offset_of(Body, mass)); glBindBuffer(GL_ARRAY_BUFFER, -1); - - // glBindVertexArray(-1); } loop();