8 #include "stb_truetype.h"
9 #include "graphicsbuffer.h"
14 * The "Screen" class handles managing the OS window (using SDL2).
22 // 'Pumps' the system event queue.
23 // Returns 'false' if the program should quit.
26 // Clears the screen to a given colour.
27 void Clear(float r=1.0, float g=1.0, float b=1.0, float a=1.0);
29 // Finishes rendering a frame, and presents it on the screen.
32 // Get the current width/height of the window's viewport.
33 int ViewportWidth() const { return m_viewport_width; }
34 int ViewportHeight() const { return m_viewport_height; }
36 // Debug Font handling
37 void DebugFontInit(const char *font_name, float font_size = 12);
38 void DebugFontClear();
39 void DebugFontPrint(const char *str);
40 void DebugFontPrintF(const char *fmt, ...);
42 // Handle mouse input.
43 typedef std::function<void(int x, int y, int button, int wheel)> MouseHandler;
44 void SetMouseHandler(MouseHandler handler)
46 m_mouse_handler = handler;
57 void SetMouseCursor(MouseCursors cursor);
59 void ScreenShot(const char * filename) const;
60 void RenderBMP(const char * filename) const;
62 void ResizeViewport(int width, int height);
63 void DebugFontFlush();
65 MouseHandler m_mouse_handler;
70 int m_viewport_height;
72 SDL_GLContext m_gl_context;
73 stbtt_bakedchar m_debug_font_rects[96];
74 unsigned int m_debug_font_atlas;
77 float m_debug_font_size;
78 GraphicsBuffer m_debug_font_vertices;
79 GraphicsBuffer m_debug_font_indices;
80 int m_debug_font_vertex_head;
81 int m_debug_font_index_head;