#define WINDOW_HEIGHT 900
#define WINDOW_TITLE "N-Body Simulation"
-void __attribute__((noreturn)) panic_and_die(const char* msg, ...) {
+void panic_and_die(const char* msg, ...) __attribute__((noreturn));
+void panic_and_die(const char* msg, ...) {
puts("************ PANIC ************");
va_list va;
glfwTerminate();
}
-void update() {
+// NOTE: dt is expected to be in units of "per second".
+void update(double dt) {
}
void draw() {
- glClearColor(1.0, 0.0, 1.0, 1.0);
+ glClearColor(0.1, 0.1, 0.1, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glfwSwapBuffers(window);
}
void loop() {
+ double last_time = glfwGetTime();
+ double curr_time = last_time;
+ double delta;
+
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
- update();
+ curr_time = glfwGetTime();
+ delta = curr_time - last_time;
+ last_time = curr_time;
+
+ update(delta);
draw();
}
}