Explanations about Rectf in gl::draw functions

Hi,

I’m having troubles understanding the way gl::draw functions (such as gl::drawSolidRect( Rectf ), or gl::draw( texture, Rectf ) ) handle the Rectf that is passed as argument.
In this piece of code (no 3d involved) :

	const ci::gl::ScopedFramebuffer scopedFbo( mDrawingFbo );
	const ci::gl::ScopedViewport scopedViewport( glm::ivec2( 0 ), mDrawingFbo->getSize() );

	ci::gl::clear( ci::ColorA( 0.f, 0.f, 0.f, 1.f ) );
	ci::gl::disableDepthRead();
	ci::gl::disableDepthWrite();
	
	auto prog = // Some gl::GlslProg here
	prog->bind();
	prog->uniform( "uSize", mDrawingFbo->getSize() );
	
	ci::gl::drawSolidRect( getWindowBounds() );

I have a Fbo that has a different size than the window size (so that I can control the quality of my rendering myself), in which I just want to render a fragment shader on the whole surface.

Now in a basic OpenGL app, I would simply draw a quad the size of my Fbo after binding my program, but from what I’m experimenting in Cinder, getWindowBounds() is always the Rectf that corresponds to my whole surface, no matter what size the latter is.
The Fbo bounds on the other hand, will either be too large or too small.

Am I missing something here ? or is Cinder somehow adapting the given Rectf to the current viewport ? (which I would find quite confusing in terms of usage)

I’m sorry if I missed other discussions about that.

ci::gl::drawSolidRect(  YOUR_FBO->getColorTexture()->getBounds() );

doesn’t work?

And, I guess you would need to match your matrices with your fbo size since you are using different size of fbo with the window screen. After you scoped viewport,

gl::setMatricesWindow( YOUR_FBO->getSize() );

-av

Thank you for your reply av,
ci::gl::drawSolidRect( YOUR_FBO->getColorTexture()->getBounds() ) did not work in the first place but gl::setMatricesWindow was indeed all I needed.
I still have a lot to learn about Cinder, thanks again.

Same here :slight_smile: Glad that it helps