@ofpixel wrote:
Hi.
I have project where I render a:
- fragment shader -> screen
- screen output -> fbo
- fbo -> images
I use multibuffer shaders, which I managed to get to work properly.
Now, I have 512x2 texture containing music data which I load into buffer Viz_A. However, once I activate the recording which cause the screen output to be written to mainFbo, that texture is not transferred anymore. Everything is still being rendering correctly except for the spectrum that needs that texture.
Look for the HERE to find where I assume the problem.
This is probably a buffer stall. How should I change the buffer handling?void ofApp::update(){ //music data -> pixels for (int i = 0; i < 512 * 4; i+=4){ int fftScale = 255; pixels[i] = (int)ofClamp(fft.magnitudesDB[i/8] * fftScale, 0, 255); pixels[i+(512*4)] = (int)ofClamp(128 + (127 * waveBuffer[i/8]) * fftScale, 0, 255); } //pixels -> texture musictex.loadData(pixels, 512, 2, GL_RGBA); /* HERE */ //texture -> shader //shader updates if(VizButton) { for( int i = 0; i < 2; i++ ){ Viz_A.beginS(); Viz_A.setPingPongFbo("tex0", musictex, 0); /* HERE */ Viz_A.setPingPongFbo("tex1", Viz_A.getPingPongFbo(),1); if(i==1)Viz_A.update(); Viz_A.endS(); ... Viz.beginS(); Viz.setPingPongFbo("tex0", Viz_C.getTexture(), 0); Viz.setPingPongFbo("tex1",bg_img.getTexture(),1); Viz.update(); Viz.endS(); } Viz_A.swap(); ... Viz.swap(); } //fbo -> images if(record){ pixelsFbo.clear();// copy the fbo texture to a buffer mainFbo.dst->getTexture().copyTo(pixelBufferBack); //TODO change fbo // map the buffer so we can access it from the cpu // and wrap the memory in an ofPixels to save it // easily. Finally unmap it. pixelBufferFront.bind(GL_PIXEL_UNPACK_BUFFER); unsigned char * p = pixelBufferFront.map<unsigned char>(GL_READ_ONLY); pixelsFbo.setFromExternalPixels(p,mainFbo.dst->getWidth(),mainFbo.dst->getHeight(),OF_PIXELS_RGB); ofSaveImage(pixelsFbo,"render/"+ofToString(ofGetFrameNum())+".png"); pixelBufferFront.unmap(); // swap the front and back buffer so we are always // copying the texture to one buffer and reading // back from another to avoid stalls swap(pixelBufferBack,pixelBufferFront); } }
//screen -> fbo
void ofApp::draw(){ mainFbo.src->begin(); ofClear(0,0,0,0); if(VizButton) Viz.draw(); mainFbo.src->end(); mainFbo.swap(); AppGUI.draw(); AppGUI.setPosition(600, 0); }
Posts: 1
Participants: 1