Browse Source

core upgrade

Kajetan Johannes Hammerle 1 year ago
parent
commit
aa429966b8

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+subprojects/packagecache
+subprojects/glew-2.1.0
+subprojects/glew.wrap

+ 27 - 30
Engine.cpp

@@ -6,11 +6,11 @@
 #include "rendering/Shader.h"
 #include "rendering/Window.h"
 
-static Window window;
 static Shader shader;
+static Renderer renderer{shader};
 
 static bool parseArgs(int argAmount, char* const* args,
-                      WindowOptions& options) {
+                      Window::Options& options) {
     while(true) {
         switch(getopt(argAmount, args, "fv")) {
             case '?': return true;
@@ -22,11 +22,11 @@ static bool parseArgs(int argAmount, char* const* args,
 }
 
 bool Engine::init(int argAmount, char* const* args) {
-    WindowOptions options(3, 0, {800, 480}, true, "Pigine");
+    Window::Options options(3, 0, {800, 480}, true, "Pigine");
     if(parseArgs(argAmount, args, options)) {
         return true;
     }
-    Error error = window.open(options);
+    Error error = Window::open(options);
     if(error.has()) {
         error.message.printLine();
         return true;
@@ -37,41 +37,38 @@ bool Engine::init(int argAmount, char* const* args) {
         error.message.printLine();
         return true;
     }
-    Controller::init(window.buttons);
+    Controller::init();
     return false;
 }
 
-struct Loop {
-    Renderer renderer{shader};
-
-    void tick() {
-        Game::tick();
-    }
+static void tick() {
+    Game::tick();
+}
 
-    void render(float lag) {
-        GL::clear();
-        const Size& size = window.getSize();
-        GL::setViewport(size.width, size.height);
+static void render(float lag) {
+    GL::clear();
+    const IntVector2& size = Window::getSize();
+    GL::setViewport(size[0], size[1]);
 
-        Matrix view;
-        view.scale(Vector3(2.0f / size.width, -2.0f / size.height, 1.0f));
-        view.translate(Vector3(-1.0f, 1.0f, 0.0f));
-        shader.setMatrix("view", view.getValues());
+    Matrix view;
+    view.scale(Vector3(2.0f / size[0], -2.0f / size[1], 1.0f));
+    view.translate(Vector3(-1.0f, 1.0f, 0.0f));
+    shader.setMatrix("view", view.getValues());
 
-        Game::render(lag, renderer);
-        GL::printError("GL-Error");
-    }
+    Game::render(lag, renderer);
+    GL::printError("GL-Error");
+}
 
-    bool isRunning() const {
-        return Game::isRunning();
-    }
-};
+static bool isRunning() {
+    return Game::isRunning();
+}
 
 void Engine::start() {
-    Loop loop;
-    window.run(loop, 10'000'000);
+    renderer.init();
+    Window::show();
+    Window::run<isRunning, tick, render>(10'000'000);
 }
 
-const Size& Engine::getSize() {
-    return window.getSize();
+const IntVector2& Engine::getSize() {
+    return Window::getSize();
 }

+ 2 - 2
Engine.h

@@ -1,12 +1,12 @@
 #ifndef ENGINE_H
 #define ENGINE_H
 
-#include "utils/Size.h"
+#include "math/Vector.h"
 
 namespace Engine {
     bool init(int argAmount, char* const* args);
     void start();
-    const Size& getSize();
+    const IntVector2& getSize();
 }
 
 #endif

+ 46 - 61
Game.cpp

@@ -1,8 +1,7 @@
 #include "Game.h"
 #include "Engine.h"
+#include "data/List.h"
 #include "input/Controller.h"
-#include "utils/List.h"
-#include "utils/Utils.h"
 
 struct Line final {
     Vector2 a;
@@ -57,8 +56,10 @@ static void addForce(const Vector2& force) {
 }
 
 static void addMovement() {
-    physicsToggle = physicsToggle ^ Controller::start.wasReleased();
-    float movement = Controller::right.isDown() - Controller::left.isDown();
+    physicsToggle =
+        physicsToggle ^ Window::Controls::wasReleased(Controller::start);
+    float movement = Window::Controls::isDown(Controller::right) -
+                     Window::Controls::isDown(Controller::left);
     float actualSpeed = SPEED * (1.0f - std::abs(steepness) * onGround);
     if(physicsToggle) {
         addForce(Vector2(actualSpeed, 0.0f) * movement);
@@ -186,14 +187,15 @@ static void applyGravity() {
 
 static void handleJump() {
     bool justJumped = false;
-    if(Controller::a.isDown() && onGround) {
+    if(Window::Controls::isDown(Controller::a) && onGround) {
         jumpPower = 15.0f;
         onGround = false;
         justJumped = true;
     }
     addForce(Vector2(0.0f, jumpPower));
     jumpPower *= 0.9f;
-    jumpPower *= Controller::a.isDown() && (velocity[1] > 0.0f || justJumped);
+    jumpPower *= Window::Controls::isDown(Controller::a) &&
+                 (velocity[1] > 0.0f || justJumped);
 }
 
 static void relaunchProjectile() {
@@ -261,57 +263,40 @@ static void applyFriction() {
 
 static void addLines() {
     lines.clear();
-    lines.add({{0.0f, 0.0f}, windowSize * Vector2(1.0f, 0.0f)});
-    lines.add({{0.0f, 0.0f}, windowSize * Vector2(0.0f, 1.0f)});
-    lines.add({windowSize, windowSize * Vector2(1.0f, 0.0f)});
-    lines.add(
-        {windowSize * Vector2(0.75f, 0.0f), windowSize * Vector2(1.0f, 0.5f)});
-    lines.add({{0.0f, 30.0f}, {400.0f, 0.0f}});
-    lines.add({{0.0f, 60.0f}, {300.0f, 0.0f}});
-    lines.add({{0.0f, 90.0f}, {200.0f, 0.0f}});
-    lines.add({{0.0f, 120.0f}, {100.0f, 0.0f}});
-    lines.add({{100.0f, 180.0f}, {200.0f, 180.0f}});
-
-    lines.add({{200.0f, 180.0f},
-               {300.0f, 230.0f},
-               Color4(0xF0, 0x00, 0x00, 0xFF),
-               0.2f});
-    lines.add({{300.0f, 230.0f},
-               {400.0f, 280.0f},
-               Color4(0xC0, 0x00, 0x00, 0xFF),
-               0.4f});
-    lines.add({{400.0f, 280.0f},
-               {500.0f, 330.0f},
-               Color4(0x90, 0x00, 0x00, 0xFF),
-               0.6f});
-    lines.add({{500.0f, 330.0f},
-               {600.0f, 380.0f},
-               Color4(0x60, 0x00, 0x00, 0xFF),
-               0.8f});
-
-    lines.add({{300.0f, 140.0f},
-               {400.0f, 200.0f},
-               Color4(0xF0, 0x00, 0x00, 0xFF),
-               0.2f});
-    lines.add({{400.0f, 200.0f},
-               {500.0f, 220.0f},
-               Color4(0xC0, 0x00, 0x00, 0xFF),
-               0.4f});
-    lines.add({{500.0f, 220.0f},
-               {600.0f, 240.0f},
-               Color4(0x90, 0x00, 0x00, 0xFF),
-               0.6f});
-    lines.add({{600.0f, 240.0f},
-               {700.0f, 260.0f},
-               Color4(0x60, 0x00, 0x00, 0xFF),
-               0.8f});
-
-    lines.add({{600.0f, 380.0f}, {1000.0f, 580.0f}});
+    lines.add(Line({0.0f, 0.0f}, windowSize * Vector2(1.0f, 0.0f)));
+    lines.add(Line({0.0f, 0.0f}, windowSize * Vector2(0.0f, 1.0f)));
+    lines.add(Line(windowSize, windowSize * Vector2(1.0f, 0.0f)));
+    lines.add(windowSize * Vector2(0.75f, 0.0f),
+              windowSize * Vector2(1.0f, 0.5f));
+    lines.add(Line({0.0f, 30.0f}, {400.0f, 0.0f}));
+    lines.add(Line({0.0f, 60.0f}, {300.0f, 0.0f}));
+    lines.add(Line({0.0f, 90.0f}, {200.0f, 0.0f}));
+    lines.add(Line({0.0f, 120.0f}, {100.0f, 0.0f}));
+    lines.add(Line({100.0f, 180.0f}, {200.0f, 180.0f}));
+
+    lines.add(Line({200.0f, 180.0f}, {300.0f, 230.0f},
+                   Color4(0xF0, 0x00, 0x00, 0xFF), 0.2f));
+    lines.add(Line({300.0f, 230.0f}, {400.0f, 280.0f},
+                   Color4(0xC0, 0x00, 0x00, 0xFF), 0.4f));
+    lines.add(Line({400.0f, 280.0f}, {500.0f, 330.0f},
+                   Color4(0x90, 0x00, 0x00, 0xFF), 0.6f));
+    lines.add(Line({500.0f, 330.0f}, {600.0f, 380.0f},
+                   Color4(0x60, 0x00, 0x00, 0xFF), 0.8f));
+
+    lines.add(Line({300.0f, 140.0f}, {400.0f, 200.0f},
+                   Color4(0xF0, 0x00, 0x00, 0xFF), 0.2f));
+    lines.add(Line({400.0f, 200.0f}, {500.0f, 220.0f},
+                   Color4(0xC0, 0x00, 0x00, 0xFF), 0.4f));
+    lines.add(Line({500.0f, 220.0f}, {600.0f, 240.0f},
+                   Color4(0x90, 0x00, 0x00, 0xFF), 0.6f));
+    lines.add(Line({600.0f, 240.0f}, {700.0f, 260.0f},
+                   Color4(0x60, 0x00, 0x00, 0xFF), 0.8f));
+
+    lines.add(Line({600.0f, 380.0f}, {1000.0f, 580.0f}));
 }
 
 void Game::tick() {
-    windowSize = Vector2(static_cast<float>(Engine::getSize().width),
-                         static_cast<float>(Engine::getSize().height));
+    windowSize = Engine::getSize().toFloat();
     lastPosition = position;
     acceleration = Vector2();
 
@@ -387,11 +372,11 @@ void Game::tick() {
 void Game::render(float lag, Renderer& r) {
     r.translateTo(0.0f, 0.0f)
         .scale(1.0f, -1.0f)
-        .translateY(Engine::getSize().height)
+        .translateY(Engine::getSize()[1])
         .update();
     r.drawRectangle(waterPosition, waterSize, Color4(0x00, 0x00, 0xFF, 0xFF));
 
-    Vector2 pos = Utils::interpolate(lastPosition, position, lag);
+    Vector2 pos = Math::interpolate(lastPosition, position, lag);
 
     r.push();
     r.translateTo(0.0f, 0.0f)
@@ -400,7 +385,7 @@ void Game::render(float lag, Renderer& r) {
         .translate(pos)
         .translate(size * 0.5f)
         .scale(1.0f, -1.0f)
-        .translateY(Engine::getSize().height)
+        .translateY(Engine::getSize()[1])
         .update();
     r.drawRectangle(Vector2(), size, Color4(0xFF, 0x00, 0x00, 0xFF));
     r.pop();
@@ -410,10 +395,10 @@ void Game::render(float lag, Renderer& r) {
         r.push();
         r.translateTo(0.0f, 0.0f)
             .translate(size * 0.75f)
-            .rotate(Utils::interpolate(lastAngle, angle, lag) + i)
+            .rotate(Math::interpolate(lastAngle, angle, lag) + i)
             .translate(pos + size * 0.5f)
             .scale(1.0f, -1.0f)
-            .translateY(Engine::getSize().height)
+            .translateY(Engine::getSize()[1])
             .update();
         r.drawRectangle(Vector2(), size * 0.25f,
                         Color4(0xFF, 0x00, 0xFF, 0xFF));
@@ -422,7 +407,7 @@ void Game::render(float lag, Renderer& r) {
     }
 
     r.drawRectangle(
-        Utils::interpolate(projectileLastPosition, projectilePosition, lag),
+        Math::interpolate(projectileLastPosition, projectilePosition, lag),
         projectileSize, Color4(0xFF, 0xFF, 0x00, 0xFF));
 
     for(const Line& line : lines) {
@@ -458,5 +443,5 @@ void Game::render(float lag, Renderer& r) {
 }
 
 bool Game::isRunning() {
-    return !Controller::select.isDown();
+    return !Window::Controls::isDown(Controller::select);
 }

+ 52 - 49
input/Controller.cpp

@@ -1,55 +1,58 @@
 #include "input/Controller.h"
+#include "GLFW/glfw3.h"
 
-Button Controller::a{GLFW_KEY_A, "A"};
-Button Controller::b{GLFW_KEY_S, "B"};
-Button Controller::x{GLFW_KEY_X, "X"};
-Button Controller::y{GLFW_KEY_Z, "Y"};
-Button Controller::l{GLFW_KEY_Q, "L"};
-Button Controller::r{GLFW_KEY_W, "R"};
-Button Controller::start{GLFW_KEY_E, "Start"};
-Button Controller::select{GLFW_KEY_D, "Select"};
-Button Controller::left{GLFW_KEY_LEFT, "Left"};
-Button Controller::right{GLFW_KEY_RIGHT, "Right"};
-Button Controller::up{GLFW_KEY_UP, "Up"};
-Button Controller::down{GLFW_KEY_DOWN, "Down"};
+Window::Controls::ButtonId Controller::a = -1;
+Window::Controls::ButtonId Controller::b = -1;
+Window::Controls::ButtonId Controller::x = -1;
+Window::Controls::ButtonId Controller::y = -1;
+Window::Controls::ButtonId Controller::l = -1;
+Window::Controls::ButtonId Controller::r = -1;
+Window::Controls::ButtonId Controller::start = -1;
+Window::Controls::ButtonId Controller::select = -1;
+Window::Controls::ButtonId Controller::left = -1;
+Window::Controls::ButtonId Controller::right = -1;
+Window::Controls::ButtonId Controller::up = -1;
+Window::Controls::ButtonId Controller::down = -1;
 
-void Controller::init(Buttons& bs) {
-    bs.add(a);
-    bs.add(b);
-    bs.add(x);
-    bs.add(y);
-    bs.add(l);
-    bs.add(r);
-    bs.add(start);
-    bs.add(select);
-    bs.add(left);
-    bs.add(right);
-    bs.add(up);
-    bs.add(down);
+void Controller::init() {
+    a = Window::Controls::add("A");
+    b = Window::Controls::add("B");
+    x = Window::Controls::add("X");
+    y = Window::Controls::add("Y");
+    l = Window::Controls::add("L");
+    r = Window::Controls::add("R");
+    start = Window::Controls::add("Start");
+    select = Window::Controls::add("Select");
+    left = Window::Controls::add("Left");
+    right = Window::Controls::add("Right");
+    up = Window::Controls::add("Up");
+    down = Window::Controls::add("Down");
 
-    bs.mapGamepadButton(a, GLFW_GAMEPAD_BUTTON_A);
-    bs.mapGamepadButton(b, GLFW_GAMEPAD_BUTTON_B);
-    bs.mapGamepadButton(x, GLFW_GAMEPAD_BUTTON_X);
-    bs.mapGamepadButton(y, GLFW_GAMEPAD_BUTTON_Y);
-    bs.mapGamepadButton(l, GLFW_GAMEPAD_BUTTON_LEFT_BUMPER);
-    bs.mapGamepadButton(r, GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER);
-    bs.mapGamepadButton(select, GLFW_GAMEPAD_BUTTON_BACK);
-    bs.mapGamepadButton(start, GLFW_GAMEPAD_BUTTON_START);
-    bs.mapGamepadButton(select, GLFW_GAMEPAD_BUTTON_LEFT_THUMB);
-    bs.mapGamepadButton(start, GLFW_GAMEPAD_BUTTON_RIGHT_THUMB);
-    bs.mapGamepadButton(up, GLFW_GAMEPAD_BUTTON_DPAD_UP);
-    bs.mapGamepadButton(right, GLFW_GAMEPAD_BUTTON_DPAD_RIGHT);
-    bs.mapGamepadButton(down, GLFW_GAMEPAD_BUTTON_DPAD_DOWN);
-    bs.mapGamepadButton(left, GLFW_GAMEPAD_BUTTON_DPAD_LEFT);
+    Window::Controls::bindKey(a, GLFW_KEY_A);
+    Window::Controls::bindKey(b, GLFW_KEY_S);
+    Window::Controls::bindKey(x, GLFW_KEY_X);
+    Window::Controls::bindKey(y, GLFW_KEY_Z);
+    Window::Controls::bindKey(l, GLFW_KEY_Q);
+    Window::Controls::bindKey(r, GLFW_KEY_W);
+    Window::Controls::bindKey(start, GLFW_KEY_E);
+    Window::Controls::bindKey(select, GLFW_KEY_D);
+    Window::Controls::bindKey(left, GLFW_KEY_LEFT);
+    Window::Controls::bindKey(right, GLFW_KEY_RIGHT);
+    Window::Controls::bindKey(up, GLFW_KEY_UP);
+    Window::Controls::bindKey(down, GLFW_KEY_DOWN);
 
-    bs.mapGamepadAxis(left, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
-    bs.mapGamepadAxis(right, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
-    bs.mapGamepadAxis(left, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
-    bs.mapGamepadAxis(right, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
-    bs.mapGamepadAxis(up, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
-    bs.mapGamepadAxis(down, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
-    bs.mapGamepadAxis(up, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
-    bs.mapGamepadAxis(down, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
-    bs.mapGamepadAxis(l, 0.1f, GLFW_GAMEPAD_AXIS_LEFT_TRIGGER);
-    bs.mapGamepadAxis(r, 0.1f, GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER);
+    Window::Controls::bindGamepad(a, GLFW_GAMEPAD_BUTTON_A);
+    Window::Controls::bindGamepad(b, GLFW_GAMEPAD_BUTTON_B);
+    Window::Controls::bindGamepad(x, GLFW_GAMEPAD_BUTTON_X);
+    Window::Controls::bindGamepad(y, GLFW_GAMEPAD_BUTTON_Y);
+    Window::Controls::bindGamepad(l, GLFW_GAMEPAD_BUTTON_LEFT_BUMPER);
+    Window::Controls::bindGamepad(r, GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER);
+    Window::Controls::bindGamepad(select, GLFW_GAMEPAD_BUTTON_BACK);
+    Window::Controls::bindGamepad(start, GLFW_GAMEPAD_BUTTON_START);
+    Window::Controls::bindGamepad(select, GLFW_GAMEPAD_BUTTON_LEFT_THUMB);
+    Window::Controls::bindGamepad(start, GLFW_GAMEPAD_BUTTON_RIGHT_THUMB);
+    Window::Controls::bindGamepad(up, GLFW_GAMEPAD_BUTTON_DPAD_UP);
+    Window::Controls::bindGamepad(right, GLFW_GAMEPAD_BUTTON_DPAD_RIGHT);
+    Window::Controls::bindGamepad(down, GLFW_GAMEPAD_BUTTON_DPAD_DOWN);
+    Window::Controls::bindGamepad(left, GLFW_GAMEPAD_BUTTON_DPAD_LEFT);
 }

+ 14 - 14
input/Controller.h

@@ -1,23 +1,23 @@
 #ifndef CONTROLLER_H
 #define CONTROLLER_H
 
-#include "input/Buttons.h"
+#include "rendering/Window.h"
 
 namespace Controller {
-    extern Button a;
-    extern Button b;
-    extern Button x;
-    extern Button y;
-    extern Button l;
-    extern Button r;
-    extern Button start;
-    extern Button select;
-    extern Button left;
-    extern Button right;
-    extern Button up;
-    extern Button down;
+    extern Window::Controls::ButtonId a;
+    extern Window::Controls::ButtonId b;
+    extern Window::Controls::ButtonId x;
+    extern Window::Controls::ButtonId y;
+    extern Window::Controls::ButtonId l;
+    extern Window::Controls::ButtonId r;
+    extern Window::Controls::ButtonId start;
+    extern Window::Controls::ButtonId select;
+    extern Window::Controls::ButtonId left;
+    extern Window::Controls::ButtonId right;
+    extern Window::Controls::ButtonId up;
+    extern Window::Controls::ButtonId down;
 
-    void init(Buttons& buttons);
+    void init();
 }
 
 #endif

+ 1 - 1
meson.build

@@ -12,7 +12,7 @@ src = [
 ]
 
 libgamingcore_proj = subproject('gaming-core')
-libgamingcore_dep = libgamingcore_proj.get_variable('libgamingcore_dep')
+libgamingcore_dep = libgamingcore_proj.get_variable('gamingcore_dep')
 
 executable('pigine', 
     sources: src,

+ 4 - 4
rendering/ColorRenderer.cpp

@@ -1,10 +1,10 @@
 #include "rendering/ColorRenderer.h"
-#include "rendering/Attributes.h"
 #include "utils/Buffer.h"
 
-ColorRenderer::ColorRenderer() {
-    vertexBuffer.init(Attributes().addFloat(2).addSpacer().addColor4());
-    vertexBuffer.setStreamData(sizeof(Vertex) * 3);
+void ColorRenderer::init() {
+    vertexBuffer.init(
+        VertexBuffer::Attributes().addFloat(2).addSpacer().addColor4());
+    vertexBuffer.setData(sizeof(Vertex) * 3, nullptr, GL::STREAM_DRAW);
 }
 
 void ColorRenderer::draw(const Vertex& v1, const Vertex& v2, const Vertex& v3) {

+ 1 - 2
rendering/ColorRenderer.h

@@ -15,8 +15,7 @@ private:
     VertexBuffer vertexBuffer;
 
 public:
-    ColorRenderer();
-
+    void init();
     void draw(const Vertex& v1, const Vertex& v2, const Vertex& v3);
 };
 

+ 6 - 3
rendering/FontRenderer.cpp

@@ -1,14 +1,17 @@
 #include "rendering/FontRenderer.h"
-#include "rendering/Attributes.h"
 #include "utils/Buffer.h"
 #include "utils/Color.h"
 
 FontRenderer::FontRenderer() : activeTex(0), scale(1) {
+}
+
+void FontRenderer::init() {
     tex[0].load("resources/font8x8.png", 0);
     tex[1].load("resources/font16x16.png", 0);
     tex[2].load("resources/font24x24.png", 0);
-    vertexBuffer.init(Attributes().addFloat(2).addFloat(2).addColor4());
-    vertexBuffer.setStreamData(256 * 4 * sizeof(float) * 8);
+    vertexBuffer.init(
+        VertexBuffer::Attributes().addFloat(2).addFloat(2).addColor4());
+    vertexBuffer.setData(256 * 4 * sizeof(float) * 8, nullptr, GL::STREAM_DRAW);
 }
 
 float FontRenderer::drawString(float x, float y, const char* text) {

+ 4 - 4
rendering/FontRenderer.h

@@ -1,19 +1,19 @@
 #ifndef FONTRENDERER_H
 #define FONTRENDERER_H
 
-#include "rendering/FileTexture.h"
+#include "data/Array.h"
+#include "rendering/Texture.h"
 #include "rendering/VertexBuffer.h"
-#include "utils/Array.h"
-#include "utils/ArrayList.h"
 
 class FontRenderer final {
     VertexBuffer vertexBuffer;
-    Array<FileTexture, 3> tex;
+    Array<Texture, 3> tex;
     int activeTex;
     int scale;
 
 public:
     FontRenderer();
+    void init();
     float drawString(float x, float y, const char* text);
     void setSize(int size);
 };

+ 4 - 5
rendering/Mesh.cpp

@@ -1,8 +1,8 @@
 #include "rendering/Mesh.h"
-#include "rendering/Attributes.h"
 
-Mesh::Mesh() {
-    vertexBuffer.init(Attributes().addFloat(3).addFloat(2).addFloat(3));
+Mesh::Mesh() : buffer(4) {
+    vertexBuffer.init(
+        VertexBuffer::Attributes().addFloat(3).addFloat(2).addFloat(3));
 }
 
 void Mesh::add(const VertexData& data) {
@@ -14,8 +14,7 @@ void Mesh::clear() {
 }
 
 void Mesh::build() {
-    vertexBuffer.setStaticData(sizeof(VertexData) * buffer.getLength(),
-                               buffer.begin());
+    vertexBuffer.setData(GL::STATIC_DRAW, buffer);
 }
 
 void Mesh::draw() {

+ 3 - 2
rendering/Mesh.h

@@ -1,8 +1,9 @@
 #ifndef MESH_H
 #define MESH_H
 
+#include "data/List.h"
 #include "rendering/VertexBuffer.h"
-#include "utils/List.h"
+#include "utils/TypedBuffer.h"
 
 struct Mesh final {
     struct VertexData final {
@@ -18,7 +19,7 @@ struct Mesh final {
 
 private:
     VertexBuffer vertexBuffer;
-    List<VertexData> buffer;
+    TypedBuffer<VertexData> buffer;
 
 public:
     Mesh();

+ 7 - 1
rendering/Renderer.cpp

@@ -1,12 +1,18 @@
 #include "rendering/Renderer.h"
-#include "wrapper/GL.h"
+#include "rendering/GL.h"
 
 Renderer::Renderer(Shader& shader)
     : shader(shader), texture(true), color(true) {
+}
+
+void Renderer::init() {
     shader.use();
     GL::enableBlending();
     setTextureMode(false);
     setColorMode(false);
+
+    fontRenderer.init();
+    colorRenderer.init();
 }
 
 void Renderer::pop() {

+ 2 - 0
rendering/Renderer.h

@@ -17,6 +17,8 @@ class Renderer final {
 public:
     Renderer(Shader& shader);
 
+    void init();
+
     void pop();
     void push();
 

+ 1 - 1
subprojects/gaming-core

@@ -1 +1 @@
-Subproject commit fa96b9a846064c5f3ea0d47a186cc84782bb4ae3
+Subproject commit 1528c3108da3cfb07654163a3fa740e29beba645