diff --git a/example/src/gpufont/font.hpp b/example/src/gpufont/font.hpp index a7eeaaa..a5ad317 100644 --- a/example/src/gpufont/font.hpp +++ b/example/src/gpufont/font.hpp @@ -735,16 +735,16 @@ class Font { glActiveTexture(GL_TEXTURE0); #else - GLint toast = glGetUniformLocation(program, "glyphs"); - glUniform1i(toast, 2); - curveBuffer = glGetUniformLocation(program, "curves"); - glUniform1i(curveBuffer, 1); + location = glGetUniformLocation(program, "glyphs"); + glUniform1i(location, 2); + location = glGetUniformLocation(program, "curves"); + glUniform1i(location, 1); - //glActiveTexture(GL_TEXTURE0); - //glBindTexture(GL_TEXTURE_2D, glyphBuffer); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, glyphBuffer); - //glActiveTexture(GL_TEXTURE1); - //glBindTexture(GL_TEXTURE_BUFFER, curveBuffer); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_BUFFER, curveBuffer); //glActiveTexture(GL_TEXTURE0); #endif diff --git a/example/src/ofApp.cpp b/example/src/ofApp.cpp index 812f4f9..4185b58 100644 --- a/example/src/ofApp.cpp +++ b/example/src/ofApp.cpp @@ -94,11 +94,6 @@ start. I hope to capture something essential.)DONE"; } currentFontPath = "data/celines-fonts/Version-1-var.ttf"; - tryUpdateMainFont(library, - currentFontPath, - mainText, - font, - bb); transform = Transform(); @@ -123,6 +118,7 @@ start. I hope to capture something essential.)DONE"; cout << "Render type " << r->getType() << endl; backgroundColor = ofFloatColor::red; + r->setBackgroundAuto(false); } //-------------------------------------------------------------- @@ -158,6 +154,13 @@ void ofApp::draw(){ int currentProgram; glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + if(!font){ + tryUpdateMainFont(library, + currentFontPath, + mainText, + font, + bb); + } if(font){ GLuint program = fontShader->program; @@ -187,10 +190,10 @@ void ofApp::draw(){ location = glGetUniformLocation(program, "enableControlPointsVisualization"); glUniform1i(location, enableControlPointsVisualization); - debug_font_location = glGetUniformLocation(program, "iChannel0"); - glUniform1i(debug_font_location, 3); + //debug_font_location = glGetUniformLocation(program, "iChannel0"); + //glUniform1i(debug_font_location, 3); - if(!debug_font.isAllocated()){ + if(!debug_font.isAllocated() && false){ debug_font.setUseTexture(false); debug_font.load("sdfatlas.png"); //debug_font.getTexture().getTextureData().textureID = debug_font_location; @@ -213,23 +216,18 @@ void ofApp::draw(){ GL_UNSIGNED_BYTE, pixels.getData()); glGenerateMipmap(GL_TEXTURE_2D); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } //debug_font.bind(debug_font_location); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, 0); - float cx = 0.5f * (bb.minX + bb.maxX); float cy = 0.5f * (bb.minY + bb.maxY); font->draw(-cx, -cy, 0, mainText); glUseProgram(currentProgram); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, 0); } glDisable(GL_BLEND);