Push before switching to new render method

main
Brett 2023-04-02 15:53:38 -04:00
parent 12b81f1363
commit 119b36cb2b
2 changed files with 13 additions and 7 deletions

View File

@ -11,6 +11,7 @@
#include "blt/std/memory.h"
#include <shaders/vertex.vert>
#include <shaders/fragment.frag>
#include <blt/profiling/profiler.h>
#include <shaders/physics.comp>
#include <stb_image.h>
#include <stb_image_resize.h>
@ -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);

View File

@ -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);
@ -185,11 +192,5 @@ int main(int argc, char** argv) {
glutMainLoop();
BLT_DEBUG("Program has exited, cleaning up resources");
cleanup();
BLT_DEBUG("Cleanup complete, have a good day!");
return 0;
}