fun with ofxGPUfont
(single draw call for multiple texts)
This commit is contained in:
parent
7016b0629f
commit
dce5e7c57a
1 changed files with 39 additions and 10 deletions
|
@ -56,7 +56,7 @@ void GPUFontAtlasLayerCombo::update(){
|
|||
//shaderCatalog->update();
|
||||
//}
|
||||
//#endif
|
||||
float animationSpeed = ofMap(sin(ofGetElapsedTimef() * 0.01), -1, 1, 0.1, 2);
|
||||
float animationSpeed = 1.0;
|
||||
float threshold = 1.0;
|
||||
for(int i = 0; i < fontVariationAxes.size(); i++){
|
||||
ofxGPUFont::Font::FontVariationAxis & axis = fontVariationAxes[i];
|
||||
|
@ -144,7 +144,7 @@ void GPUFontAtlasLayerCombo::draw(){
|
|||
glUniform1f(location, z);
|
||||
|
||||
location = glGetUniformLocation(fontShaderProgram, "color");
|
||||
glUniform4f(location, 1.0f, 0.0f, 0.0f, 0.5f);
|
||||
glUniform4f(location, 1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
location = glGetUniformLocation(fontShaderProgram, "antiAliasingWindowSize");
|
||||
glUniform1f(location, (float)antiAliasingWindowSize);
|
||||
|
@ -156,18 +156,47 @@ void GPUFontAtlasLayerCombo::draw(){
|
|||
|
||||
//mouse.x = 0;
|
||||
//mouse.y = 0;
|
||||
float mx = ofMap(mouse.x, 0, width, -0.5 * width_unit, 0.5 * width_unit);
|
||||
float my = ofMap(mouse.y, 0, height, -0.5 * height_unit, 0.5 * height_unit);
|
||||
std::vector <ofxGPUFont::Font::BufferVertex> vertices;
|
||||
std::vector <int32_t> indices;
|
||||
string text = "whatever";
|
||||
int n_texts = 240;
|
||||
vertices.resize(text.length() * n_texts * 4);
|
||||
indices.resize(text.length() * n_texts * 6);
|
||||
cx = 0.5f * (bb.minX + bb.maxX);
|
||||
cy = 0.5f * (bb.minY + bb.maxY);
|
||||
|
||||
for(int i = 0; i < n_texts - 1; i++){
|
||||
float pipi = ((PI * 2 * i) / (n_texts - 1));
|
||||
float shift = (400 * cos(ofGetElapsedTimef() * 0.125 + pipi));
|
||||
float shift_x = (600 * sin(ofGetElapsedTimef() * 0.125 + pipi));
|
||||
float shift_o = (100 * sin(ofGetElapsedTimef() * 0.4 + pipi));
|
||||
font->collectVerticesAndIndices(
|
||||
glm::vec3(mouse.x + shift_x,
|
||||
mouse.y + shift + shift_o,
|
||||
0),
|
||||
text,
|
||||
vertices,
|
||||
indices,
|
||||
true,
|
||||
int(ofMap(sin(ofGetElapsedTimef() + pipi), -1, 1, 42, 96)));
|
||||
}
|
||||
font->collectVerticesAndIndices(
|
||||
glm::vec3(mouse.x,
|
||||
mouse.y,
|
||||
0),
|
||||
text,
|
||||
vertices,
|
||||
indices,
|
||||
true,
|
||||
ofMap(sin(ofGetElapsedTimef() * 0.25f), -1.0f, 1.0f, 42.0f, 96.0f));
|
||||
font->draw(vertices, indices);
|
||||
//ofRectangle rectangle(0, 0, width, height);
|
||||
//ofDrawRectangle(rectangle);
|
||||
font->draw(mouse.x, mouse.y - (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "what", vFlip == V_FLIP_ON, 128.0f);
|
||||
location = glGetUniformLocation(fontShaderProgram, "color");
|
||||
glUniform4f(location, 0.0f, 1.0f, 0.0f, 0.5f);
|
||||
font->draw(mouse.x, mouse.y, 0, "ever", vFlip == V_FLIP_ON, 64.0f);
|
||||
glUniform4f(location, 0.0f, 0.0f, 1.0f, 0.5f);
|
||||
font->draw(mouse.x, mouse.y + (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "verraw", vFlip == V_FLIP_ON, 256.0f);
|
||||
//font->draw(mouse.x, mouse.y - (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "what", vFlip == V_FLIP_ON, 42.0f);
|
||||
//location = glGetUniformLocation(fontShaderProgram, "color");
|
||||
//glUniform4f(location, 0.0f, 1.0f, 0.0f, 0.5f);
|
||||
//font->draw(mouse.x, mouse.y, 0, "ever", vFlip == V_FLIP_ON, 420.0f);
|
||||
|
||||
glUseProgram(currentProgram);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue