Skip to content

Instantly share code, notes, and snippets.

@studioijeoma
Created November 20, 2012 19:27
Show Gist options
  • Save studioijeoma/4120423 to your computer and use it in GitHub Desktop.
Save studioijeoma/4120423 to your computer and use it in GitHub Desktop.
#include "cinder/app/AppBasic.h"
#include "cinder/gl/gl.h"
#include "cinder/gl/Fbo.h"
#include "cinder/gl/Texture.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::color(Color(255,255,255));
gl::drawSolidCircle(getWindowCenter(), 200);
fbo1.unbindFramebuffer();
//fbo2.bindFramebuffer();
//gl::color(Color(255,0,0));
//gl::drawSolidCircle(getWindowCenter(), 200);
//fbo2.unbindFramebuffer();
//fbo2.getTexture().enableAndBind();
//glEnable(GL_SCISSOR_TEST);
fbo2.bindTexture();
gl::enable(GL_SCISSOR_TEST);
glScissor( 0,0,fbo2.getWidth(),fbo2.getHeight() );
gl::color(Color(1.0,0.0,0.0));
gl::drawSolidCircle(getWindowCenter(), 200);
gl::disable(GL_SCISSOR_TEST);
fbo2.unbindTexture();
}
void MirroredFboApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::color(Color(1,1,1));
//gl::draw(fbo1.getTexture(),Vec2f::zero());
//gl::draw(fbo2.getTexture(), Rectf(fbo1.getWidth()/2,0,fbo1.getWidth(),fbo1.getHeight() ));
gl::draw(fbo2.getTexture(),Vec2f(0,0));
}
CINDER_APP_BASIC( MirroredFboApp, RendererGl )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment