#include "funcs.h" void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); } void keypress_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_P && action == GLFW_PRESS) { if (!running) { lastRefresh = glfwGetTime(); } running ^= true; } if (key == GLFW_KEY_R && action == GLFW_PRESS) { conwayGrid->setCells(start_grid); conwayGrid->sendCells(); lastRefresh = glfwGetTime(); } } void processInput(GLFWwindow* window) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(window, true); } } void mouseclick_callback(GLFWwindow* window, int button, int action, int mods) { if (action == GLFW_RELEASE) { double xpos, ypos; int xsize, ysize; glfwGetCursorPos(window, &xpos, &ypos); glfwGetWindowSize(window, &xsize, &ysize); conwayGrid->click(xpos/xsize, ypos/ysize); conwayGrid->sendCells(); } } void mousemove_callback(GLFWwindow* window, double xpos, double ypos) { if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS) { double xpos, ypos; int xsize, ysize; glfwGetCursorPos(window, &xpos, &ypos); glfwGetWindowSize(window, &xsize, &ysize); conwayGrid->click(xpos/xsize, ypos/ysize); conwayGrid->sendCells(); } }