Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/3d/quaternionArcballExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void ofApp::draw(){
float redValueFromXspeed = ofMap( fabs(xspeed), 1, 15, 100, 255, true );
float greenValueFromYspeed = ofMap( fabs(yspeed), 1, 15, 100, 255, true );

ofSetColor( redValueFromXspeed, greenValueFromYspeed, MIN(redValueFromXspeed, greenValueFromYspeed) );
ofSetColor( redValueFromXspeed, greenValueFromYspeed, std::min(redValueFromXspeed, greenValueFromYspeed) );
ofDrawSphere(0, -newSize, 0, 10.0 );
ofDrawSphere(0, newSize, 0, 10.0 );
ofDrawSphere(newSize, 0, 0, 10.0 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void ofApp::update(){
// store as floats
flowMat = cv::Mat(scaledHeight, scaledWidth, CV_32FC2);

ofSetWindowShape(MIN(sourceWidth, 1920), MIN(sourceHeight, 1200));
ofSetWindowShape(std::min(sourceWidth, 1920), std::min(sourceHeight, 1200));

// clear the previous vectors
spinCubes.clear();
Expand Down
4 changes: 2 additions & 2 deletions examples/gl/fboHighResOutputExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ void ofApp::setup(){
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);

// take the smaller size
int fboWidth = MIN(8192,maxSize);
int fboHeight = MIN(8192,maxSize);
int fboWidth = std::min(8192,maxSize);
int fboHeight = std::min(8192,maxSize);
//allocate our fbo with 3 color channels and 4x multisample
#ifdef TARGET_EMSCRIPTEN
fboOutput.allocate(fboWidth, fboHeight, GL_RGB);
Expand Down
2 changes: 1 addition & 1 deletion examples/input_output/xmlSettingsExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void ofApp::setup(){

//we have only allocated a certan amount of space for our array
//so we don't want to read more than that amount of points
int totalToRead = MIN(numPtTags, NUM_PTS);
int totalToRead = std::min(numPtTags, NUM_PTS);

for(int i = 0; i < totalToRead; i++){
//the last argument of getValue can be used to specify
Expand Down
25 changes: 12 additions & 13 deletions examples/ios/xmlSettingsExample/src/ofApp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
//we load our settings file
//initially we do this from the data/ folder
//but when we save we are saving to the documents folder which is the only place we have write access to
//thats why we check if the file exists in the documents folder.
//thats why we check if the file exists in the documents folder.

if( XML.loadFile(ofxiOSGetDocumentsDirectory() + "mySettings.xml") ){
message = "mySettings.xml loaded from documents folder!";
}else if( XML.loadFile("mySettings.xml") ){
message = "mySettings.xml loaded from data folder!";
}else{
message = "unable to load mySettings.xml check data/ folder";
}

//read the colors from XML
//if the settings file doesn't exist we assigns default values (170, 190, 240)
red = XML.getValue("BACKGROUND:COLOR:RED", 170);
Expand Down Expand Up @@ -74,7 +74,7 @@

//we have only allocated a certan amount of space for our array
//so we don't want to read more than that amount of points
int totalToRead = MIN(numPtTags, NUM_PTS);
int totalToRead = std::min(numPtTags, NUM_PTS);

for(int i = 0; i < totalToRead; i++){
//the last argument of getValue can be used to specify
Expand Down Expand Up @@ -110,11 +110,11 @@
string drawString = "How the data is stored:\n\n";
if(xmlStructure.size() > 0){
ofEnableAlphaBlending();
ofSetColor(255-red, 255-green, 255-blue, 180);
ofSetColor(255-red, 255-green, 255-blue, 180);
drawString += xmlStructure+"</STROKE>";
TTF.drawString(drawString, 5, 60);
}

//---------
//Lets draw the stroke as a continous line
ofSetHexColor(0x222222);
Expand Down Expand Up @@ -146,7 +146,7 @@

//--------------------------------------------------------------
void ofApp::exit(){

}

//--------------------------------------------------------------
Expand Down Expand Up @@ -226,7 +226,7 @@
dragPts[pointCount].set(touch.x, touch.y);
pointCount++;
}

}

}
Expand Down Expand Up @@ -254,21 +254,20 @@

//--------------------------------------------------------------
void ofApp::lostFocus(){

}

//--------------------------------------------------------------
void ofApp::gotFocus(){

}

//--------------------------------------------------------------
void ofApp::gotMemoryWarning(){

}

//--------------------------------------------------------------
void ofApp::deviceOrientationChanged(int newOrientation){

}

}
50 changes: 25 additions & 25 deletions examples/shader/07_fboAlphaMaskExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ void ofApp::setup(){
}else{
shader.load("shadersGL2/shader");
}

brushImage.load("brush.png");
// change the image to draw from the center
// the default is from top left
brushImage.setAnchorPercent(0.5f, 0.5f);

textures.resize(5);
for( int i = 0; i < textures.size(); i++ ){
ofLoadImage(textures[i], "tex"+ofToString(i,0)+".jpg");
}

bBrushDown = false;

}

//--------------------------------------------------------------
void ofApp::update(){

// check to see if we need a new fbo size
// if the window size changes or the fbo is not allocated, we can catch it here and reallocate
if( !maskFbo.isAllocated() || maskFbo.getWidth() != ofGetWidth() || maskFbo.getHeight() != ofGetHeight() ){
Expand All @@ -36,7 +36,7 @@ void ofApp::update(){
maskFbo.begin();
ofClear(0,0,0,255);
maskFbo.end();

drawMesh = ofMesh::plane(maskFbo.getWidth(), maskFbo.getHeight() );
// the plane has tex coords from 0 - 1, but we need tex coords from 0 -> maskFbo.getWidth()
auto& texCoords = drawMesh.getTexCoords();
Expand All @@ -45,11 +45,11 @@ void ofApp::update(){
for( auto& tc : texCoords ){
tc = maskFbo.getTexture().getCoordFromPercent(tc.x, (1.0-tc.y));
}

// lets reload the font at a size in relation to width or height
ofTrueTypeFont tf;
tf.load("Batang.ttf", MIN(maskFbo.getWidth(), maskFbo.getHeight()) / 2, true, true, true);
tf.load("Batang.ttf", std::min(maskFbo.getWidth(), maskFbo.getHeight()) / 2, true, true, true);

oLine.clear();
// pull out the polylines of the O character for later use
// getCharacterAsPoints returns an ofPath
Expand All @@ -60,7 +60,7 @@ void ofApp::update(){
for( auto op : opolys ){
oLine.addVertices( op.getVertices() );
}

fLine.clear();
// pull out the polylines of the F character for later use
opath = tf.getCharacterAsPoints('F', true, false);
Expand All @@ -75,7 +75,7 @@ void ofApp::update(){
void ofApp::draw(){

ofSetColor(255);

//----------------------------------------------------------
// draw the brush into the fbo with the position based on the polylines derived from the font
maskFbo.begin();
Expand All @@ -87,21 +87,21 @@ void ofApp::draw(){
// store the elapsed time in a variable for later use
float elapsedTime = ofGetElapsedTimef();
float deltaTime = ofClamp( ofGetLastFrameTime(), 1.f / 1000.0, 1.f / 5.0f );

float mouseXPercent = ofMap( ofGetMouseX(), 0, ofGetWidth(), 0.05, 1.0, true );
eTimeCounter += deltaTime * mouseXPercent;

float offset = ofMap( ofGetMouseY(), 10, ofGetHeight()-10, 0, 100, true);

float polylinePercent = ofWrap( eTimeCounter, 0, 1);
float findex = oLine.getIndexAtPercent(polylinePercent);

auto position = oLine.getPointAtPercent( polylinePercent );
auto normal = oLine.getNormalAtIndexInterpolated(findex);
normal *= sin( elapsedTime * 13.4f ) * cos(elapsedTime * 2.4f);
normal.z = 0.0;
position += normal * offset;

ofPushMatrix();
// translate to the center of the fbo //
ofTranslate( maskFbo.getWidth()/2., maskFbo.getHeight() / 2. );
Expand All @@ -110,15 +110,15 @@ void ofApp::draw(){
ofTranslate( -oLine.getBoundingBox().getWidth()*0.75f, 0.0f );
brushImage.draw(position.x, position.y, brushSize, brushSize);
ofPopMatrix();


findex = fLine.getIndexAtPercent(polylinePercent);
position = fLine.getPointAtPercent( polylinePercent );
normal = fLine.getNormalAtIndexInterpolated(findex);
normal *= sin( elapsedTime * 9.4f ) * cos(elapsedTime * 5.4f);
normal.z = 0.0;
position += normal * offset;

ofPushMatrix();
// translate to the center of the fbo //
ofTranslate( maskFbo.getWidth()/2., maskFbo.getHeight() / 2. );
Expand All @@ -127,7 +127,7 @@ void ofApp::draw(){
ofTranslate( fLine.getBoundingBox().getWidth()*0.75f, 0.0f );
brushImage.draw(position.x, position.y, brushSize, brushSize);
ofPopMatrix();

maskFbo.end();

//----------------------------------------------------------
Expand All @@ -144,7 +144,7 @@ void ofApp::draw(){
brushImage.draw(brushImageX, brushImageY, brushSize, brushSize);
maskFbo.end();
}

//----------------------------------------------------------
// HERE the shader-masking happens
shader.begin();
Expand All @@ -169,9 +169,9 @@ void ofApp::draw(){
ofTranslate(ofGetWidth()/2, ofGetHeight()/2 );
drawMesh.draw();
ofPopMatrix();

shader.end();

//----------------------------------------------------------
float drawStringY = 0;
ofDrawBitmapStringHighlight("Drag the Mouse to draw. Mode (e): "+string(bEraser?"eraser":"brush"), 15,drawStringY+=15);
Expand Down Expand Up @@ -217,7 +217,7 @@ void ofApp::keyReleased(int key){

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y){

}

//--------------------------------------------------------------
Expand Down Expand Up @@ -246,6 +246,6 @@ void ofApp::gotMessage(ofMessage msg){
}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
void ofApp::dragEvent(ofDragInfo dragInfo){

}
Loading