-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathcute_app_internal.h
155 lines (139 loc) · 4.01 KB
/
cute_app_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
Cute Framework
Copyright (C) 2024 Randy Gaul https://randygaul.github.io/
This software is dual-licensed with zlib or Unlicense, check LICENSE.txt for more info
*/
#ifndef CF_APP_INTERNAL_H
#define CF_APP_INTERNAL_H
#include <cute_app.h>
#include <cute_audio.h>
#include <cute_array.h>
#include <cute_math.h>
#include <cute_doubly_list.h>
#include <cute_png_cache.h>
#include <cute_graphics.h>
#include <cute_input.h>
#include <cute_string.h>
#include <cute_image.h>
#include <cute_file_system.h>
#include <internal/cute_draw_internal.h>
#include <internal/cute_font_internal.h>
#include <internal/cute_graphics_internal.h>
#include <SDL3/SDL.h>
struct SDL_Window;
struct cs_context_t;
extern struct CF_App* app;
struct CF_MouseState
{
int left_button = 0;
int right_button = 0;
int middle_button = 0;
float wheel_motion = 0;
float x = 0;
float y = 0;
float xrel = 0;
float yrel = 0;
int click_type = 0;
};
struct CF_WindowState
{
bool mouse_inside_window = false;
bool has_keyboard_focus = false;
bool minimized = false;
bool maximized = false;
bool restored = false;
bool resized = false;
bool moved = false;
};
struct CF_ShaderFileInfo
{
CF_Stat stat;
const char* path;
};
struct CF_App
{
// App stuff.
bool running = true;
int options = 0;
void* platform_handle = NULL;
CF_OnUpdateFn* user_on_update = NULL;
SDL_Window* window = NULL;
SDL_GPUDevice* device = NULL;
cs_context_t* cute_sound = NULL;
bool spawned_mix_thread = false;
void (*on_shader_changed_fn)(const char* path, void* udata) = NULL;
void* on_shader_changed_udata = NULL;
bool shader_directory_set = false;
Cute::CF_Path shader_directory;
Cute::Map<const char*, CF_ShaderFileInfo> shader_file_infos;
bool gfx_enabled = false;
float dpi_scale = 1.0f;
float dpi_scale_prev = 1.0f;
bool dpi_scale_was_changed = false;
bool sync_window = false;
int draw_call_count = 0;
int w;
int h;
int x;
int y;
int canvas_w;
int canvas_h;
CF_Color clear_color = cf_color_black();
float clear_depth = 1.0f;
uint32_t clear_stencil = 0;
CF_Canvas offscreen_canvas = { };
CF_Mesh backbuffer_quad = { };
CF_Shader draw_shader = { };
CF_Shader basic_shader = { };
CF_Shader backbuffer_shader = { };
CF_Material backbuffer_material = { };
CF_WindowState window_state;
CF_WindowState window_state_prev;
SDL_GPUCommandBuffer* cmd = NULL;
bool use_depth_stencil = false;
uint64_t default_image_id = CF_PNG_ID_RANGE_LO;
bool vsync = false;
bool audio_needs_updates = false;
void* update_udata = NULL;
bool on_sound_finish_single_threaded = false;
Cute::Array<CF_Sound> on_sound_finish_queue;
void (*on_sound_finish)(CF_Sound, void*) = NULL;
void (*on_music_finish)(void*) = NULL;
bool on_music_finish_signal = false;
void* on_sound_finish_udata = NULL;
void* on_music_finish_udata = NULL;
CF_Mutex on_sound_finish_mutex = cf_make_mutex();
CF_Shader blit_shader = { 0 };
// Input stuff.
Cute::Array<char> ime_composition;
int ime_composition_cursor = 0;
int ime_composition_selection_len = 0;
Cute::Array<int> input_text;
int keys[512] = { 0 };
int keys_prev[512] = { 0 };
double keys_timestamp[512] = { 0 };
void (*key_callback)(CF_KeyButton key, bool true_down_false_up) = NULL;
CF_MouseState mouse, mouse_prev;
Cute::Array<CF_Touch> touches;
// Dear ImGui stuff.
bool using_imgui = false;
SDL_GPUSampler* imgui_sampler = NULL;
int imgui_vertex_count = 0;
int imgui_index_count = 0;
SDL_GPUBuffer* imgui_vbuf = NULL;
SDL_GPUBuffer* imgui_ibuf = NULL;
SDL_GPUTransferBuffer* imgui_vtbuf = NULL;
SDL_GPUTransferBuffer* imgui_itbuf = NULL;
SDL_GPUGraphicsPipeline* imgui_pip = NULL;
SDL_GPUTexture* imgui_font_tex = NULL;
// Font stuff.
uint64_t font_image_id_gen = CF_FONT_ID_RANGE_LO;
Cute::Map<const char*, CF_Font*> fonts;
Cute::Map<uint64_t, CF_Pixel*> font_pixels;
Cute::Map<const char*, CF_TextEffectState> text_effect_states;
Cute::Map<const char*, CF_TextEffectFn*> text_effect_fns;
// Easy sprite stuff.
uint64_t easy_sprite_id_gen = CF_EASY_ID_RANGE_LO;
Cute::Map<uint64_t, CF_Image> easy_sprites;
};
#endif // CF_APP_INTERNAL_H