Added HUD with UI sliders

This commit is contained in:
James Alliban
2014-01-07 17:11:46 +00:00
parent 721d59e5f7
commit 33298f7bcb
8 changed files with 104 additions and 80 deletions
+10 -14
View File
@@ -97,19 +97,7 @@ void GUI::addBackgroundGUI()
string title = "BACKGROUND";
ofxUICanvas* gui = getNewGUI(title);
gui->addLabel("GRADIENT COLOUR");
gui->addSpacer(length, 1);
gui->addSlider("Start red", 0, 255, &app->scene.bgGradStartCol[0], length, dim);
gui->addSlider("Start green", 0, 255, &app->scene.bgGradStartCol[1], length, dim);
gui->addSlider("Start blue", 0, 255, &app->scene.bgGradStartCol[2], length, dim);
gui->addSlider("Start alpha", 0, 255, &app->scene.bgGradStartCol[3], length, dim);
gui->addSpacer(length, 1);
gui->addSlider("End red", 0, 255, &app->scene.bgGradEndCol[0], length, dim);
gui->addSlider("End green", 0, 255, &app->scene.bgGradEndCol[1], length, dim);
gui->addSlider("End blue", 0, 255, &app->scene.bgGradEndCol[2], length, dim);
gui->addSlider("End alpha", 0, 255, &app->scene.bgGradEndCol[3], length, dim);
gui->addSpacer(length, 1);
gui->addLabel("BACKGROUND IMAGE");
gui->addLabel("VIDEO IMAGE SETTINGS");
gui->addSlider("Brightness", 0, 2, &app->scene.brightness, length, dim);
gui->addSlider("Contrast", 0, 2, &app->scene.contrast, length, dim);
gui->addSlider("Saturation", 0, 2, &app->scene.saturation, length, dim);
@@ -117,8 +105,16 @@ void GUI::addBackgroundGUI()
gui->addSlider("Green", 0, 2, &app->scene.green, length, dim);
gui->addSlider("Blue", 0, 2, &app->scene.blue, length, dim);
gui->addSlider("Alpha", 0, 2, &app->scene.alpha, length, dim);
gui->addSpacer(length, 1);
gui->addLabel("HUD SETTINGS");
gui->addSlider("Red .", 0, 255, &app->scene.hudColour[0], length, dim);
gui->addSlider("Green .", 0, 255, &app->scene.hudColour[1], length, dim);
gui->addSlider("Blue .", 0, 255, &app->scene.hudColour[2], length, dim);
gui->addSlider("Alpha .", 0, 255, &app->scene.hudColour[3], length, dim);
gui->addSlider("Radius Width", 1, 2000, &app->scene.radiusW, length, dim);
gui->addSlider("Radius Height", 1, 2000, &app->scene.radiusH, length, dim);
gui->addSlider("Circle Point Size", 0, 100, &app->scene.circlePointSize, length, dim);
ofAddListener(gui->newGUIEvent, this, &GUI::variousGUIEvent);
finaliseCanvas(gui, true);
}
+7 -1
View File
@@ -50,7 +50,8 @@ void testApp::update()
}
//--------------------------------------------------------------
void testApp::draw(){
void testApp::draw()
{
dataManager.draw();
scene.draw();
}
@@ -69,4 +70,9 @@ void testApp::keyPressed(int key)
isPaused = !isPaused;
else if (key == 'f')
ofToggleFullscreen();
}
void testApp::windowResized(int w, int h)
{
}
+1
View File
@@ -14,6 +14,7 @@ class testApp : public ofBaseApp{
void draw();
void mousePressed(int x, int y, int button);
void keyPressed(int key);
void windowResized(int w, int h);
DataManager dataManager;
Scene scene;
+34 -11
View File
@@ -25,11 +25,13 @@ void Scene::update()
void Scene::draw()
{
ofBackgroundGradient(ofColor(bgGradStartCol[0], bgGradStartCol[1], bgGradStartCol[2], bgGradStartCol[3]),
ofColor(bgGradEndCol[0], bgGradEndCol[1], bgGradEndCol[2], bgGradEndCol[3]),
OF_GRADIENT_CIRCULAR);
drawVideo();
barGraph.draw();
drawHUD();
}
void Scene::drawVideo()
{
rgbShader.begin();
rgbShader.setUniform1f("brightness", brightness);
@@ -39,13 +41,34 @@ void Scene::draw()
rgbShader.setUniform1f("green", green);
rgbShader.setUniform1f("blue", blue);
rgbShader.setUniform1f("alpha", alpha);
bgImg.draw(0, 0, ofGetWidth(), ofGetHeight());
rgbShader.end();
barGraph.draw();
bgImg.draw(0, 0, ofGetWidth(), ofGetHeight());
rgbShader.end();
}
void Scene::drawHUD()
{
ofPushStyle();
ofSetColor(hudColour[0], hudColour[1], hudColour[2], hudColour[3]);
ofBeginShape();
ofVertex(0, 0);
ofVertex(ofGetWidth(), 0);
ofVertex(ofGetWidth(), ofGetHeight());
ofVertex(0, ofGetHeight());
ofNextContour(true);
for (int i = 0; i < (int)circlePointSize; i++)
{
float x = (ofGetWidth() * 0.5) + cos(((float)i / (int)circlePointSize) * TWO_PI) * radiusW;
float y = (ofGetHeight() * 0.5) + sin(((float)i / (int)circlePointSize) * TWO_PI) * radiusH;
ofVertex(x, y);
}
ofEndShape(true);
ofPopStyle();
ofFill();
}
+7 -4
View File
@@ -19,14 +19,17 @@ public:
void setup();
void update();
void draw();
void drawVideo();
void drawHUD();
BarGraph barGraph;
ofShader rgbShader;
ofImage bgImg;
float brightness, contrast, saturation, red, green, blue, alpha;
float bgGradStartCol[4];
float bgGradEndCol[4];
float hudColour[4];
float circlePointSize;
float radiusW;
float radiusH;
};