2014-01-06 02:40:24 +00:00
|
|
|
//
|
|
|
|
|
// gui->cpp
|
|
|
|
|
// emptyExample
|
|
|
|
|
//
|
|
|
|
|
// Created by James Alliban on 25/06/2013.
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "Scene.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Scene::setup()
|
|
|
|
|
{
|
2014-01-07 00:48:58 +00:00
|
|
|
bgImg.loadImage("images/tanks.jpg");
|
|
|
|
|
rgbShader.load("shaders/RGBShader");
|
2014-01-06 02:40:24 +00:00
|
|
|
barGraph.setup();
|
2014-01-08 17:31:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
text.loadFont("fonts/mplus-1c-regular.ttf", 8);
|
|
|
|
|
//text.setLineLength(ofGetWidth() - margin * 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xMargin = 500;
|
|
|
|
|
yMargin = 400;
|
|
|
|
|
lineLength = 200;
|
2014-01-06 02:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Scene::update()
|
|
|
|
|
{
|
|
|
|
|
barGraph.update();
|
2014-01-08 17:31:33 +00:00
|
|
|
|
|
|
|
|
text.setLineLength(lineLength);
|
|
|
|
|
text.setLineSpacing(lineSpacing);
|
|
|
|
|
text.setSize(textSize);
|
|
|
|
|
|
2014-01-06 02:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Scene::draw()
|
|
|
|
|
{
|
2014-01-07 17:11:46 +00:00
|
|
|
drawVideo();
|
|
|
|
|
barGraph.draw();
|
2014-01-08 17:31:33 +00:00
|
|
|
drawHUDBG();
|
|
|
|
|
drawHUDCopy();
|
2014-01-07 17:11:46 +00:00
|
|
|
}
|
2014-01-07 00:48:58 +00:00
|
|
|
|
2014-01-07 17:11:46 +00:00
|
|
|
void Scene::drawVideo()
|
|
|
|
|
{
|
2014-01-07 00:48:58 +00:00
|
|
|
rgbShader.begin();
|
|
|
|
|
|
|
|
|
|
rgbShader.setUniform1f("brightness", brightness);
|
|
|
|
|
rgbShader.setUniform1f("contrast", contrast);
|
|
|
|
|
rgbShader.setUniform1f("saturation", saturation);
|
|
|
|
|
rgbShader.setUniform1f("red", red);
|
|
|
|
|
rgbShader.setUniform1f("green", green);
|
|
|
|
|
rgbShader.setUniform1f("blue", blue);
|
|
|
|
|
rgbShader.setUniform1f("alpha", alpha);
|
2014-01-07 17:11:46 +00:00
|
|
|
|
2014-01-07 00:48:58 +00:00
|
|
|
bgImg.draw(0, 0, ofGetWidth(), ofGetHeight());
|
2014-01-07 17:11:46 +00:00
|
|
|
|
2014-01-07 00:48:58 +00:00
|
|
|
rgbShader.end();
|
2014-01-07 17:11:46 +00:00
|
|
|
}
|
2014-01-07 00:48:58 +00:00
|
|
|
|
2014-01-08 17:31:33 +00:00
|
|
|
void Scene::drawHUDBG()
|
2014-01-07 17:11:46 +00:00
|
|
|
{
|
|
|
|
|
ofPushStyle();
|
|
|
|
|
ofSetColor(hudColour[0], hudColour[1], hudColour[2], hudColour[3]);
|
|
|
|
|
ofBeginShape();
|
2014-01-07 00:48:58 +00:00
|
|
|
|
2014-01-07 17:11:46 +00:00
|
|
|
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);
|
|
|
|
|
}
|
2014-01-07 00:48:58 +00:00
|
|
|
|
2014-01-07 17:11:46 +00:00
|
|
|
ofEndShape(true);
|
|
|
|
|
ofPopStyle();
|
2014-01-06 02:40:24 +00:00
|
|
|
|
2014-01-07 17:11:46 +00:00
|
|
|
ofFill();
|
2014-01-08 17:31:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Scene::drawHUDCopy()
|
|
|
|
|
{
|
|
|
|
|
string tlStr = "TOP LEFT\nThis is some text\nthis is some more text\na little more";
|
|
|
|
|
drawTextBox(tlStr, "TOP LEFT");
|
|
|
|
|
string trStr = "TOP RIGHT\nThis is some text\nthis is some more text\na little more\none more line";
|
|
|
|
|
drawTextBox(trStr, "TOP RIGHT");
|
|
|
|
|
string blStr = "BOTTOM LEFT\nThis is some text\nthis is some more text";
|
|
|
|
|
drawTextBox(blStr, "BOTTOM LEFT");
|
|
|
|
|
string brStr = "BOTTOM RIGHT\nThis is some text\nthis is some more text\na little more";
|
|
|
|
|
drawTextBox(brStr, "BOTTOM RIGHT");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Scene::drawTextBox(string copy, string align)
|
|
|
|
|
{
|
|
|
|
|
ofPushStyle();
|
|
|
|
|
ofSetColor(textColour[0], textColour[1], textColour[2], textColour[3]);
|
|
|
|
|
ofPushMatrix();
|
|
|
|
|
if (align == "TOP LEFT")
|
|
|
|
|
{
|
|
|
|
|
ofTranslate(xMargin, yMargin);
|
|
|
|
|
text.setAlignment(FTGL_ALIGN_LEFT);
|
|
|
|
|
}
|
|
|
|
|
else if (align == "TOP RIGHT")
|
|
|
|
|
{
|
|
|
|
|
text.setAlignment(FTGL_ALIGN_RIGHT);
|
|
|
|
|
ofTranslate(ofGetWidth() - xMargin - lineLength, yMargin);
|
|
|
|
|
}
|
|
|
|
|
else if (align == "BOTTOM LEFT")
|
|
|
|
|
{
|
|
|
|
|
ofTranslate(xMargin, ofGetHeight() - yMargin - yMarginBottomOffset);
|
|
|
|
|
text.setAlignment(FTGL_ALIGN_LEFT);
|
|
|
|
|
}
|
|
|
|
|
if (align == "BOTTOM RIGHT")
|
|
|
|
|
{
|
|
|
|
|
text.setAlignment(FTGL_ALIGN_RIGHT);
|
|
|
|
|
ofTranslate(ofGetWidth() - xMargin - lineLength, ofGetHeight() - yMargin - yMarginBottomOffset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text.drawString(copy, 0, 0);
|
|
|
|
|
|
|
|
|
|
ofPopMatrix();
|
|
|
|
|
ofPopStyle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Scene::keyPressed(int key)
|
|
|
|
|
{
|
|
|
|
|
|
2014-01-07 17:11:46 +00:00
|
|
|
}
|