verifying glyphs
glyph.start & glyph.count look good, curves look good, incremental debugging :-)
This commit is contained in:
parent
d8a7bc7a98
commit
412c64298d
3 changed files with 99 additions and 64 deletions
|
@ -123,10 +123,10 @@ void main() {
|
||||||
alpha += computeCoverage(inverseDiameter.y, rotate(p0), rotate(p1), rotate(p2));
|
alpha += computeCoverage(inverseDiameter.y, rotate(p0), rotate(p1), rotate(p2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vec4 debug = texelFetch(curves, int(uv.x * textureSize(curves)));
|
//vec4 debug = texelFetch(glyphs, int(uv.x * textureSize(glyphs)));
|
||||||
result = vec4(debug.rgb, 1.0);
|
//result = vec4(debug.rgb, 1.0);
|
||||||
|
|
||||||
return;
|
//return;
|
||||||
|
|
||||||
if (enableSuperSamplingAntiAliasing) {
|
if (enableSuperSamplingAntiAliasing) {
|
||||||
alpha *= 0.5;
|
alpha *= 0.5;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
// because both files have mostly the same dependencies (OpenGL, GLM, FreeType).
|
// because both files have mostly the same dependencies (OpenGL, GLM, FreeType).
|
||||||
#include "ofMain.h"
|
#include "ofMain.h"
|
||||||
|
|
||||||
|
#include <GL/glext.h>
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#ifdef TARGET_OPENGLES
|
#ifdef TARGET_OPENGLES
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
@ -336,6 +337,7 @@ class Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool done = false;
|
||||||
void uploadBuffers(){
|
void uploadBuffers(){
|
||||||
cout << "bufferGlyphs.size(): " << bufferGlyphs.size() << endl;
|
cout << "bufferGlyphs.size(): " << bufferGlyphs.size() << endl;
|
||||||
cout << "bufferCurves.size(): " << bufferCurves.size() << endl;
|
cout << "bufferCurves.size(): " << bufferCurves.size() << endl;
|
||||||
|
@ -355,7 +357,7 @@ class Font {
|
||||||
//glBindBuffer(GL_TEXTURE_2D, curveBuffer);
|
//glBindBuffer(GL_TEXTURE_2D, curveBuffer);
|
||||||
//glBufferData(GL_TEXTURE_2D, sizeof(BufferCurve) * bufferCurves.size(), bufferCurves.data(), GL_STATIC_DRAW);
|
//glBufferData(GL_TEXTURE_2D, sizeof(BufferCurve) * bufferCurves.size(), bufferCurves.data(), GL_STATIC_DRAW);
|
||||||
//glBindBuffer(GL_TEXTURE_2D, 0);
|
//glBindBuffer(GL_TEXTURE_2D, 0);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glBindTexture(GL_TEXTURE_2D, glyphBuffer);
|
glBindTexture(GL_TEXTURE_2D, glyphBuffer);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
@ -364,7 +366,6 @@ class Font {
|
||||||
GL_NEAREST);
|
GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
GL_NEAREST);
|
GL_NEAREST);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
GL_RG32I,
|
GL_RG32I,
|
||||||
|
@ -374,7 +375,39 @@ class Font {
|
||||||
GL_RG_INTEGER,
|
GL_RG_INTEGER,
|
||||||
GL_INT,
|
GL_INT,
|
||||||
bufferGlyphs.data());
|
bufferGlyphs.data());
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
|
//int size = 2048;
|
||||||
|
//float * data = new float[3 * size * sizeof(float)];
|
||||||
|
//for(unsigned int i = 0; i < size; i++){
|
||||||
|
//data[i * 3] = (float)(0.1f);
|
||||||
|
//data[i * 3 + 1] = (float)(0.5f);
|
||||||
|
//data[i * 3 + 2] = (float)(1.0f);
|
||||||
|
//}
|
||||||
|
//glTexImage2D(GL_TEXTURE_2D,
|
||||||
|
//0,
|
||||||
|
//GL_RGB32F,
|
||||||
|
//size,
|
||||||
|
//1,
|
||||||
|
//0,
|
||||||
|
//GL_RGB,
|
||||||
|
//GL_FLOAT,
|
||||||
|
//data);
|
||||||
|
/////////////////////////////////////////
|
||||||
|
//int size = 2048;
|
||||||
|
//uint32_t * data = new uint32_t[2 * size * sizeof(uint32_t)];
|
||||||
|
//for(unsigned int i = 0; i < size; i++){
|
||||||
|
//data[i * 2] = (uint32_t)(0.1f);
|
||||||
|
//data[i * 2 + 1] = (uint32_t)(255.0f);
|
||||||
|
//}
|
||||||
|
//glTexImage2D(GL_TEXTURE_2D,
|
||||||
|
//0,
|
||||||
|
//GL_RG32I,
|
||||||
|
//size,
|
||||||
|
//1,
|
||||||
|
//0,
|
||||||
|
//GL_RG_INTEGER,
|
||||||
|
//GL_INT,
|
||||||
|
//data);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, curveBuffer);
|
glBindTexture(GL_TEXTURE_2D, curveBuffer);
|
||||||
|
@ -703,17 +736,17 @@ class Font {
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
#else
|
#else
|
||||||
glyphBuffer = glGetUniformLocation(program, "glyphs");
|
glyphBuffer = glGetUniformLocation(program, "glyphs");
|
||||||
glUniform1i(glyphBuffer, 0);
|
glUniform1i(glyphBuffer, 2);
|
||||||
curveBuffer = glGetUniformLocation(program, "curves");
|
curveBuffer = glGetUniformLocation(program, "curves");
|
||||||
glUniform1i(curveBuffer, 1);
|
glUniform1i(curveBuffer, 1);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
//glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_BUFFER, glyphBuffer);
|
//glBindTexture(GL_TEXTURE_2D, glyphBuffer);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
//glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_BUFFER, curveBuffer);
|
//glBindTexture(GL_TEXTURE_BUFFER, curveBuffer);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
//glActiveTexture(GL_TEXTURE0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,74 +124,76 @@ start. I hope to capture something essential.)DONE";
|
||||||
void ofApp::update(){
|
void ofApp::update(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
bool hasDrawnOnce = false;
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
void ofApp::draw(){
|
void ofApp::draw(){
|
||||||
GLuint location;
|
if(!hasDrawnOnce){
|
||||||
|
GLuint location;
|
||||||
|
|
||||||
int width = ofGetWidth();
|
int width = ofGetWidth();
|
||||||
int height = ofGetHeight();
|
int height = ofGetHeight();
|
||||||
|
|
||||||
glm::mat4 projection = transform.getProjectionMatrix((float)width / height);
|
glm::mat4 projection = transform.getProjectionMatrix((float)width / height);
|
||||||
glm::mat4 view = transform.getViewMatrix();
|
glm::mat4 view = transform.getViewMatrix();
|
||||||
glm::mat4 model = glm::mat4(1.0f);
|
glm::mat4 model = glm::mat4(1.0f);
|
||||||
|
|
||||||
//{ // Draw background.
|
//{ // Draw background.
|
||||||
//GLuint program = backgroundShader->program;
|
//GLuint program = backgroundShader->program;
|
||||||
//glUseProgram(program);
|
//glUseProgram(program);
|
||||||
//glBindVertexArray(emptyVAO);
|
//glBindVertexArray(emptyVAO);
|
||||||
//glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
//glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
//glBindVertexArray(0);
|
//glBindVertexArray(0);
|
||||||
//glUseProgram(0);
|
//glUseProgram(0);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
ofBackground(ofColor::pink);
|
ofBackground(ofColor::pink);
|
||||||
|
|
||||||
// Uses premultiplied-alpha.
|
// Uses premultiplied-alpha.
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
int currentProgram;
|
int currentProgram;
|
||||||
glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram);
|
glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram);
|
||||||
|
|
||||||
if(font){
|
if(font){
|
||||||
GLuint program = fontShader->program;
|
GLuint program = fontShader->program;
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
font->program = program;
|
font->program = program;
|
||||||
font->drawSetup();
|
font->drawSetup();
|
||||||
|
|
||||||
location = glGetUniformLocation(program, "projection");
|
location = glGetUniformLocation(program, "projection");
|
||||||
glUniformMatrix4fv(location, 1, false, glm::value_ptr(projection));
|
glUniformMatrix4fv(location, 1, false, glm::value_ptr(projection));
|
||||||
|
|
||||||
location = glGetUniformLocation(program, "view");
|
location = glGetUniformLocation(program, "view");
|
||||||
glUniformMatrix4fv(location, 1, false, glm::value_ptr(view));
|
glUniformMatrix4fv(location, 1, false, glm::value_ptr(view));
|
||||||
location = glGetUniformLocation(program, "model");
|
location = glGetUniformLocation(program, "model");
|
||||||
glUniformMatrix4fv(location, 1, false, glm::value_ptr(model));
|
glUniformMatrix4fv(location, 1, false, glm::value_ptr(model));
|
||||||
float z = 0;
|
float z = 0;
|
||||||
location = glGetUniformLocation(program, "z");
|
location = glGetUniformLocation(program, "z");
|
||||||
glUniform1f(location, z);
|
glUniform1f(location, z);
|
||||||
|
|
||||||
location = glGetUniformLocation(program, "color");
|
location = glGetUniformLocation(program, "color");
|
||||||
glUniform4f(location, 1.0f, 0.0f, 1.0f, 1.0f);
|
glUniform4f(location, 1.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
location = glGetUniformLocation(program, "antiAliasingWindowSize");
|
location = glGetUniformLocation(program, "antiAliasingWindowSize");
|
||||||
glUniform1f(location, (float)antiAliasingWindowSize);
|
glUniform1f(location, (float)antiAliasingWindowSize);
|
||||||
location = glGetUniformLocation(program, "enableSuperSamplingAntiAliasing");
|
location = glGetUniformLocation(program, "enableSuperSamplingAntiAliasing");
|
||||||
glUniform1i(location, enableSuperSamplingAntiAliasing);
|
glUniform1i(location, enableSuperSamplingAntiAliasing);
|
||||||
location = glGetUniformLocation(program, "enableControlPointsVisualization");
|
location = glGetUniformLocation(program, "enableControlPointsVisualization");
|
||||||
glUniform1i(location, enableControlPointsVisualization);
|
glUniform1i(location, enableControlPointsVisualization);
|
||||||
|
|
||||||
float cx = 0.5f * (bb.minX + bb.maxX);
|
float cx = 0.5f * (bb.minX + bb.maxX);
|
||||||
float cy = 0.5f * (bb.minY + bb.maxY);
|
float cy = 0.5f * (bb.minY + bb.maxY);
|
||||||
font->draw(-cx, -cy, 0, mainText);
|
font->draw(-cx, -cy, 0, mainText);
|
||||||
glUseProgram(currentProgram);
|
glUseProgram(currentProgram);
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
ofDrawBitmapStringHighlight("fps: " + ofToString(ofGetFrameRate()), 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
|
|
||||||
ofDrawBitmapStringHighlight("fps: " + ofToString(ofGetFrameRate()), 20, 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue