#include "viewport.h" viewport::viewport() { //ctor } viewport::viewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { setup(_w,_h,_x,_y,_r,_ox,_oy); } 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,float colShift){ // 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;i0) { switch(mode) { case BLOCKS: for (int i=0;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); ofSetColor(255,255,255); if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack,colShift); else list.layers[note]->draw(a,w,h,colShift); 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 }