ofxGPUFont/example/src/ofApp.h

126 lines
4.8 KiB
C++

#pragma once
#include "ofMain.h"
#include "ofxGPUFont.h"
class ofApp : public ofBaseApp {
public:
struct Transform {
float fovy = glm::radians(60.0f);
float distance = 0.42f;
glm::mat3 rotation = glm::mat3(1.0f);
glm::vec3 position = glm::vec3(0.0f);
glm::mat4 getProjectionMatrix(float aspect){
return glm::perspective( /* fovy = */ glm::radians(60.0f), aspect, 0.002f, 12.000f);
}
glm::mat4 getViewMatrix(){
auto translation = glm::translate(position);
return glm::lookAt(glm::vec3(0, 0, distance), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0)) * glm::mat4(rotation) * translation;
}
};
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void exit();
unique_ptr <ofxGPUFont::Font> font;
FT_Library library;
// Empty VAO used when the vertex shader has no input and only uses gl_VertexID,
// because OpenGL still requires a non-zero VAO to be bound for the draw call.
GLuint emptyVAO;
std::unique_ptr <ofxGPUFont::ShaderCatalog> shaderCatalog;
//std::shared_ptr <ShaderCatalog::Entry> backgroundShader;
std::shared_ptr <ofxGPUFont::ShaderCatalog::Entry> fontShader;
ofxGPUFont::Font::BoundingBox bb;
Transform transform;
string currentFontPath;
string mainText;
string mainText_full;
string mainText_hitch;
float helpFontBaseSize = 20.0f;
// Size of the window (in pixels) used for 1-dimensional anti-aliasing along each rays.
// 0 - no anti-aliasing
// 1 - normal anti-aliasing
// >=2 - exaggerated effect
int antiAliasingWindowSize = 1;
// Enable a second ray along the y-axis to achieve 2-dimensional anti-aliasing.
bool enableSuperSamplingAntiAliasing = true;
// Draw control points for debugging (green - on curve, magenta - off curve).
bool enableControlPointsVisualization = false;
bool showHelp = true;
ofFloatColor backgroundColor;
GLuint fontShaderProgram;
int fontIndex = -1;
vector <string> fonts = {
"data/fonts/RobotoFlex.ttf",
"data/fonts/Akshar-VariableFont_wght.ttf",
"data/fonts/Batang.ttf",
"data/fonts/CarmenisTrial-Regular.ttf*",
"data/fonts/castaway.ttf",
"data/fonts/cooperBlack.ttf",
"data/fonts/DENMARK.TTF",
"data/fonts/frabk.ttf",
"data/fonts/glyphicons-halflings-regular.ttf",
"data/fonts/icons.ttf*",
"data/fonts/LiberationMono-Regular.ttf*",
"data/fonts/Lilian-Ampersand-beta-0321-Regular.ttf*",
"data/fonts/mono0755.ttf",
"data/fonts/mono.ttf",
"data/fonts/Questrial-Regular.ttf",
"data/fonts/RobotoFlex.ttf",
"data/fonts/Sudbury_Basin_3D.ttf",
"data/fonts/vag.ttf",
"data/fonts/verdana.ttf",
"data/celines-fonts/Alfarn2.otf",
"data/celines-fonts/Lilian-Ampersand-beta-0321-Regular.ttf",
"data/celines-fonts/Tonka-1221-Regular.otf",
"data/celines-fonts/Tonka_Beta_02-RegularExtended.ttf",
"data/celines-fonts/Tonka-metrics-10-Regular.ttf",
"data/celines-fonts/Version-4-var.ttf",
"data/celines-fonts/CarmenisTrial-Regular.ttf",
"data/celines-fonts/Rudi15-1.otf",
"data/celines-fonts/Tonka_Beta_02-DemiExtended.ttf",
"data/celines-fonts/Tonka_Beta_02-SemiExtended.ttf",
"data/celines-fonts/Version-1-var.ttf",
"data/celines-fonts/Cottagecore.ttf",
"data/celines-fonts/testing2VF.ttf",
"data/celines-fonts/Tonka_Beta_02-ExtraExtended.ttf",
"data/celines-fonts/Tonka_Beta_02-UltraExtended.ttf",
"data/celines-fonts/Version-2-var.ttf",
"data/celines-fonts/DarkAcademia-Regular.ttf",
"data/celines-fonts/Tonka-1221GX.ttf",
"data/celines-fonts/Tonka_Beta_02-MediumExtended.ttf",
"data/celines-fonts/tonkaflowers-Regular.otf",
"data/celines-fonts/Version-3-var.ttf"
};
std::vector <ofxGPUFont::Font::FontVariationAxisParameters> fontVariationAxesParameters;
std::vector <ofxGPUFont::Font::FontVariationAxis> fontVariationAxes;
};