axis spheres still aren't showing, but some obvious bugs were removed. still debugging

This commit is contained in:
2025-08-22 11:13:16 -05:00
parent 19f786ee7c
commit a79b074201
6 changed files with 39 additions and 34 deletions

View File

@@ -31,14 +31,6 @@ void process_input() {
glfwSetWindowShouldClose(window, true);
}
static uint shader;
void create_new_sphere(Body* b, float scale = 1) {
assert(load_body(b, "Icosphere.obj"));
b->shader = shader;
b->scale = scale;
b->pose = glm::translate(b->pose, glm::vec3(0, 0, 0));
}
static bool stop = false;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
const float max_hp
@@ -189,9 +181,10 @@ int main() {
glfwSwapBuffers(window); // front buffer is now back
glClear(GL_COLOR_BUFFER_BIT); // Write to back buffer again (former front buf)
/*Body b2;
Body b2;
create_new_sphere(&b2);
b2.color = glm::vec4(0, 0.5, 0, 1);*/
b2.pose = glm::translate(b2.pose, glm::vec3(0, 0, 20));
b2.color = glm::vec4(1, 0, 0, 1);
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// set_uniform(shader, "color", glm::vec4 { sin(time), sin(time + glm::radians(45.0f)), sin(time +
@@ -201,12 +194,12 @@ int main() {
glEnable(GL_DEPTH_TEST);
glm::mat4 projection_t
= glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 1300.0f);
= glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 2000.0f);
pthread_t thread_id;
pthread_create(&thread_id, NULL, process_cin, NULL);
Array<Body> camera_pose_axes;
Array<Body> camera_pose_axes = { NULL, 0 };
if (!parse_poses(&camera_pose_axes, "poses.csv")) {
return -1;
}
@@ -217,16 +210,18 @@ int main() {
set_uniform(shader, "camera_t", world_to_camera);
set_uniform(shader, "projection_t", projection_t);
draw_body(b2);
for (int i = 0; i < camera_pose_axes.len; i++) {
draw_body(camera_pose_axes[i]);
}
if (pthread_mutex_trylock(&lock)) {
if (pthread_mutex_trylock(&lock) == 0) {
for (int i = 0; i < camera_bodies.size(); i++) {
if (!std::get<1>(camera_bodies[i])) {
Body* b = (Body*)malloc(sizeof(Body));
create_new_sphere(b);
b->color = glm::vec4(i & 0x4, i & 0x2, i & 0x1, max_hp);
b->color = glm::vec4((i+1) & 0x4, (i+1) & 0x2, (i+1) & 0x1, max_hp);
std::get<1>(camera_bodies[i]) = b;
}
draw_body(*std::get<1>(camera_bodies[i]));