part way through switch to cin parser

This commit is contained in:
2025-08-19 12:00:18 -05:00
parent d4d4a236e9
commit ba9216a338
6 changed files with 107 additions and 159 deletions

View File

@@ -3,12 +3,16 @@
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/ext/vector_float3.hpp>
#include <iostream>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string>
#include "util.hpp"
#include "shaders.hpp"
#include "body.hpp"
#include "tcp_server.hpp"
static GLFWwindow* window;
static float width, height;
@@ -24,6 +28,32 @@ void process_input() {
glfwSetWindowShouldClose(window, true);
}
static bool stop = false;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static std::map<char*, std::pair<body, int>> camera_name_to_bodies;
enum class LineParserState {
NAME,
X,
Y,
Z
};
// name x y z\n
void process_cin(void* args) {
size_t len = 256;
std::string line;
while (true) {
std::getline(std::cin, line);
array<char*> words = split_str(line.c_str());
assert(words.len == 4);
pthread_mutex_lock(&lock);
for (int i = 0; i < words.len; i++) {
if (camera_name_to_bodies.find(words
}
pthread_mutex_unlock(&lock);
}
}
static bool mouse_pressed = false;
static bool scroll_pressed = false;
static double prev_cursor_x, prev_cursor_y;
@@ -107,11 +137,6 @@ bool glfw_setup() {
}
int main() {
//tcpserver server;
//if (!create_server(&server, "127.0.0.1", 5000, 1)) {
// //return -1;
//}
if (!glfw_setup())
return -1;
@@ -163,6 +188,7 @@ int main() {
while (!glfwWindowShouldClose(window)) {
process_input();
process_cin();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
set_uniform(shader, "camera_t", camera_t);
set_uniform(shader, "projection_t", projection_t);