CMU462 Library  1.0
15-462/15-662: Computer Graphics (Fall 2015)
viewer.h
1 #ifndef CMU462_VIEWER_H
2 #define CMU462_VIEWER_H
3 
4 #include "renderer.h"
5 #include "osdtext.h"
6 
7 #include <chrono>
8 
9 #include "GLFW/glfw3.h"
10 
11 namespace CMU462 {
12 
20 class Viewer {
21  public:
22 
27  Viewer( void );
28 
33  Viewer( const char* title );
34 
40  ~Viewer( void );
41 
47  void init( void );
48 
53  void start( void );
54 
60  void set_renderer( Renderer *renderer );
61 
62  private:
63 
67  static void update( void );
68 
72  static void drawInfo( void );
73 
74  // window event callbacks
75  static void err_callback( int error, const char* description );
76  static void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods );
77  static void resize_callback( GLFWwindow* window, int width, int height );
78  static void cursor_callback( GLFWwindow* window, double xpos, double ypos );
79  static void scroll_callback( GLFWwindow* window, double xoffset, double yoffset);
80  static void mouse_button_callback( GLFWwindow* window, int button, int action, int mods );
81 
82  // HDPI display
83  static bool HDPI;
84 
85  // framerate related timeers
86  static int framecount;
87  static std::chrono::time_point<std::chrono::system_clock> sys_last;
88  static std::chrono::time_point<std::chrono::system_clock> sys_curr;
89 
90  // info toggle
91  static bool showInfo;
92 
93  // window properties
94  static GLFWwindow* window;
95  static size_t buffer_w;
96  static size_t buffer_h;
97 
98  // user space renderer
99  static Renderer* renderer;
100 
101  // on-screen display
102  static OSDText* osd_text;
103  static int line_id_renderer;
104  static int line_id_framerate;
105 
106 
107 }; // class Viewer
108 
109 } // namespace CMU462
110 
111 #endif // CMU462_VIEWER_H
Definition: CMU462.h:8
Abstract renderer definition.
Definition: renderer.h:21
void set_renderer(Renderer *renderer)
Set a user space renderer.
Definition: viewer.cpp:148
~Viewer(void)
Destructor.
Definition: viewer.cpp:49
Provides OpenGL context, window display, and event handling routines.
Definition: viewer.h:20
void start(void)
Start the drawing loop of the viewer.
Definition: viewer.cpp:137
Provides an interface for text on-screen display.
Definition: osdtext.h:47
Viewer(void)
Constructor.
Definition: viewer.cpp:45
void init(void)
Initialize the viewer.
Definition: viewer.cpp:60