summaryrefslogtreecommitdiff
path: root/liveengine/src/viewport.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-09-15 17:38:00 +0100
committerTim Redfern <tim@eclectronics.org>2012-09-15 17:38:00 +0100
commit530bf6501e6f13ed3e91d4d0e2763613146774a2 (patch)
tree3bf4f0ba78842c4e6cb74dc0a62b154b64b890cf /liveengine/src/viewport.cpp
parent4fda3af17e55c0afff35b3f3ebbe5b4fd1ffad7e (diff)
performance 2.0
Diffstat (limited to 'liveengine/src/viewport.cpp')
-rwxr-xr-xliveengine/src/viewport.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/liveengine/src/viewport.cpp b/liveengine/src/viewport.cpp
new file mode 100755
index 0000000..74333b0
--- /dev/null
+++ b/liveengine/src/viewport.cpp
@@ -0,0 +1,107 @@
+#include "viewport.h"
+
+
+
+viewport::viewport()
+{
+ //ctor
+}
+
+void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
+ r=_r;
+ w=_w;
+ h=_h;
+ x=_x;
+ y=_y;
+ ox=_ox;
+ oy=_oy;
+ rb1.allocate(w,h,GL_RGB);
+ rb2.allocate(w,h,GL_RGB);
+
+ printf("%ix%i, vp offset: %f,%f\n",w,h,-(sin(ofDegToRad(r))*h/2)-(cos(ofDegToRad(r))*w/2),-(sin(ofDegToRad(r))*w/2)-(cos(ofDegToRad(r))*h/2));
+}
+
+void viewport::draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale){
+
+
+
+ // test screen shape
+ /*
+ ofSetColor(255,0,0);
+ ofRect(0,0,w/2,h/2);
+ ofRect(w/2,h/2,w/2,h/2);
+ ofSetColor(0,255,0);
+ ofRect(0,h/2,w/2,h/2);
+ ofRect(w/2,0,w/2,h/2);
+ */
+
+ rb1.begin();
+
+ //can be done with texture offset?
+
+ int startx=((w-(w*fscale))/2)+xshift;
+ while (startx>0) startx-=(w*fscale);
+ int starty=((h-(h*fscale))/2)+yshift;
+ while (starty>0) starty-=(h*fscale);
+
+ for (int i=startx;i<w*2;i+=(w*fscale)) {
+ for (int j=starty;j<h*2;j+=(h*fscale)) {
+ rb2.draw(i,j,w*fscale,h*fscale);
+ }
+ }
+
+ float notewidth=w/NUM_NOTES;
+ float noteheight=h/NUM_CONTROLLERS;
+
+ ofPushStyle();
+
+ if (note>0) {
+ switch(mode) {
+ case BLOCKS:
+ for (int i=0;i<NUM_CONTROLLERS;i++){
+ ofSetColor(ofColor((controller_colours[i].r*controllers[i])>>7,(controller_colours[i].g*controllers[i])>>7,(controller_colours[i].b*controllers[i])>>7));
+ ofRect((note-START_NOTE)*notewidth,i*noteheight,notewidth,noteheight);
+ }
+ break;
+ case LIST:
+ if (list.lock()) { //if playlist is loaded
+ if (list.layers.find(note)!=list.layers.end()) {
+ ofPushMatrix();
+ ofTranslate(w/2,h/2);
+ ofScale(scale,scale,scale);
+ ofTranslate(-w/2,-h/2);
+ if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack);
+ else list.layers[note]->draw(a,w,h);
+ ofPopMatrix();
+ }
+ list.unlock();
+ }
+ break;
+ }
+ }
+
+ rb1.end();
+
+ rb2.begin();
+ ofSetColor(255,255,255);
+ rb1.draw(0,0);
+ rb2.end();
+
+ ofPushMatrix();
+ ofTranslate(x+(w/2),y+(h/2));
+ ofRotate(r);
+ //ofTranslate(-abs(sin(ofDegToRad(r))*h/2)-abs(cos(ofDegToRad(r))*w/2),-abs(sin(ofDegToRad(r))*w/2)-abs(cos(ofDegToRad(r))*h/2));
+ ofTranslate(ox,oy);
+
+ rb2.draw(0,0);
+
+ ofPopStyle();
+
+ ofPopMatrix();
+
+}
+
+viewport::~viewport()
+{
+ //dtor
+}