#include "Game.h" #include "LayeredFramebuffer.h" #include "gaming-core/input/Buttons.h" #include "gaming-core/utils/Clock.h" #include "gaming-core/wrapper/GL.h" #include "gaming-core/wrapper/GLEW.h" #include "gaming-core/wrapper/GLFW.h" #include "gaming-core/wrapper/Shader.h" #include "gaming-core/wrapper/Window.h" #include "gaming-core/wrapper/WindowOptions.h" void updateSize(const Window& window, Size& size) { Size newSize = window.getSize(); if(newSize.width != size.width || newSize.height != size.height) { size = newSize; GL::setViewport(size.width, size.height); } } int main() { if(GLFW::init()) { return 0; } Size size(1024, 620); WindowOptions options(4, 0, size, false, "test"); Window window(options); if(window.hasError() || GLEW::init()) { return 0; } Shader shader("resources/vertex.vs", "resources/fragment.fs", "resources/geometry.gs"); if(shader.hasError()) { return 0; } Shader noiceShader("resources/noiceVertex.vs", "resources/noiceFragment.fs"); if(noiceShader.hasError()) { return 0; } LayeredFramebuffer buffer(64, 64, 64); if(buffer.hasError()) { return 0; } Buttons buttons(window); Clock fps; window.show(); Game game(shader, noiceShader, buffer, buttons, size); GL::checkAndPrintError("setup error"); GL::enableDepthTesting(); const Clock::Nanos nanosPerTick = 50000000; Clock::Nanos lag = 0; while(!window.shouldClose()) { GL::checkAndPrintError("loop error"); updateSize(window, size); game.render(static_cast(lag) / nanosPerTick); window.swapBuffers(); lag += fps.update(); while(lag >= nanosPerTick) { lag -= nanosPerTick; buttons.tick(); game.tick(); } glfwPollEvents(); } return 0; }