I’ve been having trouble trying to understand the difference between the matrices used when drawing a rectangle to an FBO and when rendering to the screen (I had thought they shouldn’t be different?).
In particular, I’m trying to make a small 100x100px FBO and set it up with standard co-ordinates (0, 0 - topleft, 100,100 - bottom right).
both
setMatricesWindow(100,100)
and
CameraOrtho cam(0, 100, 100, 0, -1, 1);
gl::setMatrices(cam);
give me an identical but totally messed up coordinate system as follows:
void cinder_VBO_testApp::setup()
{
_fbo = gl::Fbo::create(100, 100, true, false, false);
}
void cinder_VBO_testApp::draw()
{
{
gl::ScopedFramebuffer fbScp( _fbo );
gl::ScopedMatrices();
CameraOrtho cam(0, 100, 100, 0, -1, 1);
gl::setMatrices(cam);
//gl::setMatricesWindow(100,100); - this gives the same result as above
gl::color(0.5,0.5,0);
gl::drawSolidRect( Rectf(1, 80, 15, 99)); //WHAT?!! these numbers seem totally arbitrary, I found them through trial and error
}
gl::setMatricesWindow(getWindowSize());
gl::clear( Color( 0, 0, 0 ) );
gl::draw(_fbo->getColorTexture(), Rectf(0,0,getWindowSize().x, getWindowSize().y));
}
This gives me the following:
Whereas if I do the same without the Fbo bound it works as expected:
void cinder_VBO_testApp::draw()
{
gl::setMatricesWindow(100,100);
gl::clear( Color( 0, 0, 0 ) );
gl::color(0.5,0.5,0);
gl::drawSolidRect( Rectf(10, 10, 90, 90));
}
gives me: