Skip to content

Instantly share code, notes, and snippets.

@cwhitney
Created November 20, 2012 19:30
Show Gist options
  • Save cwhitney/4120445 to your computer and use it in GitHub Desktop.
Save cwhitney/4120445 to your computer and use it in GitHub Desktop.
cinder fbo scissor
#include "cinder/app/AppBasic.h"
#include "cinder/gl/gl.h"
#include "cinder/gl/Fbo.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class MirroredFboApp : public AppBasic {
public:
void setup();
void update();
void draw();
gl::Fbo fbo1, fbo2;
};
void MirroredFboApp::setup()
{
gl::enableAlphaBlending();
fbo1 = gl::Fbo( getWindowWidth()/2, getWindowHeight() );
fbo2 = gl::Fbo( getWindowWidth(), getWindowHeight() );
}
void MirroredFboApp::update()
{
fbo1.bindFramebuffer();
gl::clear( Color(1,1,0 ) );
gl::color(Color(255,255,255));
gl::drawSolidCircle(getWindowCenter(), 200);
fbo1.unbindFramebuffer();
fbo2.bindFramebuffer();
gl::clear( Color(1,1,1 ) );
gl::color(Color(255,0,0));
gl::drawSolidCircle(getWindowCenter(), 200);
fbo2.unbindFramebuffer();
}
void MirroredFboApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::color(Color(1,1,1));
// gl::draw(fbo2.getTexture(),Vec2f::zero());
// gl::draw(fbo2.getTexture(), Rectf(fbo1.getWidth()/2,0,fbo1.getWidth(),fbo1.getHeight() ));
fbo2.getTexture().enableAndBind();
glEnable(GL_SCISSOR_TEST);
glScissor( 0,0,fbo2.getWidth()*0.5,fbo2.getHeight() );
gl::drawSolidRect( Rectf(0,0,fbo2.getWidth(),fbo2.getHeight()) );
gl::disable(GL_SCISSOR_TEST);
fbo2.unbindTexture();
}
CINDER_APP_BASIC( MirroredFboApp, RendererGl )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment