Skip to content

Commit

Permalink
updated to opengl 4.1 and removed ofxFontStash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
d3cod3 committed Dec 4, 2020
1 parent 2f8a371 commit fcb4144
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 28 deletions.
2 changes: 1 addition & 1 deletion addon_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ meta:
common:
# dependencies with other addons, a list of them separated by spaces
# or use += in several lines
ADDON_DEPENDENCIES = ofxFontStash ofxInfiniteCanvas ofxXmlSettings
ADDON_DEPENDENCIES = ofxInfiniteCanvas ofxXmlSettings

# include search paths, this will be usually parsed from the file system
# but if the addon or addon libraries need special search paths they can be
Expand Down
2 changes: 1 addition & 1 deletion src/ofxMtlMapping2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void ofxMtlMapping2D::init(int width, int height, string mappingXmlFilePath)
_backgroundFbo.allocate(width, height, GL_RGBA, 0);

// ----
ofxMtlMapping2DSettings::infoFont.setup(ofToDataPath("fonts/IBMPlexMono-Medium.ttf"),1.0,2048,true,8,3.0f);
ofxMtlMapping2DSettings::infoFont.load(ofToDataPath("fonts/IBMPlexMono-Medium.ttf"),12);

// ----
_mappingXmlFilePath = mappingXmlFilePath;
Expand Down
2 changes: 1 addition & 1 deletion src/settings/ofxMtlMapping2DSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const bool ofxMtlMapping2DSettings::kIsManuallyCreatingShapeEnabled
const bool ofxMtlMapping2DSettings::kIsManuallyAddingDeletingVertexEnabled = true;

// ---
ofxFontStash ofxMtlMapping2DSettings::infoFont;
ofTrueTypeFont ofxMtlMapping2DSettings::infoFont;

// ---
float ofxMtlMapping2DSettings::gridDefaultNbCols = 2.0f;
Expand Down
4 changes: 1 addition & 3 deletions src/settings/ofxMtlMapping2DSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "ofMain.h"

#include "ofxFontStash.h"

//--------------------------------------------------------------
class ofxMtlMapping2DSettings {
public:
Expand All @@ -13,7 +11,7 @@ class ofxMtlMapping2DSettings {
static const bool kIsManuallyAddingDeletingVertexEnabled;

// ---
static ofxFontStash infoFont;
static ofTrueTypeFont infoFont;

// ---
static float gridDefaultNbCols;
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/ofxMtlMapping2DPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void ofxMtlMapping2DPolygon::drawID()
}


ofxMtlMapping2DSettings::infoFont.draw(ofToString(shapeId),14, _centroid2D.x + xOffset, _centroid2D.y + yOffset);
ofxMtlMapping2DSettings::infoFont.drawString(ofToString(shapeId), _centroid2D.x + xOffset, _centroid2D.y + yOffset);
ofDisableAlphaBlending();
}

Expand Down
34 changes: 18 additions & 16 deletions src/shapes/ofxMtlMapping2DQuad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ void ofxMtlMapping2DQuad::render()
glMultMatrixf(inputPolygon->homoMatrix);
glBegin(GL_POLYGON);

// int i = 0;
// list<ofxMtlMapping2DVertex*>::iterator it;
// for (it=inputPolygon->vertices.begin(); it!=inputPolygon->vertices.end(); it++) {
// ofxMtlMapping2DVertex* vertex = *it;
// glTexCoord2f(vertex->center.x, vertex->center.y);
// glVertex2f(inputPolygon->polyline->getVertices()[i].x - inputPolygon->boundingBox.x, inputPolygon->polyline->getVertices()[i].y - inputPolygon->boundingBox.y);
// i++;
// }

for (int i = 0; i < inputPolygon->polyline->size(); i++) {
glTexCoord2f(inputPolygon->polyline->getVertices()[i].x, inputPolygon->polyline->getVertices()[i].y);
//glVertex2f(inputPolygon->polyline->getVertices()[i].x, inputPolygon->polyline->getVertices()[i].y);
glVertex2f(inputPolygon->polyline->getVertices()[i].x - inputPolygon->boundingBox.x, inputPolygon->polyline->getVertices()[i].y - inputPolygon->boundingBox.y);
if (ofIsGLProgrammableRenderer()) {
quad.clear();
quad.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
for (int i = 0; i < polyline->size(); i++) {
quad.addVertex(glm::vec3(polyline->getVertices()[i].x - boundingBox.x, polyline->getVertices()[i].y - boundingBox.y, 0));
quad.addTexCoord(glm::vec2(inputPolygon->polyline->getVertices()[i].x, inputPolygon->polyline->getVertices()[i].y));
}
ofPushMatrix();
ofTranslate(boundingBox.x,boundingBox.y,0);
quad.draw(OF_MESH_FILL);
ofPopMatrix();
}else{
for (int i = 0; i < inputPolygon->polyline->size(); i++) {
glTexCoord2f(inputPolygon->polyline->getVertices()[i].x, inputPolygon->polyline->getVertices()[i].y);
glVertex2f(polyline->getVertices()[i].x - boundingBox.x, polyline->getVertices()[i].y - boundingBox.y);
}
}



glEnd();
glPopMatrix();
}
Expand Down Expand Up @@ -113,4 +115,4 @@ void ofxMtlMapping2DQuad::calcHomography()
polyline->getVertices()[1].x, polyline->getVertices()[1].y,
polyline->getVertices()[2].x, polyline->getVertices()[2].y,
polyline->getVertices()[3].x, polyline->getVertices()[3].y);
}
}
1 change: 1 addition & 0 deletions src/shapes/ofxMtlMapping2DShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ofxMtlMapping2DShape : public ofxMtlMapping2DPolygon {

std::map<string,string> shapeSettings;
ofxMtlMapping2DInput* inputPolygon;
ofVboMesh quad;

void init(int sId, bool defaultShape = false);

Expand Down
20 changes: 15 additions & 5 deletions src/shapes/ofxMtlMapping2DTriangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ void ofxMtlMapping2DTriangle::render()
{
glPushMatrix();
glBegin(GL_POLYGON);

for (int i = 0; i < inputPolygon->polyline->size(); i++) {
glTexCoord2f(inputPolygon->polyline->getVertices()[i].x, inputPolygon->polyline->getVertices()[i].y);
glVertex2f(polyline->getVertices()[i].x, polyline->getVertices()[i].y);

if (ofIsGLProgrammableRenderer()) {
quad.clear();
quad.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
for (int i = 0; i < polyline->size(); i++) {
quad.addVertex(glm::vec3(polyline->getVertices()[i].x, polyline->getVertices()[i].y, 0));
quad.addTexCoord(glm::vec2(inputPolygon->polyline->getVertices()[i].x, inputPolygon->polyline->getVertices()[i].y));
}
quad.draw(OF_MESH_FILL);
}else{
for (int i = 0; i < inputPolygon->polyline->size(); i++) {
glTexCoord2f(inputPolygon->polyline->getVertices()[i].x, inputPolygon->polyline->getVertices()[i].y);
glVertex2f(polyline->getVertices()[i].x, polyline->getVertices()[i].y);
}
}

glEnd();
Expand Down Expand Up @@ -78,4 +88,4 @@ void ofxMtlMapping2DTriangle::createDefaultShape()
inputPolygon->vertices.push_back(newVertex);

inputPolygon->init(shapeId);
}
}

0 comments on commit fcb4144

Please sign in to comment.