1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
}
|