X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fscreen.h;h=aed042d51ae345b6b0cdd05d8e65c7cccdcb2e8a;hp=f2a98c2abff72c37b4d38a7c85f83cff83addb67;hb=398e6b2732decd57cdb57deb3f91d3ff08669e8b;hpb=f8ef964f021d1d6da6ea46bbb1fe8f0250a5be8c diff --git a/src/screen.h b/src/screen.h index f2a98c2..aed042d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,7 +1,7 @@ #ifndef _SCREEN_H #define _SCREEN_H -#include +#include "SDL.h" #include @@ -11,6 +11,7 @@ namespace IPDF { + class View; /* * The "Screen" class handles managing the OS window (using SDL2). */ @@ -41,7 +42,7 @@ namespace IPDF void DebugFontPrintF(const char *fmt, ...); // Handle mouse input. - typedef std::function MouseHandler; + typedef void(*MouseHandler)(int x, int y, int button, int wheel, Screen * scr, View * view); void SetMouseHandler(MouseHandler handler) { m_mouse_handler = handler; @@ -59,12 +60,21 @@ namespace IPDF void ScreenShot(const char * filename) const; void RenderBMP(const char * filename) const; - void RenderPixels(int x, int y, int w, int h, void * pixels) const; + void RenderPixels(int x, int y, int w, int h, uint8_t * pixels) const; + + + void SetView(View * new_view) {m_view = new_view;} // Returns the CPU time (in seconds) it took to render the last completed frame. double GetLastFrameTimeCPU() const { return m_last_frame_time / SDL_GetPerformanceFrequency(); } // Returns the GPU time (in seconds) it took to render the last completed frame. double GetLastFrameTimeGPU() const; + + void RequestQuit() {m_no_quit_requested = false;} + bool QuitRequested() const {return !m_no_quit_requested;} + + void ShowDebugFont(bool show = true) {m_show_debug_font = show;} + bool DebugFontShown() const {return m_show_debug_font;} private: void ResizeViewport(int width, int height); void DebugFontFlush(); @@ -83,6 +93,7 @@ namespace IPDF SDL_Window *m_window; SDL_GLContext m_gl_context; ShaderProgram m_texture_prog; + ShaderProgram m_font_prog; GLint m_colour_uniform_location; GraphicsBuffer m_viewport_ubo; stbtt_bakedchar m_debug_font_rects[96]; @@ -94,6 +105,9 @@ namespace IPDF GraphicsBuffer m_debug_font_indices; int m_debug_font_vertex_head; int m_debug_font_index_head; + View * m_view; + bool m_no_quit_requested; + bool m_show_debug_font; }; }