-
Notifications
You must be signed in to change notification settings - Fork 0
/
ofxFeedback.h
42 lines (35 loc) · 895 Bytes
/
ofxFeedback.h
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
#pragma once
#include "ofMain.h"
//heavily inspired by https://p5js.org/examples/3d-simple-feedback.html
struct ofxFeedback {
inline void setup(float width, float height) {
this->width = width;
this->height = height;
target.allocate(width, height, GL_RGBA32F_ARB);
buffer.allocate(width, height, GL_RGBA32F_ARB);
}
inline void begin() {
capture.begin();
}
inline void end() {
buffer.draw(0, 0, width, height);
capture.end();
buffer.begin();
capture.draw(
-width / scale,
-height / scale,
width + (width / (scale * 0.5)),
height + (height / (scale * 0.5)));
ofSetColor(0, 0, 0, clearValue);
ofDrawRectangle(0, 0, width, height);
buffer.end();
}
inline void draw(float x, float y) {
buffer.draw(x, y);
}
float width, height;
float scale = 0.f;
int clearValue = 1;
ofFbo capture;
ofFbo buffer;
};