diff --git a/src/high_perf/high_perf.cpp b/src/high_perf/high_perf.cpp index 18471ab..2c18a6a 100644 --- a/src/high_perf/high_perf.cpp +++ b/src/high_perf/high_perf.cpp @@ -11,6 +11,7 @@ #include "blt/std/memory.h" #include #include +#include #include #include #include @@ -115,8 +116,11 @@ void render() { perspectiveMatrix = blt::perspective(FOV, (float)WINDOW_WIDTH / (float)WINDOW_HEIGHT, 0.1f, 1000.0f); auto pvm = perspectiveMatrix * viewMatrix; + BLT_START_INTERVAL("Particles", "Compute Shader"); runPhysicsShader(); + BLT_END_INTERVAL("Particles", "Compute Shader"); + BLT_START_INTERVAL("Particles", "Render"); instance_shader->bind(); instance_shader->setMatrix("pvm", pvm); @@ -126,7 +130,7 @@ void render() { glBindVertexArray(particleVAO); glDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0, particle_count); glBindVertexArray(0); - + BLT_END_INTERVAL("Particles", "Render"); } void init() { @@ -316,6 +320,7 @@ void init() { } void cleanup() { + BLT_PRINT_PROFILE("Particles", blt::logging::NONE, true); // cleanup opengl resources glDeleteVertexArrays(1, &particleVAO); glDeleteBuffers(1, &particleTranslationsBuffer); diff --git a/src/main.cpp b/src/main.cpp index 544dd03..f2f3db4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -160,6 +160,13 @@ int main(int argc, char** argv) { glutPassiveMotionFunc([](int x, int y) -> void { cam.mousePassiveMotion(x, y); }); + glutCloseFunc([]() -> void { + BLT_DEBUG("Program has exited, cleaning up resources"); + + cleanup(); + + BLT_DEBUG("Cleanup complete, have a good day!"); + }); // display glutIdleFunc(render_i); @@ -184,12 +191,6 @@ int main(int argc, char** argv) { BLT_DEBUG("Resource initialization complete!"); glutMainLoop(); - - BLT_DEBUG("Program has exited, cleaning up resources"); - - cleanup(); - - BLT_DEBUG("Cleanup complete, have a good day!"); return 0; } \ No newline at end of file