Browse Source

Add remove surface method to both examples, press backspace and delete selected surface

master
Krisjanis Rijnieks 11 years ago
parent
commit
f7df8734d6
  1. 1
      example-fboTexture/src/ofApp.cpp
  2. 1
      example/src/ofApp.cpp
  3. 14
      src/ofxSurfaceManager.cpp
  4. 1
      src/ofxSurfaceManager.h

1
example-fboTexture/src/ofApp.cpp

@ -94,6 +94,7 @@ void ofApp::keyPressed(int key)
case 'f': ofToggleFullscreen(); break;
case 's': surfaceManager.saveXmlSettings("surfaces.xml"); break;
case 'a': setFboAsTexture(); break;
case OF_KEY_BACKSPACE: surfaceManager.removeSelectedSurface(); break;
default: break;
}
}

1
example/src/ofApp.cpp

@ -69,6 +69,7 @@ void ofApp::keyPressed(int key)
case 'n': addSurface(); break;
case 'f': ofToggleFullscreen(); break;
case 's': surfaceManager.saveXmlSettings("surfaces.xml"); break;
case OF_KEY_BACKSPACE: surfaceManager.removeSelectedSurface(); break;
default: break;
}
}

14
src/ofxSurfaceManager.cpp

@ -82,6 +82,20 @@ void ofxSurfaceManager::addSurface(int surfaceType, ofTexture* texturePtr, vecto
}
}
void ofxSurfaceManager::removeSelectedSurface()
{
if ( selectedSurface == NULL ) return;
for ( int i=0; i<surfaces.size(); i++ ) {
if ( surfaces[i] == selectedSurface ) {
delete surfaces[i];
surfaces.erase(surfaces.begin()+i);
selectedSurface = NULL;
break;
}
}
}
void ofxSurfaceManager::manageMemory()
{
// check if each of the sources is assigned to a surface or not

1
src/ofxSurfaceManager.h

@ -20,6 +20,7 @@ public:
void addSurface(int surfaceType, ofTexture* texturePtr);
void addSurface(int surfaceType, vector<ofVec2f> vertices, vector<ofVec2f> texCoords);
void addSurface(int surfaceType, ofTexture* texturePtr, vector<ofVec2f> vertices, vector<ofVec2f> texCoords);
void removeSelectedSurface();
void manageMemory(); // deletes unasigned sources
void clear();
void saveXmlSettings(string fileName);

Loading…
Cancel
Save