From 1fb3c95eb85e955163d7b7ca2d238011b089f5c1 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Sat, 29 Apr 2023 21:32:38 +0200 Subject: [PATCH] proper layerPointer and indefinite amount layers per texture array --- src/gpufont/font.hpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gpufont/font.hpp b/src/gpufont/font.hpp index d4eb652..1f7f310 100644 --- a/src/gpufont/font.hpp +++ b/src/gpufont/font.hpp @@ -538,11 +538,11 @@ class Font { widthCurveTextureLayer = curveBufferSize; glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RG32F, curveBufferSize, 1, neededLayers); }else{ + //cout << ofToString(neededLayers) << "layers needed NEW" << endl; if(neededLayers > 4){ - neededLayers = 4; + //neededLayers = 4; // TODO: implement multiple arrays // LOL - //cout << "more layers than 4 needed" << endl; }else{ } widthCurveTextureLayer = gl_max_texture_size; @@ -569,9 +569,13 @@ class Font { for(int i = 0; i < amountCurveTextureLayers; i++){ int width = widthCurveTextureLayer; int height = 1; - int layerPointer = i == 0 ? 0 : - 5461; - //(i * gl_max_texture_size) - (gl_max_texture_size % bufferCurveSize); + + int third = (int)std::floor(gl_max_texture_size / 3); + int layerPointer = (i * third) - (third % bufferCurveSize) + 1; + //int layerPointer = i == 0 ? 0 : + ////5461; + //(i * gl_max_texture_size / int(3)) - ((gl_max_texture_size / int(3)) % bufferCurveSize) + 1; + //cout << ofToString(i) << " - layer pointer " << ofToString(layerPointer) << endl; glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, @@ -667,10 +671,10 @@ class Font { } int i = 0; - string text = ""; + stringstream text; + for(const auto & glyphIdentity : variationText){ const uint32_t & charcode = glyphIdentity.charcode; - text += charcode; if(charcode == '\0'){ // do we need this? break; } @@ -698,8 +702,7 @@ class Font { continue; } - // LOL - //cout << (char)glyphIdentity.charcode + //text << (char)glyphIdentity.charcode //<< " " << ofToString(glyphIdentity.coords[0]) << " " //<< " (" << ofToString(bufferCurves.size()) << ")" << endl; @@ -710,6 +713,7 @@ class Font { changed = true; i++; } + //cout << text.str() << endl; if(changed){ dirtyBuffers = true;