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
108
109
110
111
112
113
114
115
116
117
118
|
#include "viewport.h"
//make viewport oversample
viewport::viewport()
{
//ctor
}
viewport::viewport(int _w,int _h,int _ox,int _oy,int _num) {
setup(_w,_h,_ox,_oy,_num);
}
void viewport::setup(int _w,int _h,int _ox,int _oy,int _num) {
w=_w;
h=_h;
bw=w*oversample;
bh=h*oversample;
ox=_ox;
oy=_oy;
num=_num;
rb1.allocate(bw,bh,GL_RGB);
rb2.allocate(bw,bh,GL_RGB);
seed=ofRandom(1.0f);
}
void viewport::drawport(vpcontrol &control){
rb1.begin();
//can be done with texture offset?
int startx=((bw-(bw*control.fscale))/2)+control.xshift;
while (startx>0) startx-=(bw*control.fscale);
int starty=((bh-(bh*control.fscale))/2)+control.yshift;
while (starty>0) starty-=(bh*control.fscale);
for (int i=startx;i<bw*2;i+=(bw*control.fscale)) {
for (int j=starty;j<bh*2;j+=(bh*control.fscale)) {
rb2.draw(i,j,bw*control.fscale,bh*control.fscale);
}
}
if (control.fade>0){
ofEnableAlphaBlending();
ofSetColor(0,0,0,control.fade);
ofRect(0,0,bw,bh);
ofDisableAlphaBlending();
}
//do whatever with feedback
//set draw colour from palette
if (Palette.isLoaded()){
ofSetColor(Palette.getBlend((ofGetElapsedTimef()*control.freq*0.0318)/seed));
}
else {
uint8_t f=(uint8_t)((sin((ofGetElapsedTimef()*control.freq)/seed)+1.0f)*127.50f);
ofSetColor(f,f,f);
}
if (control.fill){
ofRect(0,0,bw,bh);
}
//for (int i=0;i<control.feats.size();i++){
// ofCircle(bw*0.2*i,bh*0.5,control.feats[i]*w);
//}
ofSetLineWidth(control.thickness);
if (!control.fillwave) {
ofNoFill();
}
if(control.wave){
if (h>w){
ofBeginShape();
for (int i = 0; i < bh; i++){
ofVertex((bw/2) -(control.right[i+(num*bh)]*bw),i);
}
ofEndShape(false);
}
else {
ofBeginShape();
for (int i = 0; i < bw; i++){
ofVertex(i, (bh/2) -(control.right[i+(num*bw)]*bh) );
}
ofEndShape(false);
}
}
ofFill();
if (control.drawseconds>-1){
ofCircle(control.bx*bw,control.by*bh,(control.drawseconds*bh*.02)+(bh*.01));
}
rb1.end();
rb2.begin();
ofSetColor(255,255,255);
rb1.draw(0,0);
rb2.end();
}
void viewport::draw(uint8_t b,float s){
ofSetColor(b,b,b);
rb2.draw(ox*s,oy*s,w*s,h*s);
}
viewport::~viewport()
{
//dtor
}
|