Draw a texture:
gl::draw(texture);
Draw a texture into a specified rectangle, distort texture to fill rectangle:
gl::draw(texture, Rectf(0,0,200,200));
Draw a texture to fit completely into specified rectangle
(no distortion/keeps aspect ratio, shows white space):
Rectf destRect = Rectf(0,0,200,200); gl::draw(texture, Rectf(texture.getBounds()).getCenteredFit(destRect, true));
Draw a texture to fill a specified rectangle while retaining image proportions and not showing white space (texture is centered within the rectangle and overflow is masked/cropped):
Rectf destRect = Rectf(0,0,200,200); gl::draw(texture, Area(destRect.getCenteredFit(texture.getBounds(), true)), destRect);
(This has the same effect as css3’s “background-size: cover;”)