X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fscreen.h;h=d918dd1afc2a9fd0b604b46468939d1e4c247c7f;hp=e6418265b522bdf2a8dcdb51cf529c52158d4bab;hb=a851cf197844a2eb15fd5ee2c350ee296e415dca;hpb=07db15ca49833542130f7c29c6a6dc7560fab59d diff --git a/src/screen.h b/src/screen.h index e641826..d918dd1 100644 --- a/src/screen.h +++ b/src/screen.h @@ -5,6 +5,10 @@ #include +#include "stb_truetype.h" +#include "graphicsbuffer.h" +#include "shaderprogram.h" + namespace IPDF { /* @@ -20,6 +24,9 @@ namespace IPDF // Returns 'false' if the program should quit. bool PumpEvents(); + // Clears the screen to a given colour. + void Clear(float r=1.0, float g=1.0, float b=1.0, float a=1.0); + // Finishes rendering a frame, and presents it on the screen. void Present(); @@ -27,6 +34,12 @@ namespace IPDF int ViewportWidth() const { return m_viewport_width; } int ViewportHeight() const { return m_viewport_height; } + // Debug Font handling + void DebugFontInit(const char *font_name, float font_size = 12); + void DebugFontClear(); + void DebugFontPrint(const char *str); + void DebugFontPrintF(const char *fmt, ...); + // Handle mouse input. typedef std::function MouseHandler; void SetMouseHandler(MouseHandler handler) @@ -48,6 +61,7 @@ namespace IPDF void RenderBMP(const char * filename) const; private: void ResizeViewport(int width, int height); + void DebugFontFlush(); MouseHandler m_mouse_handler; int m_last_mouse_x; @@ -57,6 +71,18 @@ namespace IPDF int m_viewport_height; SDL_Window *m_window; SDL_GLContext m_gl_context; + ShaderProgram m_texture_prog; + GLint m_colour_uniform_location; + GraphicsBuffer m_viewport_ubo; + stbtt_bakedchar m_debug_font_rects[96]; + unsigned int m_debug_font_atlas; + float m_debug_font_x; + float m_debug_font_y; + float m_debug_font_size; + GraphicsBuffer m_debug_font_vertices; + GraphicsBuffer m_debug_font_indices; + int m_debug_font_vertex_head; + int m_debug_font_index_head; }; }