diff options
| author | Comment <tim@gray.(none)> | 2013-05-28 01:36:25 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-05-28 01:36:25 +0100 |
| commit | 040eaa3babb648bea889f8c152b522a86e8c39d5 (patch) | |
| tree | de9209f404b899828b3dda819152e307f3d09907 /src/viewport.cpp | |
initial commit
Diffstat (limited to 'src/viewport.cpp')
| -rwxr-xr-x | src/viewport.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp new file mode 100755 index 0000000..875b439 --- /dev/null +++ b/src/viewport.cpp @@ -0,0 +1,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
+}
|
