generated from AfonsoCMSousa/CPP-OpenGLTemplate
feat: thread view - change between Normal colors and Thread ID color view
This commit is contained in:
parent
bf56d3377a
commit
9042e053c8
@ -31,7 +31,7 @@ const unsigned int SCR_WIDTH = 2560;
|
||||
const unsigned int SCR_HEIGHT = 1440;
|
||||
const char *glsl_version;
|
||||
|
||||
const unsigned int PARTICLE_COUNT = 8;
|
||||
const unsigned int PARTICLE_COUNT = 10000;
|
||||
|
||||
GLFWwindow *window;
|
||||
unsigned int VBO, VAO;
|
||||
@ -48,6 +48,7 @@ pthread_barrier_t barrier;
|
||||
|
||||
// INFO: Debug views toggles
|
||||
bool viewThreads = 0;
|
||||
bool enablePhysics = 1;
|
||||
|
||||
static void cursor_callback(GLFWwindow *w, double xpos, double ypos) {
|
||||
#ifndef NDEBUG
|
||||
@ -246,7 +247,7 @@ int main() {
|
||||
|
||||
default_particle_color[i] = {x, y, z, 255.0f};
|
||||
particles[i] = particle_init({x, y, z}, {x, y, z, 255.0f});
|
||||
particles[i].radius = (float)(rand() % 50) / 1000.0f;
|
||||
particles[i].radius = (float)((rand() % 5) + 5) / 1000.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -309,6 +310,7 @@ int main() {
|
||||
glm::mat4 projection = camera_projection(camera, aspect);
|
||||
glm::mat4 mvp = projection * view; // model is identity
|
||||
|
||||
if (enablePhysics) {
|
||||
pthread_mutex_lock(&mutex);
|
||||
for (int i = 0; i < THREAD_COUNT; i++) {
|
||||
thread_params[i].time = delta_time;
|
||||
@ -324,6 +326,7 @@ int main() {
|
||||
alive_count += thread_params[i].alive_count;
|
||||
|
||||
// collision_update(particles, alive_count, 0.3f);
|
||||
}
|
||||
|
||||
// Render
|
||||
glClearColor(0.03f, 0.03f, 0.03f, 1.0f);
|
||||
@ -368,6 +371,15 @@ int main() {
|
||||
snprintf(errLog, 128, "Switched views to thread view\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Enable Physics", &enablePhysics)) {
|
||||
if (!enablePhysics) {
|
||||
snprintf(errLog, 128, "Disabled phyics\n");
|
||||
} else {
|
||||
snprintf(errLog, 128, "Enable physics\n");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
// Render ImGui
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user