Browse Source

removed redundant shader names, gui experiments, core update,
refactoring, font renderer became a general immediate renderer

Kajetan Johannes Hammerle 3 years ago
parent
commit
3dd8a4cd7a

+ 13 - 9
client/Game.cpp

@@ -6,7 +6,8 @@ Game::Game(TextInput& textInput, const Controller& controller, const Clock& fps,
            const Clock& tps, RenderSettings& settings, const Size& size,
            Client& client)
     : textInput(textInput), controller(controller), fps(fps), tps(tps),
-      renderSettings(settings), size(size), client(client),
+      renderSettings(settings), size(size), client(client), state(State::START),
+      baseGUI(size, textInput, controller), startGUI(baseGUI),
       world(blockRegistry), worldRenderer(world), connected(false) {
     pos = Vector3(16.0f, 30.0f, -10.0f);
     rotation = Quaternion(Vector3(1.0f, 0.0f, 0.0f), 30) * rotation;
@@ -68,24 +69,27 @@ void Game::tick() {
     }
 }
 
-void Game::renderWorld(float lag, Renderer& renderer) {
-    renderer.update(Utils::interpolate(lastPos, pos, lag),
-                    lastRotation.lerp(lag, rotation));
-    worldRenderer.render(lag, renderer);
+void Game::renderWorld(float lag, ShaderMatrix& sm) {
+    sm.update(Utils::interpolate(lastPos, pos, lag),
+              lastRotation.lerp(lag, rotation));
+    worldRenderer.render(lag, sm);
 }
 
-void Game::renderTextOverlay(float lag, Renderer& renderer, FontRenderer& fr) {
+void Game::renderOverlay(float lag, ShaderMatrix& sm, Renderer& r) {
+    switch(state) {
+        case State::START: startGUI.render(lag, sm, r); break;
+    }
     (void)lag;
-    renderer.scale(2.0f).update();
+    sm.identity().scale(2.0f).update();
     StringBuffer<100> s;
     s.append("FPS: &074")
         .append(fps.getUpdatesPerSecond())
         .append(" &999TPS: &722")
         .append(tps.getUpdatesPerSecond());
-    fr.drawString(10, 10, s);
+    r.drawString(10, 10, s);
     s.clear();
     textInput.getInput(s);
-    fr.drawString(10, 30, s);
+    r.drawString(10, 30, s);
 }
 
 bool Game::isRunning() const {

+ 10 - 4
client/Game.h

@@ -1,10 +1,11 @@
 #ifndef GAME_H
 #define GAME_H
 
+#include "client/gui/StartGUI.h"
 #include "client/input/Controller.h"
-#include "client/rendering/FontRenderer.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 "gaming-core/input/TextInput.h"
@@ -15,14 +16,15 @@
 
 class Game final {
 public:
+    enum State { START };
+
     Game(TextInput& textInput, const Controller& controller, const Clock& fps,
          const Clock& tps, RenderSettings& renderSettings, const Size& size,
          Client& client);
 
     void tick();
-    void renderWorld(float lag, Renderer& renderer);
-    void renderWorldLines(float lag, Renderer& renderer);
-    void renderTextOverlay(float lag, Renderer& renderer, FontRenderer& fr);
+    void renderWorld(float lag, ShaderMatrix& sm);
+    void renderOverlay(float lag, ShaderMatrix& sm, Renderer& r);
 
     bool isRunning() const;
 
@@ -39,6 +41,10 @@ private:
     const Size& size;
     Client& client;
 
+    State state;
+    BaseGUI baseGUI;
+    StartGUI startGUI;
+
     Vector3 lastPos;
     Vector3 pos;
     Quaternion lastRotation;

+ 12 - 0
client/gui/BaseGUI.cpp

@@ -0,0 +1,12 @@
+#include "client/gui/BaseGUI.h"
+
+BaseGUI::BaseGUI(const Size& size, TextInput& textInput,
+                 const Controller& controller)
+    : size(size), textInput(textInput), controller(controller) {
+}
+
+void BaseGUI::render(float lag, ShaderMatrix& sm, Renderer& r) {
+    (void)lag;
+    (void)sm;
+    (void)r;
+}

+ 22 - 0
client/gui/BaseGUI.h

@@ -0,0 +1,22 @@
+#ifndef BASE_GUI_H
+#define BASE_GUI_H
+
+#include "client/input/Controller.h"
+#include "client/rendering/Renderer.h"
+#include "client/rendering/ShaderMatrix.h"
+#include "gaming-core/input/TextInput.h"
+#include "gaming-core/utils/Size.h"
+
+class BaseGUI final {
+    const Size& size;
+    TextInput& textInput;
+    const Controller& controller;
+
+public:
+    BaseGUI(const Size& size, TextInput& textInput,
+            const Controller& controller);
+
+    void render(float lag, ShaderMatrix& sm, Renderer& r);
+};
+
+#endif

+ 11 - 0
client/gui/StartGUI.cpp

@@ -0,0 +1,11 @@
+#include "client/gui/StartGUI.h"
+
+StartGUI::StartGUI(BaseGUI base) : base(base) {
+}
+
+void StartGUI::render(float lag, ShaderMatrix& sm, Renderer& r) {
+    base.render(lag, sm, r);
+
+    sm.scale(2.0f).update();
+    r.drawRectangle(0, 0, 100, 200, Color4(0xFF, 0x00, 0xFF, 0xFF));
+}

+ 15 - 0
client/gui/StartGUI.h

@@ -0,0 +1,15 @@
+#ifndef START_GUI_H
+#define START_GUI_H
+
+#include "client/gui/BaseGUI.h"
+
+class StartGUI final {
+    BaseGUI base;
+
+public:
+    StartGUI(BaseGUI base);
+
+    void render(float lag, ShaderMatrix& sm, Renderer& r);
+};
+
+#endif

+ 12 - 13
client/rendering/Engine.cpp

@@ -1,5 +1,5 @@
 #include "client/rendering/Engine.h"
-#include "client/rendering/Renderer.h"
+#include "client/rendering/ShaderMatrix.h"
 #include "gaming-core/wrapper/GL.h"
 
 Engine::Engine(Shaders& shaders, Framebuffers& fb, const Size& size,
@@ -30,7 +30,7 @@ void Engine::renderTick(float lag, Game& game) {
         renderSSAO();
     }
     renderPostWorld();
-    renderTextOverlay(lag, game);
+    renderOverlay(lag, game);
 }
 
 void Engine::renderShadow(float lag, Game& game) {
@@ -42,8 +42,8 @@ void Engine::renderShadow(float lag, Game& game) {
     shaders.shadow.setMatrix("projView", worldShadowProjView.getValues());
     model.clear();
     shaders.shadow.setMatrix("model", model.peek().getValues());
-    Renderer renderer(shaders.shadow, model, worldView);
-    game.renderWorld(lag, renderer);
+    ShaderMatrix sm(shaders.shadow, model, worldView);
+    game.renderWorld(lag, sm);
 }
 
 void Engine::renderWorld(float lag, Game& game) {
@@ -65,8 +65,8 @@ void Engine::renderWorld(float lag, Game& game) {
     shaders.world.setInt("shadows", renderSettings.shadows);
     shaders.world.setFloat("radius", renderSettings.testRadius);
     shaders.world.setFloat("zbias", renderSettings.testBias);
-    Renderer renderer(shaders.world, model, worldView);
-    game.renderWorld(lag, renderer);
+    ShaderMatrix sm(shaders.world, model, worldView);
+    game.renderWorld(lag, sm);
 }
 
 void Engine::renderSSAO() {
@@ -104,21 +104,20 @@ void Engine::renderPostWorld() {
     rectangle.draw();
 }
 
-void Engine::renderTextOverlay(float lag, Game& game) {
+void Engine::renderOverlay(float lag, Game& game) {
     GL::disableDepthTesting();
-    shaders.text.use();
+    shaders.overlay.use();
 
     Matrix m;
-    shaders.text.setMatrix("proj", m.getValues());
     m.scale(Vector3(2.0f / size.width, -2.0f / size.height, 1.0f))
         .translate(Vector3(-1.0f, 1.0f, 0.0f));
-    shaders.text.setMatrix("view", m.getValues());
+    shaders.overlay.setMatrix("view", m.getValues());
     model.clear();
-    shaders.text.setMatrix("model", model.peek().getValues());
+    shaders.overlay.setMatrix("model", model.peek().getValues());
 
     GL::enableBlending();
-    Renderer renderer(shaders.text, model, m);
-    game.renderTextOverlay(lag, renderer, fontRenderer);
+    ShaderMatrix sm(shaders.overlay, model, m);
+    game.renderOverlay(lag, sm, renderer);
     GL::disableBlending();
 }
 

+ 9 - 8
client/rendering/Engine.h

@@ -1,18 +1,19 @@
 #ifndef ENGINE_H
 #define ENGINE_H
 
-#include "client/rendering/Shaders.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/Game.h"
+#include "client/rendering/Renderer.h"
+#include "client/rendering/Shaders.h"
 #include "gaming-core/math/Frustum.h"
-#include "client/rendering/FontRenderer.h"
-#include "client/rendering/NoiseTexture.h"
-#include "client/rendering/Mesh.h"
 
 class Engine final {
 public:
-    Engine(Shaders& shaders, Framebuffers& fb, const Size& size, RenderSettings& renderSettings);
+    Engine(Shaders& shaders, Framebuffers& fb, const Size& size,
+           RenderSettings& renderSettings);
     void renderTick(float lag, Game& game);
 
 private:
@@ -20,7 +21,7 @@ private:
     void renderWorld(float lag, Game& game);
     void renderSSAO();
     void renderPostWorld();
-    void renderTextOverlay(float lag, Game& game);
+    void renderOverlay(float lag, Game& game);
     void updateWorldProjection();
     void updateWorldView();
 
@@ -31,7 +32,7 @@ private:
 
     Frustum frustum;
     MatrixStack<16> model;
-    FontRenderer fontRenderer;
+    Renderer renderer;
     NoiseTexture ssaoNoise;
     Mesh rectangle;
 

+ 0 - 52
client/rendering/FontRenderer.cpp

@@ -1,52 +0,0 @@
-#include "client/rendering/FontRenderer.h"
-#include "gaming-core/rendering/Attributes.h"
-#include "gaming-core/utils/Buffer.h"
-
-FontRenderer::FontRenderer() : tex("resources/font8x8.png") {
-    vertexBuffer.setAttributes(
-        Attributes().addFloat(2).addFloat(2).addColor4());
-    vertexBuffer.setStreamData(MAX_CHARS * VERTEX_SIZE * 4);
-}
-
-void FontRenderer::drawString(float x, float y, const char* text) {
-    Buffer buffer(MAX_CHARS * VERTEX_SIZE * 4);
-
-    int index = 0;
-    Color4 color(0xFF, 0xFF, 0xFF, 0xFF);
-
-    while(text[index] != '\0' && index < MAX_CHARS) {
-        char32_t c = text[index];
-        if(c > 128 && index + 1 < MAX_CHARS && text[index + 1] != '\0') {
-            index++;
-            c = (text[index] & 0x3F) | ((c & 0x1F) << 6);
-        }
-        if(c == '&') {
-            if(text[index + 1] == '\0' || text[index + 2] == '\0' ||
-               text[index + 3] == '\0') {
-                break;
-            }
-            color[0] = ((text[index + 1] - '0') * 255) / 9;
-            color[1] = ((text[index + 2] - '0') * 255) / 9;
-            color[2] = ((text[index + 3] - '0') * 255) / 9;
-            index += 4;
-            continue;
-        }
-
-        float minX = (c & 0xF) * (1.0f / 16.0f) + 1.0f / 128.0f;
-        float minY = (c >> 4) * (1.0f / 16.0f);
-        float maxX = minX + (1.0f / 16.0f) - 2.0f / 128.0f;
-        float maxY = minY + (1.0f / 16.0f);
-
-        buffer.add(x).add(y).add(minX).add(minY).add(color);
-        buffer.add(x).add(y + 8).add(minX).add(maxY).add(color);
-        buffer.add(x + 6).add(y).add(maxX).add(minY).add(color);
-        buffer.add(x + 6).add(y + 8).add(maxX).add(maxY).add(color);
-
-        x += 6;
-        index++;
-    }
-
-    tex.bindTo(0);
-    vertexBuffer.updateData(0, buffer.getLength(), buffer);
-    vertexBuffer.drawStrip(buffer.getLength() / VERTEX_SIZE);
-}

+ 0 - 21
client/rendering/FontRenderer.h

@@ -1,21 +0,0 @@
-#ifndef FONTRENDERER_H
-#define FONTRENDERER_H
-
-#include "gaming-core/rendering/FileTexture.h"
-#include "gaming-core/rendering/VertexBuffer.h"
-#include "gaming-core/utils/Color.h"
-
-class FontRenderer final {
-    static constexpr int MAX_CHARS = 256;
-    static constexpr int VERTEX_SIZE = 4 * sizeof(float) + sizeof(Color4);
-
-    VertexBuffer vertexBuffer;
-    FileTexture tex;
-
-public:
-    FontRenderer();
-
-    void drawString(float x, float y, const char* text);
-};
-
-#endif

+ 59 - 72
client/rendering/Renderer.cpp

@@ -1,81 +1,68 @@
 #include "client/rendering/Renderer.h"
+#include "gaming-core/rendering/Attributes.h"
+#include "gaming-core/utils/Buffer.h"
 
-Renderer::Renderer(Shader& shader, MatrixStack<16>& stack, Matrix& view) : shader(shader), stack(stack), view(view) {
+Renderer::Renderer() : buffer(16), font("resources/font8x8.png") {
+    vertexBuffer.setAttributes(
+        Attributes().addFloat(2).addFloat(2).addColor4());
+    vertexBuffer.setStreamData(1024 * 1024);
 }
 
-void Renderer::pop() {
-    stack.pop();
+void Renderer::drawString(float x, float y, const char* text) {
+    buffer.clear();
+    int index = 0;
+    int vertices = 0;
+    Color4 color(0xFF, 0xFF, 0xFF, 0x00);
+    while(text[index] != '\0') {
+        char32_t c = text[index];
+        if(c > 128 && text[index + 1] != '\0') {
+            index++;
+            c = (text[index] & 0x3F) | ((c & 0x1F) << 6);
+        }
+        if(c == '&') {
+            if(text[index + 1] == '\0' || text[index + 2] == '\0' ||
+               text[index + 3] == '\0') {
+                break;
+            }
+            color[0] = ((text[index + 1] - '0') * 255) / 9;
+            color[1] = ((text[index + 2] - '0') * 255) / 9;
+            color[2] = ((text[index + 3] - '0') * 255) / 9;
+            index += 4;
+            continue;
+        }
+
+        float minX = (c & 0xF) * (1.0f / 16.0f) + 1.0f / 128.0f;
+        float minY = (c >> 4) * (1.0f / 16.0f);
+        float maxX = minX + (1.0f / 16.0f) - 2.0f / 128.0f;
+        float maxY = minY + (1.0f / 16.0f);
+
+        buffer.add(x).add(y).add(minX).add(minY).add(color);
+        buffer.add(x).add(y + 8).add(minX).add(maxY).add(color);
+        buffer.add(x + 6).add(y).add(maxX).add(minY).add(color);
+        buffer.add(x + 6).add(y + 8).add(maxX).add(maxY).add(color);
+
+        x += 6;
+        index++;
+        vertices += 4;
+    }
+
+    font.bindTo(0);
+    update();
+    vertexBuffer.drawStrip(vertices);
 }
 
-void Renderer::push() {
-    stack.push();
+void Renderer::drawRectangle(float x, float y, float width, float height,
+                             Color4 c) {
+    buffer.clear();
+    buffer.add(x).add(y).add(0.0f).add(0.0f).add(c);
+    buffer.add(x).add(y + height).add(0.0f).add(0.0f).add(c);
+    buffer.add(x + width).add(y).add(0.0f).add(0.0f).add(c);
+    buffer.add(x + width).add(y + height).add(0.0f).add(0.0f).add(c);
+    update();
+    vertexBuffer.drawStrip(4);
 }
 
-Renderer& Renderer::update() {
-    shader.setMatrix("model", stack.peek().getValues());
-    return *this;
-}
-
-Renderer& Renderer::update(const Vector3& pos, const Quaternion& rotation) {
-    Vector3 right = rotation * Vector3(1.0f, 0.0f, 0.0f);
-    Vector3 up = rotation * Vector3(0.0f, 1.0f, 0.0f);
-    Vector3 back = rotation * Vector3(0.0f, 0.0f, -1.0f);
-
-    view.set(0, Vector4(right[0],  right[1], right[2], right.dot(-pos)));
-    view.set(1, Vector4(up[0], up[1], up[2], up.dot(-pos)));
-    view.set(2, Vector4(back[0], back[1], back[2], back.dot(-pos)));
-    view.set(3, Vector4(0.0f, 0.0f, 0.0f, 1.0f));
-    
-    shader.setMatrix("view", view.getValues());
-    return *this;
-}
-
-Renderer& Renderer::scale(float sx, float sy, float sz) {
-    stack.peek().scale(Vector3(sx, sy, sz));
-    return *this;
-}
-
-Renderer& Renderer::scale(float s) {
-    stack.peek().scale(s);
-    return *this;
-}
-
-Renderer& Renderer::translate(float tx, float ty, float tz) {
-    stack.peek().translate(Vector3(tx, ty, tz));
-    return *this;
-}
-
-Renderer& Renderer::translateX(float tx) {
-    stack.peek().translateX(tx);
-    return *this;
-}
-
-Renderer& Renderer::translateY(float ty) {
-    stack.peek().translateY(ty);
-    return *this;
-}
-
-Renderer& Renderer::translateZ(float tz) {
-    stack.peek().translateZ(tz);
-    return *this;
-}
-
-Renderer& Renderer::translateTo(float tx, float ty, float tz) {
-    stack.peek().translateTo(Vector3(tx, ty, tz));
-    return *this;
-}
-
-Renderer& Renderer::rotateX(float degrees) {
-    stack.peek().rotateX(degrees);
-    return *this;
-}
-
-Renderer& Renderer::rotateY(float degrees) {
-    stack.peek().rotateY(degrees);
-    return *this;
-}
-
-Renderer& Renderer::rotateZ(float degrees) {
-    stack.peek().rotateZ(degrees);
-    return *this;
+void Renderer::update() {
+    vertexBuffer.updateData(
+        0, std::min(buffer.getLength(), vertexBuffer.getSize()), buffer);
 }

+ 12 - 26
client/rendering/Renderer.h

@@ -1,38 +1,24 @@
 #ifndef RENDERER_H
 #define RENDERER_H
 
-#include "gaming-core/math/MatrixStack.h"
-#include "gaming-core/math/Quaternion.h"
-#include "gaming-core/math/Vector.h"
-#include "gaming-core/rendering/Shader.h"
+#include "gaming-core/rendering/FileTexture.h"
+#include "gaming-core/rendering/VertexBuffer.h"
+#include "gaming-core/utils/Buffer.h"
+#include "gaming-core/utils/Color.h"
 
 class Renderer final {
-public:
-    Renderer(Shader& shader, MatrixStack<16>& stack, Matrix& view);
-
-    void pop();
-    void push();
-
-    Renderer& update();
-    Renderer& update(const Vector3& pos, const Quaternion& rotation);
+    VertexBuffer vertexBuffer;
+    Buffer buffer;
+    FileTexture font;
 
-    Renderer& scale(float sx, float sy, float sz);
-    Renderer& scale(float s);
-
-    Renderer& translate(float tx, float ty, float tz);
-    Renderer& translateX(float tx);
-    Renderer& translateY(float ty);
-    Renderer& translateZ(float tz);
-    Renderer& translateTo(float tx, float ty, float tz);
+public:
+    Renderer();
 
-    Renderer& rotateX(float degrees);
-    Renderer& rotateY(float degrees);
-    Renderer& rotateZ(float degrees);
+    void drawString(float x, float y, const char* text);
+    void drawRectangle(float x, float y, float width, float height, Color4 c);
 
 private:
-    Shader& shader;
-    MatrixStack<16>& stack;
-    Matrix& view;
+    void update();
 };
 
 #endif

+ 88 - 0
client/rendering/ShaderMatrix.cpp

@@ -0,0 +1,88 @@
+#include "client/rendering/ShaderMatrix.h"
+
+ShaderMatrix::ShaderMatrix(Shader& shader, MatrixStack<16>& stack, Matrix& view)
+    : shader(shader), stack(stack), view(view) {
+}
+
+void ShaderMatrix::pop() {
+    stack.pop();
+}
+
+void ShaderMatrix::push() {
+    stack.push();
+}
+
+ShaderMatrix& ShaderMatrix::update() {
+    shader.setMatrix("model", stack.peek().getValues());
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::update(const Vector3& pos,
+                                   const Quaternion& rotation) {
+    Vector3 right = rotation * Vector3(1.0f, 0.0f, 0.0f);
+    Vector3 up = rotation * Vector3(0.0f, 1.0f, 0.0f);
+    Vector3 back = rotation * Vector3(0.0f, 0.0f, -1.0f);
+
+    view.set(0, Vector4(right[0], right[1], right[2], right.dot(-pos)));
+    view.set(1, Vector4(up[0], up[1], up[2], up.dot(-pos)));
+    view.set(2, Vector4(back[0], back[1], back[2], back.dot(-pos)));
+    view.set(3, Vector4(0.0f, 0.0f, 0.0f, 1.0f));
+
+    shader.setMatrix("view", view.getValues());
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::scale(float sx, float sy, float sz) {
+    stack.peek().scale(Vector3(sx, sy, sz));
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::scale(float s) {
+    stack.peek().scale(s);
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::translate(float tx, float ty, float tz) {
+    stack.peek().translate(Vector3(tx, ty, tz));
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::translateX(float tx) {
+    stack.peek().translateX(tx);
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::translateY(float ty) {
+    stack.peek().translateY(ty);
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::translateZ(float tz) {
+    stack.peek().translateZ(tz);
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::translateTo(float tx, float ty, float tz) {
+    stack.peek().translateTo(Vector3(tx, ty, tz));
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::rotateX(float degrees) {
+    stack.peek().rotateX(degrees);
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::rotateY(float degrees) {
+    stack.peek().rotateY(degrees);
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::rotateZ(float degrees) {
+    stack.peek().rotateZ(degrees);
+    return *this;
+}
+
+ShaderMatrix& ShaderMatrix::identity() {
+    stack.peek().translateTo(Vector3());
+    return *this;
+}

+ 40 - 0
client/rendering/ShaderMatrix.h

@@ -0,0 +1,40 @@
+#ifndef SHADER_MATRIX_H
+#define SHADER_MATRIX_H
+
+#include "gaming-core/math/MatrixStack.h"
+#include "gaming-core/math/Quaternion.h"
+#include "gaming-core/math/Vector.h"
+#include "gaming-core/rendering/Shader.h"
+
+class ShaderMatrix final {
+public:
+    ShaderMatrix(Shader& shader, MatrixStack<16>& stack, Matrix& view);
+
+    void pop();
+    void push();
+
+    ShaderMatrix& update();
+    ShaderMatrix& update(const Vector3& pos, const Quaternion& rotation);
+
+    ShaderMatrix& scale(float sx, float sy, float sz);
+    ShaderMatrix& scale(float s);
+
+    ShaderMatrix& translate(float tx, float ty, float tz);
+    ShaderMatrix& translateX(float tx);
+    ShaderMatrix& translateY(float ty);
+    ShaderMatrix& translateZ(float tz);
+    ShaderMatrix& translateTo(float tx, float ty, float tz);
+
+    ShaderMatrix& rotateX(float degrees);
+    ShaderMatrix& rotateY(float degrees);
+    ShaderMatrix& rotateZ(float degrees);
+
+    ShaderMatrix& identity();
+
+private:
+    Shader& shader;
+    MatrixStack<16>& stack;
+    Matrix& view;
+};
+
+#endif

+ 11 - 9
client/rendering/Shaders.cpp

@@ -1,15 +1,17 @@
 #include "client/rendering/Shaders.h"
 
-Shaders::Shaders() :
-world("resources/shader/worldVertex.vs", "resources/shader/worldFragment.fs"),
-ssao("resources/shader/ssaoVertex.vs", "resources/shader/ssaoFragment.fs"),
-ssaoBlur("resources/shader/ssaoBlurVertex.vs", "resources/shader/ssaoBlurFragment.fs"),
-shadow("resources/shader/worldShadowVertex.vs", "resources/shader/worldShadowFragment.fs"),
-postWorld("resources/shader/worldPostVertex.vs", "resources/shader/worldPostFragment.fs"),
-text("resources/shader/textVertex.vs", "resources/shader/textFragment.fs") {
+Shaders::Shaders()
+    : world("resources/shader/world.vs", "resources/shader/world.fs"),
+      ssao("resources/shader/ssao.vs", "resources/shader/ssao.fs"),
+      ssaoBlur("resources/shader/ssaoBlur.vs", "resources/shader/ssaoBlur.fs"),
+      shadow("resources/shader/worldShadow.vs",
+             "resources/shader/worldShadow.fs"),
+      postWorld("resources/shader/worldPost.vs",
+                "resources/shader/worldPost.fs"),
+      overlay("resources/shader/overlay.vs", "resources/shader/overlay.fs") {
 }
 
 bool Shaders::hasError() const {
-    return world.hasError() || ssao.hasError() || ssaoBlur.hasError() || shadow.hasError() || postWorld.hasError() ||
-            text.hasError();
+    return world.hasError() || ssao.hasError() || ssaoBlur.hasError() ||
+           shadow.hasError() || postWorld.hasError() || overlay.hasError();
 }

+ 1 - 1
client/rendering/Shaders.h

@@ -12,7 +12,7 @@ struct Shaders final {
     Shader ssaoBlur;
     Shader shadow;
     Shader postWorld;
-    Shader text;
+    Shader overlay;
 };
 
 #endif

+ 3 - 3
client/rendering/renderer/WorldRenderer.cpp

@@ -15,13 +15,13 @@ WorldRenderer::WorldRenderer(const World& world)
     mesh.build(buffer);
 }
 
-void WorldRenderer::render(float lag, Renderer& renderer) {
+void WorldRenderer::render(float lag, ShaderMatrix& sm) {
     (void)lag;
-    (void)renderer;
+    (void)sm;
     texture.bindTo(0);
     for(int x = -1; x <= 1; x++) {
         for(int z = -1; z <= 1; z++) {
-            renderer.translateTo(world.getSize() * x, 0.0f, world.getSize() * z)
+            sm.translateTo(world.getSize() * x, 0.0f, world.getSize() * z)
                 .update();
             mesh.draw();
         }

+ 3 - 3
client/rendering/renderer/WorldRenderer.h

@@ -1,16 +1,16 @@
 #ifndef WORLDRENDERER_H
 #define WORLDRENDERER_H
 
-#include "client/rendering/Renderer.h"
-#include "common/world/World.h"
 #include "client/rendering/Mesh.h"
+#include "client/rendering/ShaderMatrix.h"
+#include "common/world/World.h"
 #include "gaming-core/rendering/FileTexture.h"
 
 class WorldRenderer {
 public:
     WorldRenderer(const World& world);
 
-    void render(float lag, Renderer& renderer);
+    void render(float lag, ShaderMatrix& sm);
     void addCube(TypedBuffer<Triangle>& buffer, float x, float y, float z);
     bool isAir(int x, int y, int z) const;
 

+ 1 - 1
gaming-core

@@ -1 +1 @@
-Subproject commit cc650ea739ef7837404d7e8f0c5676df2402c2ea
+Subproject commit 923055a1562c99d025bd0ee7477dd22929f209a7

+ 4 - 2
meson.build

@@ -49,14 +49,16 @@ sourcesClient = ['client/Main.cpp',
     'client/rendering/Shaders.cpp',
     'client/rendering/Mesh.cpp',
     'client/Game.cpp',
-    'client/rendering/FontRenderer.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',
-    'client/rendering/Triangle.cpp']
+    'client/rendering/Triangle.cpp',
+    'client/gui/BaseGUI.cpp',
+    'client/gui/StartGUI.cpp']
 
 sourcesTest = ['tests/Main.cpp']
 

+ 2 - 2
resources/shader/textFragment.fs → resources/shader/overlay.fs

@@ -3,10 +3,10 @@
 layout (binding = 0) uniform sampler2D samp;
 
 in vec2 varTex;
-in vec3 varColor;
+in vec4 varColor;
 
 out vec4 color;
 
 void main() {
-    color = vec4(varColor, texture(samp, varTex).r);
+    color = vec4(varColor.xyz, max(texture(samp, varTex).r, varColor.w));
 }  

+ 3 - 4
resources/shader/textVertex.vs → resources/shader/overlay.vs

@@ -2,17 +2,16 @@
 
 layout (location = 0) in vec2 position;
 layout (location = 1) in vec2 tex;
-layout (location = 2) in vec3 color;
+layout (location = 2) in vec4 color;
 
-uniform mat4 proj;
 uniform mat4 view;
 uniform mat4 model;
 
 out vec2 varTex;
-out vec3 varColor;
+out vec4 varColor;
 
 void main(void) { 
     varTex = tex;
     varColor = color;
-    gl_Position = proj * view * model * vec4(position, 0.0, 1.0);
+    gl_Position = view * model * vec4(position, 0.0, 1.0);
 }

+ 0 - 0
resources/shader/ssaoFragment.fs → resources/shader/ssao.fs


+ 0 - 0
resources/shader/ssaoBlurVertex.vs → resources/shader/ssao.vs


+ 0 - 0
resources/shader/ssaoBlurFragment.fs → resources/shader/ssaoBlur.fs


+ 0 - 0
resources/shader/ssaoVertex.vs → resources/shader/ssaoBlur.vs


+ 0 - 0
resources/shader/worldFragment.fs → resources/shader/world.fs


+ 0 - 0
resources/shader/worldVertex.vs → resources/shader/world.vs


+ 0 - 0
resources/shader/worldPostFragment.fs → resources/shader/worldPost.fs


+ 0 - 0
resources/shader/worldPostVertex.vs → resources/shader/worldPost.vs


+ 0 - 0
resources/shader/worldShadowFragment.fs → resources/shader/worldShadow.fs


+ 0 - 0
resources/shader/worldShadowVertex.vs → resources/shader/worldShadow.vs