-
Notifications
You must be signed in to change notification settings - Fork 1
/
viewer.cpp
59 lines (51 loc) · 1.25 KB
/
viewer.cpp
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
// vjshader
//
// viewer.cpp
//
// Created by Lewis Lepton on 24/04/2020.
// lewislepton.com
//
#include "viewer.hpp"
//--------------------------------------------------------------
void viewer::setup(){
fbo.allocate(ofGetWidth(), ofGetHeight());
fbo.begin();
ofClear(255);
shader.allocate(fbo.getWidth(), fbo.getHeight());
shader.load("color.frag");
fbo.end();
shapes.setup();
// Setup light
light.setPosition(1000, 1000, 2000);
}
//--------------------------------------------------------------
void viewer::update(){
fbo.begin();
shapes.update();
shader.setUniform3f("u_color", color.x, color.y, color.z);
fbo.end();
fbo.begin();
shader.render();
shader.draw(0, 0, ofGetWidth(), ofGetHeight());
fbo.end();
}
//--------------------------------------------------------------
void viewer::draw(){
// ofEnableDepthTest();
light.enable();
fbo.draw(0, 0);
camera.begin();
shapes.draw();
camera.end();
}
//--------------------------------------------------------------
void viewer::keyPressed(int key){
if (key == 'f'){
ofToggleFullscreen();
}
}
//--------------------------------------------------------------
void viewer::windowResized(int w, int h){
shader.allocate(w, h);
fbo.allocate(w, h);
}