CMU462 Library Documentation  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.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 
81  // HDPI display
82  static bool HDPI;
83 
84  // framerate related timeers
85  static int framecount;
86  static std::chrono::time_point<std::chrono::system_clock> sys_last;
87  static std::chrono::time_point<std::chrono::system_clock> sys_curr;
88 
89  // info toggle
90  static bool showInfo;
91 
92  // window properties
93  static GLFWwindow* window;
94  static size_t buffer_w;
95  static size_t buffer_h;
96 
97  // user space renderer
98  static Renderer* renderer;
99 
100  // on-screen display
101  static OSDText* osd_text;
102  static int line_id_renderer;
103  static int line_id_framerate;
104 
105 
106 }; // class Viewer
107 
108 } // namespace CMU462
109 
110 #endif // CMU462_VIEWER_H
Definition: color.cpp:10
Abstract renderer definition.
Definition: renderer.h:19
void set_renderer(Renderer *renderer)
Set a user space renderer.
Definition: viewer.cpp:139
~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:128
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