Last active
August 15, 2017 19:42
-
-
Save stephanschulz/20aa88b547641cf732b7c587338d547d to your computer and use it in GitHub Desktop.
ofxTextureRecorder - memory build up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "ofApp.h" | |
| ofTexture frames[60]; | |
| int counter; | |
| bool bDone; | |
| //-------------------------------------------------------------- | |
| void ofApp::setup(){ | |
| fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGB); | |
| ofxTextureRecorder::Settings settings(fbo.getTexture()); | |
| settings.imageFormat = OF_IMAGE_FORMAT_JPEG; | |
| settings.numThreads = 12; | |
| settings.maxMemoryUsage = 9000000000; | |
| recorder.setup(settings); | |
| counter = 0; | |
| bDone = false; | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::update(){ | |
| fbo.begin(); | |
| ofClear(0,255); | |
| ofDrawCircle(ofGetFrameNum()*4, ofGetWidth()/2, 50); | |
| fbo.end(); | |
| if(ofGetFrameNum()>0 && counter < 60){ | |
| ofPixels pix; | |
| fbo.readToPixels(pix); | |
| ofTexture tex; | |
| tex.loadData(pix); | |
| frames[counter] = tex; | |
| counter++; | |
| // recorder.save(tex); //fbo.getTexture()); | |
| } | |
| if(counter == 60 && bDone == false){ | |
| for(int i=0; i<60; i++){ | |
| recorder.save(frames[i]); | |
| } | |
| bDone = true; | |
| } | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::draw(){ | |
| fbo.draw(0,0); | |
| ofDrawBitmapStringHighlight("counter "+ofToString(counter), 20,20); | |
| if(ofGetFrameNum()%60==0){ | |
| cout << ofGetFrameRate() << endl; | |
| cout << "texture copy: " << recorder.getAvgTimeTextureCopy() << endl; | |
| cout << "gpu download: " << recorder.getAvgTimeGpuDownload() << endl; | |
| cout << "image encoding: " << recorder.getAvgTimeEncode() << endl; | |
| cout << "file save: " << recorder.getAvgTimeSave() << endl; | |
| } | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::keyPressed(int key){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::keyReleased(int key){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::mouseMoved(int x, int y ){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::mouseDragged(int x, int y, int button){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::mousePressed(int x, int y, int button){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::mouseReleased(int x, int y, int button){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::mouseEntered(int x, int y){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::mouseExited(int x, int y){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::windowResized(int w, int h){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::gotMessage(ofMessage msg){ | |
| } | |
| //-------------------------------------------------------------- | |
| void ofApp::dragEvent(ofDragInfo dragInfo){ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment