Implementing a simple GUI panel with sliders
Let's create a simple GUI consisting of a panel and three sliders. The first thing required is to add the ofxGui
addon to the project. Fortunately, we already did it when creating the project in the previous chapter (see step 4 (Selecting the addons) of the Creating a project section of Chapter 2, Creating Your First openFrameworks Project). Perform the following steps:
- Include the addon's header to the
ofApp.h
file by inserting the following line (after the#include "ofMain.h"
line):#include "ofxGui.h"
- Next, declare the visual panel and four sliders by adding the following lines to the
ofApp
class' declaration:ofxPanel gui; ofxIntSlider countX; ofxFloatSlider stepX; ofxFloatSlider twistX;
The first line declares the GUI panel, which will be a container for all our GUI elements. The second line declares the
countX
slider, which holds integer values. The last two lines declare thestepX
andtwistX
sliders with float...