The drawing on the screen in openFrameworks should be performed in the testApp::draw()
function (see the testApp.cpp section in Chapter 1, openFrameworks Basics). Before this function is called by openFrameworks, the entire screen is filled with a fixed color, which is set by the function ofSetBackground( r, g, b )
. Here r
, g
, and b
are integer values corresponding to red, green, and blue components of the background color in the range 0 to 255. Note that each of the ofSetBackground()
function call fills the screen with the specified color immediately.
Tip
You can make a gradient background using the ofBackgroundGradient()
function. See its description in the The triangles cloud example section in Chapter 7, Drawing in 3D.
You can set the background color just once in the testApp::setup()
function, but we often call ofSetBackground()
in the beginning of the testApp::draw()
function to not mix up the setup stage and the drawing stage.