Projection mat4 automatically updates on window size change. cin thread now quits quietly upon receiving eof

This commit is contained in:
2025-08-23 23:36:07 -05:00
parent 9fe709dfe4
commit b775d5a90f

View File

@@ -19,11 +19,13 @@
static GLFWwindow* window;
static float width, height;
static glm::mat4 projection_t;
void framebuffer_size_callback(GLFWwindow* window, int w, int h) {
width = w;
height = h;
glViewport(0, 0, width, height);
projection_t = glm::infinitePerspective(glm::radians(45.0f), (float)width / (float)height, 0.1f);
}
void process_input() {
@@ -48,7 +50,7 @@ void* process_cin(void* args) {
while (true) {
std::getline(std::cin, line);
Array<char*> words = split_str(line.c_str());
assert(words.len == 4);
if (!words.len == 4) return NULL;
printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging
float x = atof(words[1]);
float y = atof(words[2]);
@@ -194,7 +196,7 @@ int main() {
glDisable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glm::mat4 projection_t = glm::infinitePerspective(glm::radians(45.0f), (float)width / (float)height, 0.1f);
projection_t = glm::infinitePerspective(glm::radians(45.0f), (float)width / (float)height, 0.1f);
pthread_t thread_id;
pthread_create(&thread_id, NULL, process_cin, NULL);