Browse Source

update to new buffer

Kajetan Johannes Hammerle 3 years ago
parent
commit
0d6110e4ec
4 changed files with 9 additions and 7 deletions
  1. 1 1
      gaming-core
  2. 2 0
      meson.build
  3. 2 2
      rendering/ColorRenderer.cpp
  4. 4 4
      rendering/FontRenderer.cpp

+ 1 - 1
gaming-core

@@ -1 +1 @@
-Subproject commit 33d0fc4551fd47d5d1b607df6f2a807b6107c7a1
+Subproject commit c6dd6c59b7c6f5b5da78c05b8e7f58c0c256db40

+ 2 - 0
meson.build

@@ -13,6 +13,8 @@ sources = [
     'gaming-core/math/Vector.cpp',
     '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/wrapper/VertexBuffer.cpp',
     'gaming-core/wrapper/Attributes.cpp',

+ 2 - 2
rendering/ColorRenderer.cpp

@@ -4,11 +4,11 @@
 
 ColorRenderer::ColorRenderer() {
     vertexBuffer.setAttributes(Attributes().addFloat(2).addSpacer().addColor4());
-    vertexBuffer.setStreamData(3 * sizeof (float) * 6);
+    vertexBuffer.setStreamData(sizeof (Vertex) * 3);
 }
 
 void ColorRenderer::draw(const Vertex& v1, const Vertex& v2, const Vertex& v3) {
-    Buffer <sizeof (Vertex) * 3 > buffer;
+    Buffer buffer(sizeof (Vertex) * 3);
     buffer.add(v1).add(v2).add(v3);
     vertexBuffer.updateData(0, buffer.getLength(), buffer);
     vertexBuffer.draw(3);

+ 4 - 4
rendering/FontRenderer.cpp

@@ -14,8 +14,8 @@ FontRenderer::FontRenderer() : activeTex(0), scale(1) {
 float FontRenderer::drawString(float x, float y, const char* text) {
     const int maxIndex = 256;
 
-    Buffer<sizeof (float) * maxIndex * 4 * 8 > buffer;
-    
+    Buffer buffer(sizeof (float) * maxIndex * 4 * 8);
+
     int index = 0;
     Color4 color(0xFF, 0xFF, 0xFF, 0xFF);
 
@@ -43,7 +43,7 @@ float FontRenderer::drawString(float x, float y, const char* text) {
         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 + addY).add(minX).add(maxY).add(color);
         buffer.add(x + addX).add(y).add(maxX).add(minY).add(color);
@@ -55,7 +55,7 @@ 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;
 }