small changes; moving to desktop
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 19 Oct 2020 23:34:05 +0000 (18:34 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 19 Oct 2020 23:34:05 +0000 (18:34 -0500)
include/physics.h
include/utils.h
src/physics.cpp
src/sim.cpp

index 881dfa4e91177fa59d428700e8353e6a25e58c30..1acfc6e88c7b0c9dde6349f2e9aa30d9ee083402 100644 (file)
@@ -11,4 +11,6 @@ struct Body
     f32 mass;
 };
 
+Body* make_bodies(i32 body_count = 1);
+
 #endif //PHYSICS_H
\ No newline at end of file
index 15ebbdd93193147a6a9904ae6835887d11e24046..8c4ee7cc29d2c8dc9e167817ecf953b40aca3914 100644 (file)
@@ -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
index 5f4f4882590d61ea114ba698d7c98b769f9c3ccc..44885cc659f651ae56b1b5ffa8ba89a6e3a3e55b 100644 (file)
@@ -1,2 +1,7 @@
 #include "physics.h"
+#include "utils.h"
+#include "types.h"
 
+Body* make_bodies(i32 body_count) {
+    return alloc<Body>(body_count);
+}
\ No newline at end of file
index b8bbbc69bed327a772590c6bcf6b8ed7d337c5e4..4e9a31302d17599989a09540fe2842814f9b6cb6 100644 (file)
@@ -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<Body>(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();