#define STB_IMAGE_IMPLEMENTATION #include #include #include #include //#include #include #include #include #include "Draw.h" #include "grid.h" #include "Buffers.h" bool running = false; float lastRefresh = 0.0; NB::ConwayGrid* conwayGrid; NB::ConwayGrid::CellGrid start_grid; int main() { NB::Window myWindow(800, 600, "Howdy Naif!"); myWindow.setWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); myWindow.setWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); myWindow.init(); auto window = myWindow.getWindow(); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetKeyCallback(window, keypress_callback); glfwSetMouseButtonCallback(window, mouseclick_callback); glfwSetCursorPosCallback(window, mousemove_callback); NB::Shader myShader("../shaders/vert.vs", "../shaders/frag.fs"); myShader.use(); NB::ConwayGrid myGrid(myShader, 30, 30, {-0.9, -0.9}, {0.9, 0.9}); conwayGrid = &myGrid; NB_GL_DEBUG(myGrid.sendCells()); // Window loop start_grid = myGrid.getCells(); GLenum err; while(!glfwWindowShouldClose(window)) { NB_GL_DEBUG_THROW("nothing", "during"); // Input checking processInput(window); // Rendering Loop myShader.use(); if (running) { glClearColor(0.2f, 0.4f, 0.3f, 1.0f); } else { glClearColor(0.4f, 0.2f, 0.3f, 1.0f); } glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); NB_GL_DEBUG(myGrid.draw()); if ( running && glfwGetTime()-lastRefresh > 0.2) { myGrid.calcNext(); myGrid.sendCells(); lastRefresh = glfwGetTime(); } // Events and buffer swap // myDrawing.draw(); glfwPollEvents(); glfwSwapBuffers(window); } glfwTerminate(); return 0; }