Push before switching to new render method
parent
12b81f1363
commit
119b36cb2b
|
@ -11,6 +11,7 @@
|
||||||
#include "blt/std/memory.h"
|
#include "blt/std/memory.h"
|
||||||
#include <shaders/vertex.vert>
|
#include <shaders/vertex.vert>
|
||||||
#include <shaders/fragment.frag>
|
#include <shaders/fragment.frag>
|
||||||
|
#include <blt/profiling/profiler.h>
|
||||||
#include <shaders/physics.comp>
|
#include <shaders/physics.comp>
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
#include <stb_image_resize.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);
|
perspectiveMatrix = blt::perspective(FOV, (float)WINDOW_WIDTH / (float)WINDOW_HEIGHT, 0.1f, 1000.0f);
|
||||||
auto pvm = perspectiveMatrix * viewMatrix;
|
auto pvm = perspectiveMatrix * viewMatrix;
|
||||||
|
|
||||||
|
BLT_START_INTERVAL("Particles", "Compute Shader");
|
||||||
runPhysicsShader();
|
runPhysicsShader();
|
||||||
|
BLT_END_INTERVAL("Particles", "Compute Shader");
|
||||||
|
|
||||||
|
BLT_START_INTERVAL("Particles", "Render");
|
||||||
instance_shader->bind();
|
instance_shader->bind();
|
||||||
instance_shader->setMatrix("pvm", pvm);
|
instance_shader->setMatrix("pvm", pvm);
|
||||||
|
|
||||||
|
@ -126,7 +130,7 @@ void render() {
|
||||||
glBindVertexArray(particleVAO);
|
glBindVertexArray(particleVAO);
|
||||||
glDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0, particle_count);
|
glDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0, particle_count);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
BLT_END_INTERVAL("Particles", "Render");
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
|
@ -316,6 +320,7 @@ void init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
|
BLT_PRINT_PROFILE("Particles", blt::logging::NONE, true);
|
||||||
// cleanup opengl resources
|
// cleanup opengl resources
|
||||||
glDeleteVertexArrays(1, &particleVAO);
|
glDeleteVertexArrays(1, &particleVAO);
|
||||||
glDeleteBuffers(1, &particleTranslationsBuffer);
|
glDeleteBuffers(1, &particleTranslationsBuffer);
|
||||||
|
|
13
src/main.cpp
13
src/main.cpp
|
@ -160,6 +160,13 @@ int main(int argc, char** argv) {
|
||||||
glutPassiveMotionFunc([](int x, int y) -> void {
|
glutPassiveMotionFunc([](int x, int y) -> void {
|
||||||
cam.mousePassiveMotion(x, y);
|
cam.mousePassiveMotion(x, y);
|
||||||
});
|
});
|
||||||
|
glutCloseFunc([]() -> void {
|
||||||
|
BLT_DEBUG("Program has exited, cleaning up resources");
|
||||||
|
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
BLT_DEBUG("Cleanup complete, have a good day!");
|
||||||
|
});
|
||||||
|
|
||||||
// display
|
// display
|
||||||
glutIdleFunc(render_i);
|
glutIdleFunc(render_i);
|
||||||
|
@ -184,12 +191,6 @@ int main(int argc, char** argv) {
|
||||||
BLT_DEBUG("Resource initialization complete!");
|
BLT_DEBUG("Resource initialization complete!");
|
||||||
|
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
|
|
||||||
BLT_DEBUG("Program has exited, cleaning up resources");
|
|
||||||
|
|
||||||
cleanup();
|
|
||||||
|
|
||||||
BLT_DEBUG("Cleanup complete, have a good day!");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue