Browse Source

engine is global

Kajetan Johannes Hammerle 3 years ago
parent
commit
564e1c2616

+ 13 - 35
client/Game.cpp

@@ -1,22 +1,23 @@
 #include "client/Game.h"
+#include "client/GameClient.h"
 #include "client/packets/WorldPackets.h"
+#include "client/rendering/Engine.h"
 #include "common/network/Packets.h"
 #include "utils/Logger.h"
 #include "utils/Utils.h"
 
+Game* Game::game = nullptr;
 BlockRegistry Game::blockRegistry;
+World Game::world{blockRegistry};
 
-Game::Game(TextInput*& textInput, const Controller& controller,
-           const Clock& fps, const Clock& tps, RenderSettings& settings,
-           const Size& size, Client& client)
-    : controller(controller), fps(fps), tps(tps), renderSettings(settings),
-      size(size), client(client), tickState(&Game::tickConnectState),
-      renderState(&Game::renderConnectState),
-      baseGUI(size, textInput, controller), startGUI(baseGUI),
-      world(blockRegistry), worldRenderer(world) {
+Game::Game(const Controller& controller)
+    : controller(controller), tickState(&Game::tickConnectState),
+      renderState(&Game::renderConnectState), baseGUI(controller),
+      startGUI(baseGUI), worldRenderer(world) {
     pos = Vector3(0.0f, 30.0f, 0.0f);
     rotation = Quaternion(Vector3(1.0f, 0.0f, 0.0f), 30) * rotation;
     rotation = Quaternion(Vector3(0.0f, 1.0f, 0.0f), 30) * rotation;
+    game = this;
 }
 
 void Game::tick() {
@@ -75,9 +76,9 @@ void Game::renderOverlay(float lag, ShaderMatrix& sm, Renderer& r) {
     sm.identity().scale(2.0f).update();
     StringBuffer<100> s;
     s.append("FPS: &074")
-        .append(fps.getUpdatesPerSecond())
+        .append(Engine::getFrameClock().getUpdatesPerSecond())
         .append(" &999TPS: &722")
-        .append(tps.getUpdatesPerSecond());
+        .append(Engine::getTickClock().getUpdatesPerSecond());
     r.renderString(Vector2(10.0f, 10.0f), s);
 }
 
@@ -85,34 +86,11 @@ bool Game::isRunning() const {
     return true;
 }
 
-void Game::onConnect() {
-}
-
-void Game::onDisconnect() {
-}
-
-void Game::onPacket(InPacket& in) {
-    uint16 id;
-    if(in.readU16(id)) {
-        return;
-    }
-    switch(id) {
-        case S_CHAT:
-            {
-                StringBuffer<256> s;
-                in.readString(s);
-                puts(s);
-                break;
-            }
-        case S_WORLD_SEGMENT: WorldPackets::receiveChunk(world, in); break;
-    }
-}
-
 void Game::tickConnectState() {
     startGUI.tick();
     StartGUI::Address a;
     if(startGUI.getAddress(a)) {
-        Error error = client.connect(a, 11196, 3000);
+        Error error = GameClient::connect(a, 11196, 3000);
         if(error.has()) {
             LOG_INFO(error.message);
         } else {
@@ -124,7 +102,7 @@ void Game::tickConnectState() {
 }
 
 void Game::tickConnectedState() {
-    client.consumeEvents(*this);
+    GameClient::consumeEvents();
 }
 
 void Game::renderConnectState(float lag, ShaderMatrix& sm, Renderer& r) {

+ 3 - 18
client/Game.h

@@ -3,24 +3,14 @@
 
 #include "client/gui/StartGUI.h"
 #include "client/input/Controller.h"
-#include "client/rendering/RenderSettings.h"
 #include "client/rendering/Renderer.h"
 #include "client/rendering/ShaderMatrix.h"
 #include "common/block/BlockRegistry.h"
 #include "common/world/World.h"
-#include "input/TextInput.h"
-#include "network/Client.h"
 #include "rendering/renderer/WorldRenderer.h"
-#include "utils/Clock.h"
-#include "utils/Size.h"
 
 class Game final {
     const Controller& controller;
-    const Clock& fps;
-    const Clock& tps;
-    RenderSettings& renderSettings;
-    const Size& size;
-    Client& client;
 
     typedef void (Game::*TickState)();
     TickState tickState;
@@ -34,15 +24,14 @@ class Game final {
     Quaternion lastRotation;
     Quaternion rotation;
 
-    World world;
     WorldRenderer worldRenderer;
 
 public:
+    static Game* game;
     static BlockRegistry blockRegistry;
+    static World world;
 
-    Game(TextInput*& textInput, const Controller& controller, const Clock& fps,
-         const Clock& tps, RenderSettings& renderSettings, const Size& size,
-         Client& client);
+    Game(const Controller& controller);
 
     void tick();
     void renderWorld(float lag, ShaderMatrix& sm);
@@ -50,10 +39,6 @@ public:
 
     bool isRunning() const;
 
-    void onConnect();
-    void onDisconnect();
-    void onPacket(InPacket& in);
-
 private:
     void tickConnectState();
     void tickConnectedState();

+ 51 - 0
client/GameClient.cpp

@@ -0,0 +1,51 @@
+#include "client/GameClient.h"
+#include "client/Game.h"
+#include "client/packets/WorldPackets.h"
+#include "common/network/Packets.h"
+#include "utils/Logger.h"
+
+static Client client;
+
+struct Receiver {
+    void onConnect() {
+    }
+
+    void onDisconnect() {
+    }
+
+    void onPacket(InPacket& in) {
+        uint16 id;
+        if(in.readU16(id)) {
+            return;
+        }
+        switch(id) {
+            case S_CHAT:
+                {
+                    StringBuffer<256> s;
+                    in.readString(s);
+                    puts(s);
+                    break;
+                }
+            case S_WORLD_SEGMENT:
+                WorldPackets::receiveChunk(Game::world, in);
+                break;
+        }
+    }
+};
+
+bool GameClient::init() {
+    Error error = client.start();
+    if(error.has()) {
+        LOG_ERROR(error.message);
+    }
+    return error.has();
+}
+
+Error GameClient::connect(const char* address, Client::Port port, int timeout) {
+    return client.connect(address, port, timeout);
+}
+
+void GameClient::consumeEvents() {
+    Receiver r;
+    client.consumeEvents(r);
+}

+ 12 - 0
client/GameClient.h

@@ -0,0 +1,12 @@
+#ifndef GAME_CLIENT_H
+#define GAME_CLIENT_H
+
+#include "network/Client.h"
+
+namespace GameClient {
+    bool init();
+    Error connect(const char* address, Client::Port port, int timeout);
+    void consumeEvents();
+}
+
+#endif

+ 6 - 36
client/Main.cpp

@@ -1,47 +1,17 @@
+#include "client/Game.h"
+#include "client/GameClient.h"
 #include "client/input/Controller.h"
 #include "client/rendering/Engine.h"
-#include "client/rendering/Framebuffers.h"
-#include "client/rendering/RenderSettings.h"
-#include "client/rendering/Shaders.h"
-#include "network/Client.h"
 #include "rendering/Window.h"
 #include "utils/Logger.h"
 #include "wrapper/GL.h"
 
 int main() {
-    Client client;
-    Error error = client.start();
-    if(error.has()) {
-        LOG_ERROR(error.message);
+    if(GameClient::init() || Engine::init()) {
         return 0;
     }
-    WindowOptions options(4, 0, {1024, 620}, false, "test");
-    Window w;
-    error = w.open(options);
-    if(error.has()) {
-        LOG_ERROR(error.message);
-        return 0;
-    }
-
-    Shaders shaders;
-    error = shaders.init();
-    if(error.has()) {
-        LOG_ERROR(error.message);
-        return 0;
-    }
-
-    Framebuffers framebuffers;
-    error = framebuffers.init(w.getSize());
-    if(error.has()) {
-        LOG_ERROR(error.message);
-        return 0;
-    }
-
-    RenderSettings renderSettings;
-    Controller controller(w.buttons);
-    Game game(w.textInput, controller, w.getFrameClock(), w.getTickClock(),
-              renderSettings, w.getSize(), client);
-    Engine engine(shaders, framebuffers, w.getSize(), renderSettings, game);
-    w.run(engine, 50'000'000);
+    Controller controller(Engine::getButtons());
+    Game game(controller);
+    Engine::run();
     return 0;
 }

+ 5 - 6
client/gui/BaseGUI.cpp

@@ -1,4 +1,5 @@
 #include "client/gui/BaseGUI.h"
+#include "client/rendering/Engine.h"
 
 static const Color4 INPUT_BACKGROUND(0x00, 0x00, 0x00, 0xA0);
 static const Color4 INPUT_BACKGROUND_2(0x00, 0x00, 0x00, 0x80);
@@ -7,9 +8,7 @@ const Vector2 BaseGUI::FIXED_SIZE(400.0f, 300.0f);
 BaseGUI::Base::Base() : hovered(false), pressed(false) {
 }
 
-BaseGUI::BaseGUI(const Size& size, TextInput*& textInput,
-                 const Controller& controller)
-    : size(size), textInput(textInput), controller(controller) {
+BaseGUI::BaseGUI(const Controller& controller) : controller(controller) {
 }
 
 void BaseGUI::tickBase(Base& b) {
@@ -24,8 +23,7 @@ void BaseGUI::tick() {
     for(Input& input : inputs) {
         tickBase(input.base);
         if(input.base.pressed) {
-            textInput = &input.text;
-            textInput->setActive(true);
+            Engine::setTextInput(&input.text);
         }
     }
     for(Button& button : buttons) {
@@ -34,6 +32,7 @@ void BaseGUI::tick() {
 }
 
 void BaseGUI::updateScale(ShaderMatrix& sm) {
+    const Size& size = Engine::getSize();
     scale = static_cast<int>(
         std::min(size.width / FIXED_SIZE[0], size.height / FIXED_SIZE[1]));
     scale = scale < 1.0f ? 1.0f : scale;
@@ -58,7 +57,7 @@ void BaseGUI::renderInputs(Renderer& r) {
         renderBase(r, input.base);
         StringBuffer<256> text(input.text);
         Vector2 pos = renderCenteredString(r, input.base, text);
-        if(textInput == &input.text) {
+        if(Engine::isActiveTextInput(&input.text)) {
             Vector2 cursor = r.getStringSize(text, input.text.getCursor());
             renderString(r, Vector2(pos[0] + cursor[0], pos[1] + 2.0f),
                          "&292_");

+ 1 - 4
client/gui/BaseGUI.h

@@ -12,8 +12,6 @@
 struct BaseGUI final {
     static const Vector2 FIXED_SIZE;
 
-    const Size& size;
-    TextInput*& textInput;
     const Controller& controller;
 
     float scale;
@@ -45,8 +43,7 @@ struct BaseGUI final {
     };
     List<Button> buttons;
 
-    BaseGUI(const Size& size, TextInput*& textInput,
-            const Controller& controller);
+    BaseGUI(const Controller& controller);
 
     void tick();
     void updateScale(ShaderMatrix& sm);

+ 140 - 47
client/rendering/Engine.cpp

@@ -1,12 +1,39 @@
 #include "client/rendering/Engine.h"
+#include "client/Game.h"
+#include "client/rendering/Framebuffers.h"
+#include "client/rendering/Mesh.h"
+#include "client/rendering/NoiseTexture.h"
+#include "client/rendering/Renderer.h"
 #include "client/rendering/ShaderMatrix.h"
+#include "client/rendering/Shaders.h"
+#include "math/Frustum.h"
+#include "rendering/Window.h"
+#include "utils/Logger.h"
 #include "wrapper/GL.h"
 
-Engine::Engine(Shaders& shaders, Framebuffers& fb, const Size& size,
-               RenderSettings& renderSettings, Game& game)
-    : shaders(shaders), framebuffers(fb), lastSize(size), size(size),
-      renderSettings(renderSettings), game(game),
-      frustum(60.0f, 0.1f, 1000.0f, size) {
+static Window window;
+static Shaders shaders;
+static Framebuffers framebuffers;
+static Size lastSize{0, 0};
+static Frustum frustum{60.0f, 0.1f, 1000.0f, window.getSize()};
+static MatrixStack<16> model;
+static Renderer renderer;
+static NoiseTexture ssaoNoise;
+static Mesh rectangle;
+static Matrix worldProj;
+static Matrix worldView;
+static Matrix worldShadowProj;
+static Matrix worldShadowView;
+static Matrix worldShadowProjView;
+static bool useSsao = true;
+static bool useShadows = false;
+static float shadowRadius = 0.01f;
+static float shadowBias = 0.0002f;
+
+static bool initRectangle() {
+    if(rectangle.init()) {
+        return true;
+    }
     TypedBuffer<Triangle> buffer(2);
     buffer.add(
         Triangle(Vertex(Vector3(-1.0f, -1.0f, 0.0f), Vector2(0, 0.0f)),
@@ -17,39 +44,34 @@ Engine::Engine(Shaders& shaders, Framebuffers& fb, const Size& size,
                  Vertex(Vector3(1.0f, -1.0f, 0.0f), Vector2(1.0f, 0.0f)),
                  Vertex(Vector3(1.0f, 1.0f, 0.0f), Vector2(1.0f, 1.0f))));
     rectangle.build(buffer);
+    return false;
 }
 
-void Engine::render(float lag) {
-    if(size.width != lastSize.width || size.height != lastSize.height) {
-        GL::setViewport(size.width, size.height);
-        framebuffers.resize(size);
-        lastSize = size;
+bool Engine::init() {
+    WindowOptions options(4, 0, {1024, 620}, false, "test");
+    Error error = window.open(options);
+    if(error.has()) {
+        LOG_ERROR(error.message);
+        return true;
     }
-    GL::printError("loop error");
-
-    updateWorldProjection();
-    updateWorldView();
-
-    if(renderSettings.shadows) {
-        renderShadow(lag);
+    lastSize = window.getSize();
+    error = shaders.init();
+    if(error.has()) {
+        LOG_ERROR(error.message);
+        return true;
     }
-    renderWorld(lag);
-    if(renderSettings.ssao) {
-        renderSSAO();
+    error = framebuffers.init(window.getSize());
+    if(error.has()) {
+        LOG_ERROR(error.message);
+        return true;
     }
-    renderPostWorld();
-    renderOverlay(lag);
-}
-
-void Engine::tick() {
-    game.tick();
-}
-
-bool Engine::isRunning() const {
-    return game.isRunning();
+    if(renderer.init() || ssaoNoise.init() || initRectangle()) {
+        return true;
+    }
+    return false;
 }
 
-void Engine::renderShadow(float lag) {
+static void renderShadow(float lag) {
     framebuffers.shadow.bindAndClear();
     GL::enableDepthTesting();
     shaders.shadow.use();
@@ -59,10 +81,10 @@ void Engine::renderShadow(float lag) {
     model.clear();
     shaders.shadow.setMatrix("model", model.peek().getValues());
     ShaderMatrix sm(shaders.shadow, model, worldView);
-    game.renderWorld(lag, sm);
+    Game::game->renderWorld(lag, sm);
 }
 
-void Engine::renderWorld(float lag) {
+static void renderWorld(float lag) {
     framebuffers.world.bindAndClear();
     GL::enableDepthTesting();
     shaders.world.use();
@@ -78,14 +100,14 @@ void Engine::renderWorld(float lag) {
     model.clear();
     shaders.world.setMatrix("model", model.peek().getValues());
     framebuffers.shadow.bindTextureTo(0, 1);
-    shaders.world.setInt("shadows", renderSettings.shadows);
-    shaders.world.setFloat("radius", renderSettings.testRadius);
-    shaders.world.setFloat("zbias", renderSettings.testBias);
+    shaders.world.setInt("shadows", useShadows);
+    shaders.world.setFloat("radius", shadowRadius);
+    shaders.world.setFloat("zbias", shadowBias);
     ShaderMatrix sm(shaders.world, model, worldView);
-    game.renderWorld(lag, sm);
+    Game::game->renderWorld(lag, sm);
 }
 
-void Engine::renderSSAO() {
+static void renderSSAO() {
     shaders.ssao.use();
 
     Matrix rProj;
@@ -93,6 +115,7 @@ void Engine::renderSSAO() {
     rProj *= worldProj;
 
     shaders.ssao.setMatrix("proj", rProj.getValues());
+    const Size& size = window.getSize();
     shaders.ssao.setInt("width", size.width);
     shaders.ssao.setInt("height", size.height);
     framebuffers.world.bindTextureTo(0, 0);
@@ -107,7 +130,7 @@ void Engine::renderSSAO() {
     rectangle.draw();
 }
 
-void Engine::renderPostWorld() {
+static void renderPostWorld() {
     GL::bindMainFramebuffer();
     GL::clear();
     shaders.postWorld.use();
@@ -115,15 +138,16 @@ void Engine::renderPostWorld() {
     framebuffers.ssaoBlur.bindTextureTo(0, 1);
     framebuffers.world.bindTextureTo(3, 2);
     framebuffers.world.bindTextureTo(1, 3);
-    shaders.postWorld.setInt("ssao", renderSettings.ssao);
-    shaders.postWorld.setInt("shadows", renderSettings.shadows);
+    shaders.postWorld.setInt("ssao", useSsao);
+    shaders.postWorld.setInt("shadows", useShadows);
     rectangle.draw();
 }
 
-void Engine::renderOverlay(float lag) {
+static void renderOverlay(float lag) {
     GL::disableDepthTesting();
     shaders.overlay.use();
 
+    const Size& size = window.getSize();
     Matrix m;
     m.scale(Vector3(2.0f / size.width, -2.0f / size.height, 1.0f))
         .translate(Vector3(-1.0f, 1.0f, 0.0f));
@@ -133,14 +157,14 @@ void Engine::renderOverlay(float lag) {
 
     GL::enableBlending();
     ShaderMatrix sm(shaders.overlay, model, m);
-    game.renderOverlay(lag, sm, renderer);
+    Game::game->renderOverlay(lag, sm, renderer);
     GL::disableBlending();
 }
 
-void Engine::updateWorldProjection() {
+static void updateWorldProjection() {
     worldProj = frustum.updateProjection();
 
-    if(!renderSettings.shadows) {
+    if(!useShadows) {
         return;
     }
 
@@ -150,8 +174,8 @@ void Engine::updateWorldProjection() {
     worldShadowProj.set(3, Vector4(0.0f, 0.0f, 0.0f, 1.0f));
 }
 
-void Engine::updateWorldView() {
-    if(!renderSettings.shadows) {
+static void updateWorldView() {
+    if(!useShadows) {
         return;
     }
 
@@ -166,4 +190,73 @@ void Engine::updateWorldView() {
     worldShadowView.set(2,
                         Vector4(back[0], back[1], back[2], back.dot(-center)));
     worldShadowView.set(3, Vector4(0.0f, 0.0f, 0.0f, 1.0f));
+}
+
+static void startRender(float lag) {
+    const Size& size = window.getSize();
+    if(size.width != lastSize.width || size.height != lastSize.height) {
+        GL::setViewport(size.width, size.height);
+        framebuffers.resize(size);
+        lastSize = size;
+    }
+    GL::printError("loop error");
+
+    updateWorldProjection();
+    updateWorldView();
+
+    if(useShadows) {
+        renderShadow(lag);
+    }
+    renderWorld(lag);
+    if(useSsao) {
+        renderSSAO();
+    }
+    renderPostWorld();
+    renderOverlay(lag);
+}
+
+struct Loop final {
+    void render(float lag) {
+        startRender(lag);
+    }
+
+    void tick() {
+        Game::game->tick();
+    }
+
+    bool isRunning() const {
+        return Game::game->isRunning();
+    }
+};
+
+void Engine::run() {
+    Loop loop;
+    window.run(loop, 50'000'000);
+}
+
+void Engine::setTextInput(TextInput* input) {
+    window.textInput = input;
+    if(input != nullptr) {
+        input->setActive(true);
+    }
+}
+
+bool Engine::isActiveTextInput(TextInput* input) {
+    return window.textInput == input;
+}
+
+Buttons& Engine::getButtons() {
+    return window.buttons;
+}
+
+const Size& Engine::getSize() {
+    return window.getSize();
+}
+
+const Clock& Engine::getFrameClock() {
+    return window.getFrameClock();
+}
+
+const Clock& Engine::getTickClock() {
+    return window.getTickClock();
 }

+ 14 - 42
client/rendering/Engine.h

@@ -1,50 +1,22 @@
 #ifndef ENGINE_H
 #define ENGINE_H
 
-#include "client/Game.h"
-#include "client/rendering/Framebuffers.h"
-#include "client/rendering/Mesh.h"
-#include "client/rendering/NoiseTexture.h"
-#include "client/rendering/RenderSettings.h"
-#include "client/rendering/Renderer.h"
-#include "client/rendering/Shaders.h"
-#include "math/Frustum.h"
+#include "input/Buttons.h"
+#include "input/TextInput.h"
+#include "utils/Clock.h"
+#include "utils/Size.h"
 
-class Engine final {
-    Shaders& shaders;
-    Framebuffers& framebuffers;
-    Size lastSize;
-    const Size& size;
-    RenderSettings& renderSettings;
-    Game& game;
+namespace Engine {
+    bool init();
+    void run();
 
-    Frustum frustum;
-    MatrixStack<16> model;
-    Renderer renderer;
-    NoiseTexture ssaoNoise;
-    Mesh rectangle;
+    void setTextInput(TextInput* input);
+    bool isActiveTextInput(TextInput* input);
 
-    Matrix worldProj;
-    Matrix worldView;
-    Matrix worldShadowProj;
-    Matrix worldShadowView;
-    Matrix worldShadowProjView;
-
-public:
-    Engine(Shaders& shaders, Framebuffers& fb, const Size& size,
-           RenderSettings& renderSettings, Game& game);
-    void render(float lag);
-    void tick();
-    bool isRunning() const;
-
-private:
-    void renderShadow(float lag);
-    void renderWorld(float lag);
-    void renderSSAO();
-    void renderPostWorld();
-    void renderOverlay(float lag);
-    void updateWorldProjection();
-    void updateWorldView();
-};
+    Buttons& getButtons();
+    const Size& getSize();
+    const Clock& getFrameClock();
+    const Clock& getTickClock();
+}
 
 #endif

+ 4 - 0
client/rendering/Mesh.cpp

@@ -2,7 +2,11 @@
 #include "rendering/Attributes.h"
 
 Mesh::Mesh() : vertices(0) {
+}
+
+bool Mesh::init() {
     vertexBuffer.init(Attributes().addFloat(3).addFloat(2).addFloat(3));
+    return false;
 }
 
 void Mesh::build(const TypedBuffer<Triangle>& buffer) {

+ 4 - 4
client/rendering/Mesh.h

@@ -6,15 +6,15 @@
 #include "utils/TypedBuffer.h"
 
 class Mesh final {
+    VertexBuffer vertexBuffer;
+    int vertices;
+
 public:
     Mesh();
+    bool init();
 
     void build(const TypedBuffer<Triangle>& buffer);
     void draw();
-
-private:
-    VertexBuffer vertexBuffer;
-    int vertices;
 };
 
 #endif

+ 2 - 1
client/rendering/NoiseTexture.cpp

@@ -2,7 +2,7 @@
 #include "utils/Array.h"
 #include "utils/Random.h"
 
-NoiseTexture::NoiseTexture() {
+bool NoiseTexture::init() {
     texture.init(TextureFormat::float32(3), 0);
     Random r(1);
     Array<float, 48> data;
@@ -10,6 +10,7 @@ NoiseTexture::NoiseTexture() {
         data[i] = r.nextFloat() * 2.0f - 1.0f;
     }
     texture.setData(4, 4, data.begin());
+    return false;
 }
 
 void NoiseTexture::bindTo(int index) const {

+ 1 - 2
client/rendering/NoiseTexture.h

@@ -7,8 +7,7 @@ class NoiseTexture final {
     Texture texture;
 
 public:
-    NoiseTexture();
-
+    bool init();
     void bindTo(int index) const;
 };
 

+ 0 - 4
client/rendering/RenderSettings.cpp

@@ -1,4 +0,0 @@
-#include "client/rendering/RenderSettings.h"
-
-RenderSettings::RenderSettings() : ssao(true), shadows(false), testRadius(0.01f), testBias(0.0002f), bump(0.5f) {
-}

+ 0 - 14
client/rendering/RenderSettings.h

@@ -1,14 +0,0 @@
-#ifndef RENDERSETTINGS_H
-#define RENDERSETTINGS_H
-
-struct RenderSettings final {
-    RenderSettings();
-
-    bool ssao;
-    bool shadows;
-    float testRadius;
-    float testBias;
-    float bump;
-};
-
-#endif

+ 5 - 0
client/rendering/Renderer.cpp

@@ -6,12 +6,17 @@
 Renderer::Renderer()
     : buffer(16), text(nullptr), index(0), maxIndex(0), x(0.0f), y(0.0f),
       vertices(0) {
+}
+
+bool Renderer::init() {
     Error error = font.load("resources/font8x8.png", 0);
     if(error.has()) {
         LOG_WARNING(error.message);
+        return true;
     }
     vertexBuffer.init(Attributes().addFloat(2).addFloat(2).addColor4());
     vertexBuffer.setStreamData(1024 * 1024);
+    return false;
 }
 
 void Renderer::setupStringRead(const char* s, int limit) {

+ 1 - 0
client/rendering/Renderer.h

@@ -21,6 +21,7 @@ class Renderer final {
 
 public:
     Renderer();
+    bool init();
 
     void renderString(const Vector2& pos, const char* text, int limit = -1);
     Vector2 getStringSize(const char* text, int limit = -1);

+ 1 - 0
client/rendering/renderer/WorldRenderer.cpp

@@ -2,6 +2,7 @@
 #include "utils/Logger.h"
 
 WorldRenderer::WorldRenderer(const World& world) : world(world) {
+    mesh.init();
     Error error = texture.load("resources/textures.png", 4);
     if(error.has()) {
         LOG_WARNING(error.message);

+ 1 - 1
meson.build

@@ -27,10 +27,10 @@ src_client = ['client/Main.cpp',
     'client/rendering/Shaders.cpp',
     'client/rendering/Mesh.cpp',
     'client/Game.cpp',
+    'client/GameClient.cpp',
     'client/rendering/ShaderMatrix.cpp',
     'client/rendering/NoiseTexture.cpp',
     'client/input/Controller.cpp',
-    'client/rendering/RenderSettings.cpp',
     'client/rendering/Renderer.cpp',
     'client/rendering/renderer/WorldRenderer.cpp',
     'client/rendering/Vertex.cpp',

+ 1 - 1
subprojects/gaming-core

@@ -1 +1 @@
-Subproject commit 87aa3c8bed59c2847831ac939dbc644b2d1c1f3f
+Subproject commit d965a3542acbce525e4372258c1e5b1ef61bdc63