Line data Source code
1 : #pragma once
2 : #include <string>
3 :
4 : struct SDL_Window;
5 : typedef void* SDL_GLContext;
6 : typedef union SDL_Event SDL_Event;
7 :
8 : namespace Amplitron {
9 :
10 : class WindowContext {
11 : public:
12 : WindowContext();
13 : ~WindowContext();
14 :
15 : bool initialize(int width, int height, const std::string& title);
16 : void shutdown();
17 :
18 : // Polls SDL events and passes them to ImGui. Returns false if a quit event is received.
19 : bool poll_events();
20 :
21 : void begin_frame();
22 : void end_frame();
23 :
24 : SDL_Window* get_window() const { return window_; }
25 0 : int get_width() const { return width_; }
26 0 : int get_height() const { return height_; }
27 : float get_dpi_scale() const { return dpi_scale_; }
28 :
29 : private:
30 : void load_fonts();
31 : void load_icon();
32 :
33 : SDL_Window* window_ = nullptr;
34 : SDL_GLContext gl_context_ = nullptr;
35 : int width_ = 1280;
36 : int height_ = 720;
37 : float dpi_scale_ = 1.0f;
38 : bool initialized_ = false;
39 : };
40 :
41 : } // namespace Amplitron
|