Let's create two sliders and use them to mix 2D and 3D graphics using the following steps:
Declare a new slider and a new offscreen buffer for storing the sphere image in the
ofApp
class:ofxFloatSlider show2d, show3d; ofFbo fbo3d;
Add commands to set up sliders and the offscreen buffer to
setup()
, after themixerGroup.add( ky.setup...
command:mixerGroup.add( show2d.setup("show2d", 255, 0, 255) ); mixerGroup.add( show3d.setup("show3d", 255, 0, 255) ); fbo3d.allocate( ofGetWidth(), ofGetHeight(), GL_RGBA );
The first and second lines set sliders to have a range from
0
to255
and add them to the GUI groupmixerGroup
(this group was created in the previous chapter). The third line allocates the offscreen buffer with size equal to the screen size. We set theGL_RGBA
pixel format for this buffer, so it will hold the pixels colors together with the alpha channel. Such a format is required here to properly mixfbo3d
contents withfbo2
contents using the alpha blending...