summaryrefslogtreecommitdiff
path: root/src/viewport.cpp
blob: 875b4393d9683ba85f7156ea6aa3f0869943f15b (plain)
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
#include "viewport.h"

viewport::viewport()
{
    //ctor
}
viewport::viewport(int _w,int _h,int _ox,int _oy) {
	setup(_w,_h,_ox,_oy);
}

void viewport::setup(int _w,int _h,int _ox,int _oy) {
	w=_w;
	h=_h;
	ox=_ox;
	oy=_oy;
	rb1.allocate(w,h,GL_RGB);
	rb2.allocate(w,h,GL_RGB);
	seed=ofRandom(1.0f);
}

void viewport::drawport(vpcontrol &control){
		
		rb1.begin();

		//can be done with texture offset?

		int startx=((w-(w*control.fscale))/2)+control.xshift;
		while (startx>0) startx-=(w*control.fscale);
		int starty=((h-(h*control.fscale))/2)+control.yshift;
		while (starty>0) starty-=(h*control.fscale);
		
		for (int i=startx;i<w*2;i+=(w*control.fscale)) {
			for (int j=starty;j<h*2;j+=(h*control.fscale)) {
			    rb2.draw(i,j,w*control.fscale,h*control.fscale);
			}
		}

		//do whatever with feedback

		if (control.fillgrey){
			uint8_t f=(uint8_t)((sin((ofGetElapsedTimef()*control.fillgreyfreq)/seed)+1.0f)*127.50f);
			ofSetColor(f,f,f);
			ofRect(0,0,w,h);
		}
		

		rb1.end();

		rb2.begin();
		ofSetColor(255,255,255);
		rb1.draw(0,0);
		rb2.end();

}
void viewport::draw(uint8_t b){
			
	ofSetColor(b,b,b);
	rb2.draw(ox,oy);

}

viewport::~viewport()
{
    //dtor
}