introduce buffer target type

This commit is contained in:
jrkb 2023-05-29 09:50:52 +02:00
parent 45240df10c
commit 0b41ae9f97

View file

@ -429,9 +429,10 @@ class Font {
// If hinting is enabled, worldSize must be an integer and defines the font size in pixels used for hinting. // If hinting is enabled, worldSize must be an integer and defines the font size in pixels used for hinting.
// Otherwise, worldSize can be an arbitrary floating-point value. // Otherwise, worldSize can be an arbitrary floating-point value.
Font(FT_Face face, float worldSize = 1.0f, bool hinting = false) : Font(FT_Face face, float worldSize = 1.0f, bool hinting = false, GLint bufferTargetType = GL_TEXTURE_2D_ARRAY) :
face(face), face(face),
hinting(hinting), hinting(hinting),
BUFFER_TARGET_TYPE(bufferTargetType),
worldSize(worldSize){ worldSize(worldSize){
// TODO: modularize init, so we can initialize with settings and text // TODO: modularize init, so we can initialize with settings and text
@ -1400,6 +1401,7 @@ class Font {
// If hinting is enabled, we must let FreeType scale the outlines for the hinting to work properly. // If hinting is enabled, we must let FreeType scale the outlines for the hinting to work properly.
// The variables loadFlags and kerningMode are set in the constructor and control this scaling behavior. // The variables loadFlags and kerningMode are set in the constructor and control this scaling behavior.
bool hinting; bool hinting;
GLint BUFFER_TARGET_TYPE;
FT_Int32 loadFlags; FT_Int32 loadFlags;
FT_Kerning_Mode kerningMode; FT_Kerning_Mode kerningMode;
@ -1443,6 +1445,7 @@ class Font {
static std::shared_ptr <Font> loadFont(FT_Library & library, static std::shared_ptr <Font> loadFont(FT_Library & library,
const std::string & filename, const std::string & filename,
GLint bufferTargetType,
float worldSize = 1.0f, float worldSize = 1.0f,
bool hinting = false){ bool hinting = false){
std::string error; std::string error;
@ -1454,15 +1457,16 @@ static std::shared_ptr <Font> loadFont(FT_Library & library,
std::cout << "ofxGPUFont::font.hpp[" << __LINE__ << "] FT loaded " << filename << ": " << error << std::endl; std::cout << "ofxGPUFont::font.hpp[" << __LINE__ << "] FT loaded " << filename << ": " << error << std::endl;
} }
return std::make_shared <Font>(face, worldSize, hinting); return std::make_shared <Font>(face, worldSize, hinting, bufferTargetType);
} }
static void initializeFont(FT_Library & library, static void initializeFont(FT_Library & library,
const std::string & filename, const std::string & filename,
shared_ptr <Font> & mainFont){ shared_ptr <Font> & mainFont,
GLint bufferTargetType = GL_TEXTURE_2D_ARRAY){
cout << "initializeFont" << endl; cout << "initializeFont" << endl;
auto font = loadFont(library, filename); auto font = loadFont(library, filename, bufferTargetType);
if(!font){ if(!font){
return; return;
} }