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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
This file is part of the MinGfx Project.
Copyright (c) 2017,2018 Regents of the University of Minnesota.
All Rights Reserved.
Original Author(s) of this File:
Dan Keefe, 2018, University of Minnesota
Author(s) of Significant Updates/Modifications to the File:
...
*/
#include <mingfx.h>
using namespace mingfx;
/** An application that opens up a window that includes a few buttons
for controlling the simulation and can be used to draw circles and
other computer graphics.
After constructing a new CircleViewer, call Run() to start and
run the application. Run() will not return until the application
window is closed. Make sure that you call cs3081::InitGraphics()
before creating the RobotViewer app. Example:
```
int main(int argc, char **argv) {
cs3081::InitGraphics();
cs3081::CircleViewer *app = new cs3081::CircleViewer();
app->Run();
cs3081::ShutdownGraphics();
return 0;
}
```
While the window is open UpdateSimulation() will be called
repeatedly, once per frame. Fill this in to update your simulation
or perform any other processing that should happen over time as the
simulation progresses.
Fill in the On*() methods as desired to respond to user input events.
Fill in the Draw*() methods to draw graphics to the screen using
either the nanovg library or raw OpenGL.
*/
class GuiPlusOpenGL : public GraphicsApp {
public:
GuiPlusOpenGL();
~GuiPlusOpenGL();
void InitNanoGUI();
void UpdateSimulation(double dt);
void OnRestartBtnPressed();
void OnPauseBtnPressed();
void OnMouseMove(const Point2 &pos, const Vector2 &delta);
void OnLeftMouseDown(const Point2 &pos);
void OnLeftMouseDrag(const Point2 &pos, const Vector2 &delta);
void OnLeftMouseUp(const Point2 &pos);
void OnMiddleMouseDown(const Point2 &pos);
void OnMiddleMouseDrag(const Point2 &pos, const Vector2 &delta);
void OnMiddleMouseUp(const Point2 &pos);
void OnRightMouseDown(const Point2 &pos);
void OnRightMouseDrag(const Point2 &pos, const Vector2 &delta);
void OnRightMouseUp(const Point2 &pos);
void OnKeyDown(const char *c, int modifiers);
void OnKeyUp(const char *c, int modifiers);
void OnSpecialKeyDown(int key, int scancode, int modifiers);
void OnSpecialKeyUp(int key, int scancode, int modifiers);
void DrawUsingNanoVG(NVGcontext *ctx);
void InitOpenGL();
void DrawUsingOpenGL();
private:
double simTime_;
bool paused_;
nanogui::Button *pauseBtn_;
};
|