コード例 #1
0
// todo: update -(handled by)-> animation
// returns true if rendering succeeded
// only swap the FBo if you also transfer the pixels
bool basicEffect::render(karmaFboLayer& renderLayer, const animationParams& params){
	ofScopedLock lock(effectMutex);
	if( !isReady() ) return false;
	
	// only swap if you need access to the previous FBO's source
	//renderLayer.swap(); // ping-pong!
	
	renderLayer.begin();
	
	ofPushStyle();
	
	// draw bounding box
	ofSetColor(mainColor[0]*255, mainColor[1]*255, mainColor[2]*255, mainColor[3]*255);
	ofNoFill();
	if(overallBoundingBox.width > 0) ofDrawRectangle( overallBoundingBox );
	
	// by default, basicEffect uses the shape's default rendering mode
	for(int i=0; i<shapes.size(); i++){
		shapes[i]->sendToGPU();
	}
	
	ofPopStyle();
	
	renderLayer.end();
	
	return true;
}
コード例 #2
0
bool gpuGlitchEffect::render(karmaFboLayer& renderLayer, const animationParams &params){
	if(!isReady()) return false;
	
	if(fbo.isAllocated()){
		
		renderLayer.begin();
		
		ofPushStyle();
		ofSetColor(mainColor[0]*255, mainColor[1]*255, mainColor[2]*255, mainColor[3]*255);
		ofFill();
		
		ofEnableBlendMode(OF_BLENDMODE_MULTIPLY);
		
		
		// bind the glitched fbo
		//fbo.getTexture().bind();
		//fbo.getTexture().bind(); // todo, doesn't work... need to use a shader here ?
		
		// draw shape so GPU gets their vertex data
		for(auto it=shapes.begin(); it!=shapes.end(); ++it){
			(*it)->sendToGPU();
		}
		ofDisableBlendMode();
		
		//fbo.getTexture().unbind();
		
		ofPopStyle();
		
		//fbo.getTexture().setAlphaMask();
		fbo.getTexture().draw(0,0);
		
		renderLayer.end();
	}
	
	return true;
}