Cleanup the main.cpp file

pull/6/head
E. Almqvist 2 years ago
parent 5e88f63273
commit ce061b91ae
  1. 1
      headers/window.hpp
  2. 8
      src/main.cpp
  3. 5
      src/window.cpp

@ -25,6 +25,7 @@ class Window {
void updateSize(int w, int h);
void makeCurrent();
void swapBuffers();
bool shouldClose();
private:
GLFWwindow* _win;
static std::map<GLFWwindow*, Window*> windowMap;

@ -123,9 +123,6 @@ int main() {
return 1;
}
// glViewport(0, 0, win.getWidth(), win.getHeight());
// glfwSetFramebufferSizeCallback(win.getWindow(), framebuffer_size_callback); // Framebuffer
glEnable(GL_DEPTH_TEST);
// Input
@ -148,7 +145,7 @@ int main() {
Controller player(&win, glm::vec3(0.0f, 0.0f, 8.0f));
scene.setCamera(&player);
while (!glfwWindowShouldClose(win.getWindow())) {
while (!win.shouldClose()) {
// Handle input
player.processInput(scene.deltaTime);
processInput(win.getWindow());
@ -162,10 +159,9 @@ int main() {
scene.render();
// glfw
glfwSwapBuffers(win.getWindow());
win.swapBuffers();
glfwPollEvents();
}
glfwTerminate();
return 0;
}

@ -55,6 +55,11 @@ void Window::swapBuffers() {
glfwSwapBuffers(_win);
}
bool Window::shouldClose() {
return glfwWindowShouldClose(_win);
}
// Framebuffer Size Callback, called each time the window "updates"
void Window::framebufferSizeCallback(GLFWwindow* win, int width, int height) {
windowMap[win]->updateSize(width, height);
}

Loading…
Cancel
Save