50 typedef struct AscContext { |
50 typedef struct AscContext { |
51 unsigned int flags; |
51 unsigned int flags; |
52 CxBuffer error_buffer; |
52 CxBuffer error_buffer; |
53 AscInput input; |
53 AscInput input; |
54 AscWindow windows[ASC_MAX_WINDOWS]; |
54 AscWindow windows[ASC_MAX_WINDOWS]; |
55 // TODO: rework how fonts are cached |
55 AscFont active_font; |
56 AscFont fonts[ASC_MAX_FONTS]; |
|
57 unsigned char fonts_loaded; |
56 unsigned char fonts_loaded; |
58 unsigned char active_window; |
57 unsigned char active_window; |
59 unsigned char active_font; |
|
60 asc_col4i ink; |
58 asc_col4i ink; |
61 uint64_t frame_nanos; |
59 uint64_t frame_nanos; |
62 uint64_t total_nanos; |
60 uint64_t total_nanos; |
63 } AscContext; |
61 } AscContext; |
64 |
62 |
67 |
65 |
68 /** |
66 /** |
69 * The currently active font. |
67 * The currently active font. |
70 * @see asc_font() |
68 * @see asc_font() |
71 */ |
69 */ |
72 #define asc_active_font \ |
70 #define asc_active_font asc_context.active_font |
73 (&asc_context.fonts[asc_context.active_font]) |
|
74 |
71 |
|
72 #ifdef NDEBUG |
75 /** |
73 /** |
76 * The currently active window in the context. |
74 * The currently active window in the context. |
77 * @see asc_window_activate() |
75 * @see asc_window_activate() |
78 */ |
76 */ |
79 #define asc_active_window \ |
77 #define asc_active_window \ |
80 (&asc_context.windows[asc_context.active_window]) |
78 (&asc_context.windows[asc_context.active_window]) |
81 |
79 #else |
82 static inline bool asc_assert_active_window() { |
80 /** |
83 if (asc_context.active_window < ASC_MAX_WINDOWS) { |
81 * The currently active window in the context. |
84 return true; |
82 * @see asc_window_activate() |
85 } else { |
83 */ |
86 asc_error("A graphics operation was performed without active window"); |
84 #define asc_active_window asc_active_window_assert() |
87 return false; |
85 AscWindow *asc_active_window_assert(void); |
88 } |
86 #endif // NDEBUG |
89 } |
|
90 |
87 |
91 void asc_context_initialize(void); |
88 void asc_context_initialize(void); |
92 void asc_context_destroy(void); |
89 void asc_context_destroy(void); |
93 |
90 |
94 /** |
91 /** |