-
Notifications
You must be signed in to change notification settings - Fork 876
/
Copy pathmain.cpp
48 lines (36 loc) · 1.52 KB
/
main.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
#include <pangolin/display/display.h>
#include <pangolin/plot/plotter.h>
int main(/*int argc, char* argv[]*/)
{
// Create OpenGL window in single line
pangolin::CreateWindowAndBind("Main",640,480);
// Data logger object
pangolin::DataLog log;
// Optionally add named labels
std::vector<std::string> labels;
labels.push_back(std::string("sin(t)"));
labels.push_back(std::string("cos(t)"));
labels.push_back(std::string("sin(t)+cos(t)"));
log.SetLabels(labels);
const float tinc = 0.01f;
// OpenGL 'view' of data. We might have many views of the same data.
pangolin::Plotter plotter(&log,0.0f,4.0f*(float)M_PI/tinc,-2.0f,2.0f,(float)M_PI/(4.0f*tinc),0.5f);
plotter.SetBounds(0.0, 1.0, 0.0, 1.0);
plotter.Track("$i");
// Add some sample annotations to the plot
plotter.AddMarker(pangolin::Marker::Vertical, -1000, pangolin::Marker::LessThan, pangolin::Colour::Blue().WithAlpha(0.2f) );
plotter.AddMarker(pangolin::Marker::Horizontal, 100, pangolin::Marker::GreaterThan, pangolin::Colour::Red().WithAlpha(0.2f) );
plotter.AddMarker(pangolin::Marker::Horizontal, 10, pangolin::Marker::Equal, pangolin::Colour::Green().WithAlpha(0.2f) );
pangolin::DisplayBase().AddDisplay(plotter);
float t = 0;
// Default hooks for exiting (Esc) and fullscreen (tab).
while( !pangolin::ShouldQuit() )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
log.Log(sin(t),cos(t),sin(t)+cos(t));
t += tinc;
// Render graph, Swap frames and Process Events
pangolin::FinishFrame();
}
return 0;
}