Browse Source

Add simple addSurface method on n key press

master
Krisjanis Rijnieks 11 years ago
parent
commit
7d4fdf5c7e
  1. 18
      example/src/ofApp.cpp
  2. 1
      example/src/ofApp.h

18
example/src/ofApp.cpp

@ -70,6 +70,7 @@ void ofApp::keyPressed(int key)
case '4': gui.setMode(ofxGuiMode::SOURCE_SELECTION); break;
case 'i': bShowInfo = !bShowInfo; break;
case 'r': addRandomSurface(); break;
case 'n': addSurface(); break;
case 'f': ofToggleFullscreen(); break;
case 's': surfaceManager.saveXmlSettings("surfaces.xml"); break;
default: break;
@ -106,4 +107,21 @@ void ofApp::addRandomSurface()
texCoords.push_back( ofVec2f( ofRandomuf(), ofRandomuf() ) );
texCoords.push_back( ofVec2f( ofRandomuf(), ofRandomuf() ) );
surfaceManager.addSurface(surfaceType, vertices, texCoords);
}
void ofApp::addSurface()
{
int surfaceType = ofxSurfaceType::TRIANGLE_SURFACE;
vector<ofVec2f> vertices;
vertices.push_back( ofVec2f( (float)ofGetWidth()/2.0f, 0.0f ) );
vertices.push_back( ofVec2f( (float)ofGetWidth(), (float)ofGetHeight() ) );
vertices.push_back( ofVec2f( 0.0f, (float)ofGetHeight() ) );
vector<ofVec2f> texCoords;
texCoords.push_back( ofVec2f( 0.5f, 0.0f ) );
texCoords.push_back( ofVec2f( 1.0f, 1.0f ) );
texCoords.push_back( ofVec2f( 0.0f, 1.0f ) );
surfaceManager.addSurface(surfaceType, vertices, texCoords);
// select this surface right away
surfaceManager.selectSurface(surfaceManager.size()-1);
}

1
example/src/ofApp.h

@ -17,6 +17,7 @@ public:
void mouseDragged(int x, int y, int button);
void addRandomSurface();
void addSurface();
ofImage image;
ofxSurfaceManager surfaceManager;

Loading…
Cancel
Save