Browse Source

core update

Kajetan Johannes Hammerle 3 years ago
parent
commit
b884c1a814

+ 5 - 5
Main.cpp

@@ -3,13 +3,13 @@
 #include <getopt.h>
 
 #include "Game.h"
+#include "gaming-core/rendering/Shader.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"
-#include "gaming-core/wrapper/Shader.h"
-#include "gaming-core/wrapper/Window.h"
-#include "gaming-core/wrapper/WindowOptions.h"
 #include "rendering/Renderer.h"
 
 bool parseArgs(int argAmount, char* const* args, WindowOptions& options) {
@@ -53,7 +53,7 @@ int main(int argAmount, char* const* args) {
     const Clock::Nanos nanosPerTick = 10'000'000;
     Clock::Nanos lag = 0;
     while(!window.shouldClose() && game.isRunning()) {
-        GL::checkAndPrintError("GL-Error");
+        GL::printError("GL-Error");
 
         lag += fps.update();
         while(lag >= nanosPerTick) {
@@ -73,7 +73,7 @@ int main(int argAmount, char* const* args) {
 
         game.render(static_cast<float>(lag) / nanosPerTick, renderer);
         window.swapBuffers();
-        GL::clearFramebuffer();
+        GL::clear();
 
         glfwPollEvents();
     }

+ 1 - 1
gaming-core

@@ -1 +1 @@
-Subproject commit 1afdb909090ce8398de997bde094f1fcda3a2e4b
+Subproject commit 3f19a9343926b7ee3dc8c8fca6c503062adc6a0b

+ 7 - 8
meson.build

@@ -5,13 +5,13 @@ sources = [
     'gaming-core/wrapper/GLFW.cpp', 
     'gaming-core/wrapper/GL.cpp', 
     'gaming-core/wrapper/GLEW.cpp', 
-    'gaming-core/wrapper/Shader.cpp', 
-    'gaming-core/wrapper/Texture.cpp',
-    'gaming-core/wrapper/TextureFormat.cpp',
-    'gaming-core/wrapper/VertexBuffer.cpp',
-    'gaming-core/wrapper/Attributes.cpp',
-    'gaming-core/wrapper/Window.cpp', 
-    'gaming-core/wrapper/WindowOptions.cpp',
+    'gaming-core/rendering/Shader.cpp', 
+    'gaming-core/rendering/Texture.cpp',
+    'gaming-core/rendering/TextureFormat.cpp',
+    'gaming-core/rendering/VertexBuffer.cpp',
+    'gaming-core/rendering/Attributes.cpp',
+    'gaming-core/rendering/Window.cpp', 
+    'gaming-core/rendering/WindowOptions.cpp',
     'gaming-core/rendering/FileTexture.cpp',
     'gaming-core/math/Matrix.cpp',
     'gaming-core/math/Quaternion.cpp',
@@ -19,7 +19,6 @@ sources = [
     'gaming-core/utils/Size.cpp', 
     'gaming-core/utils/Clock.cpp', 
     'gaming-core/utils/Buffer.cpp', 
-    'gaming-core/memory/StackAllocator.cpp', 
     'gaming-core/images/PNGReader.cpp',
     'gaming-core/input/Buttons.cpp',
     'gaming-core/input/Button.cpp',

+ 3 - 2
rendering/ColorRenderer.cpp

@@ -1,9 +1,10 @@
 #include "rendering/ColorRenderer.h"
+#include "gaming-core/rendering/Attributes.h"
 #include "gaming-core/utils/Buffer.h"
-#include "gaming-core/wrapper/Attributes.h"
 
 ColorRenderer::ColorRenderer() {
-    vertexBuffer.setAttributes(Attributes().addFloat(2).addSpacer().addColor4());
+    vertexBuffer.setAttributes(
+        Attributes().addFloat(2).addSpacer().addColor4());
     vertexBuffer.setStreamData(sizeof(Vertex) * 3);
 }
 

+ 1 - 1
rendering/ColorRenderer.h

@@ -1,8 +1,8 @@
 #ifndef COLORRENDERER_H
 #define COLORRENDERER_H
 
+#include "gaming-core/rendering/VertexBuffer.h"
 #include "gaming-core/utils/Color.h"
-#include "gaming-core/wrapper/VertexBuffer.h"
 
 struct ColorRenderer final {
     struct Vertex {

+ 7 - 4
rendering/FontRenderer.cpp

@@ -1,13 +1,14 @@
 #include "rendering/FontRenderer.h"
+#include "gaming-core/rendering/Attributes.h"
 #include "gaming-core/utils/Buffer.h"
 #include "gaming-core/utils/Color.h"
-#include "gaming-core/wrapper/Attributes.h"
 
 FontRenderer::FontRenderer() : activeTex(0), scale(1) {
     tex.add("resources/font8x8.png");
     tex.add("resources/font16x16.png");
     tex.add("resources/font24x24.png");
-    vertexBuffer.setAttributes(Attributes().addFloat(2).addFloat(2).addColor4());
+    vertexBuffer.setAttributes(
+        Attributes().addFloat(2).addFloat(2).addColor4());
     vertexBuffer.setStreamData(256 * 4 * sizeof(float) * 8);
 }
 
@@ -29,7 +30,8 @@ float FontRenderer::drawString(float x, float y, const char* text) {
             c = (text[index] & 0x3F) | ((c & 0x1F) << 6);
         }
         if(c == '&') {
-            if(text[index + 1] == '\0' || text[index + 2] == '\0' || text[index + 3] == '\0') {
+            if(text[index + 1] == '\0' || text[index + 2] == '\0' ||
+               text[index + 3] == '\0') {
                 break;
             }
             color[0] = ((text[index + 1] - '0') * 255) / 9;
@@ -55,7 +57,8 @@ float FontRenderer::drawString(float x, float y, const char* text) {
 
     tex[activeTex].bindTo(0);
     vertexBuffer.updateData(0, buffer.getLength(), buffer);
-    vertexBuffer.drawStrip(buffer.getLength() / (4 * sizeof(float) + sizeof(Color4)));
+    vertexBuffer.drawStrip(buffer.getLength() /
+                           (4 * sizeof(float) + sizeof(Color4)));
     return y + addY;
 }
 

+ 3 - 3
rendering/FontRenderer.h

@@ -2,13 +2,13 @@
 #define FONTRENDERER_H
 
 #include "gaming-core/rendering/FileTexture.h"
-#include "gaming-core/utils/List.h"
-#include "gaming-core/wrapper/VertexBuffer.h"
+#include "gaming-core/rendering/VertexBuffer.h"
+#include "gaming-core/utils/ArrayList.h"
 #include "utils/Array.h"
 
 class FontRenderer final {
     VertexBuffer vertexBuffer;
-    List<FileTexture, 3> tex;
+    ArrayList<FileTexture, 3> tex;
     int activeTex;
     int scale;
 

+ 5 - 3
rendering/Mesh.cpp

@@ -1,8 +1,9 @@
 #include "rendering/Mesh.h"
-#include "gaming-core/wrapper/Attributes.h"
+#include "gaming-core/rendering/Attributes.h"
 
 Mesh::Mesh() {
-    vertexBuffer.setAttributes(Attributes().addFloat(3).addFloat(2).addFloat(3));
+    vertexBuffer.setAttributes(
+        Attributes().addFloat(3).addFloat(2).addFloat(3));
 }
 
 void Mesh::add(const VertexData& data) {
@@ -14,7 +15,8 @@ void Mesh::clear() {
 }
 
 void Mesh::build() {
-    vertexBuffer.setStaticData(sizeof(VertexData) * buffer.getLength(), buffer.begin());
+    vertexBuffer.setStaticData(sizeof(VertexData) * buffer.getLength(),
+                               buffer.begin());
 }
 
 void Mesh::draw() {

+ 2 - 2
rendering/Mesh.h

@@ -1,7 +1,7 @@
 #ifndef MESH_H
 #define MESH_H
 
-#include "gaming-core/wrapper/VertexBuffer.h"
+#include "gaming-core/rendering/VertexBuffer.h"
 #include "utils/List.h"
 
 struct Mesh final {
@@ -18,7 +18,7 @@ struct Mesh final {
 
 private:
     VertexBuffer vertexBuffer;
-    List<VertexData, 65536 * 2> buffer;
+    List<VertexData> buffer;
 
 public:
     Mesh();

+ 7 - 4
rendering/Renderer.h

@@ -1,7 +1,7 @@
 #ifndef RENDERER_H
 #define RENDERER_H
 
-#include "gaming-core/wrapper/Shader.h"
+#include "gaming-core/rendering/Shader.h"
 #include "math/MatrixStack.h"
 #include "rendering/ColorRenderer.h"
 #include "rendering/FontRenderer.h"
@@ -34,10 +34,13 @@ public:
 
     void setStringSize(int size);
     float drawString(float x, float y, const char* text);
-    void drawTriangle(const ColorRenderer::Vertex& v1, const ColorRenderer::Vertex& v2,
+    void drawTriangle(const ColorRenderer::Vertex& v1,
+                      const ColorRenderer::Vertex& v2,
                       const ColorRenderer::Vertex& v3);
-    void drawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, Color4 color);
-    void drawRectangle(float x, float y, float width, float height, Color4 color);
+    void drawTriangle(float x1, float y1, float x2, float y2, float x3,
+                      float y3, Color4 color);
+    void drawRectangle(float x, float y, float width, float height,
+                       Color4 color);
 
 private:
     void setTextureMode(bool b);