|
@@ -6,20 +6,7 @@
|
|
|
#include "gaming-core/network/Client.h"
|
|
|
#include "gaming-core/network/ENet.h"
|
|
|
#include "gaming-core/rendering/Window.h"
|
|
|
-#include "gaming-core/rendering/WindowOptions.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"
|
|
|
-
|
|
|
-void updateSize(const Window& window, Size& size, Framebuffers& framebuffers) {
|
|
|
- Size newSize = window.getSize();
|
|
|
- if(newSize.width != size.width || newSize.height != size.height) {
|
|
|
- size = newSize;
|
|
|
- GL::setViewport(size.width, size.height);
|
|
|
- framebuffers.resize(size);
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
int main() {
|
|
|
ENet enet;
|
|
@@ -32,15 +19,12 @@ int main() {
|
|
|
std::cout << client.getError() << '\n';
|
|
|
return 0;
|
|
|
}
|
|
|
- if(GLFW::init()) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
Size size(1024, 620);
|
|
|
WindowOptions options(4, 0, size, false, "test");
|
|
|
TextInput* textInput = nullptr;
|
|
|
- Window window(textInput, options);
|
|
|
- if(window.hasError() || GLEW::init()) {
|
|
|
+ Window w(textInput, options);
|
|
|
+ if(w.getError().has()) {
|
|
|
+ std::cout << w.getError().message << '\n';
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -50,38 +34,15 @@ int main() {
|
|
|
}
|
|
|
|
|
|
Framebuffers framebuffers;
|
|
|
- if(framebuffers.init(size)) {
|
|
|
+ if(framebuffers.init(w.getSize())) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
RenderSettings renderSettings;
|
|
|
- Engine engine(shaders, framebuffers, size, renderSettings);
|
|
|
-
|
|
|
- Buttons buttons(window);
|
|
|
- Controller controller(buttons);
|
|
|
- Clock fps;
|
|
|
- Clock tps;
|
|
|
- Game game(textInput, controller, fps, tps, renderSettings, size, client);
|
|
|
-
|
|
|
- window.show();
|
|
|
-
|
|
|
- GL::printError("setup error");
|
|
|
-
|
|
|
- const Clock::Nanos nanosPerTick = 50000000;
|
|
|
- Clock::Nanos lag = 0;
|
|
|
- while(!window.shouldClose() && game.isRunning()) {
|
|
|
- GL::printError("loop error");
|
|
|
- updateSize(window, size, framebuffers);
|
|
|
- engine.renderTick(static_cast<float>(lag) / nanosPerTick, game);
|
|
|
- window.swapBuffers();
|
|
|
- lag += fps.update();
|
|
|
- while(lag >= nanosPerTick) {
|
|
|
- lag -= nanosPerTick;
|
|
|
- tps.update();
|
|
|
- buttons.tick();
|
|
|
- game.tick();
|
|
|
- }
|
|
|
- glfwPollEvents();
|
|
|
- }
|
|
|
+ Controller controller(w.getButtons());
|
|
|
+ Game game(textInput, controller, w.getFrameClock(), w.getTickClock(),
|
|
|
+ renderSettings, w.getSize(), client);
|
|
|
+ Engine engine(shaders, framebuffers, w.getSize(), renderSettings, game);
|
|
|
+ w.run(engine, 50'000'000);
|
|
|
return 0;
|
|
|
}
|