6 | ImGuiWindowFlags_NoMove
7 | ImGuiWindowFlags_NoSavedSettings;
12 if (
ctx &&
ctx->imgui_context) {
13 igSetCurrentContext(
ctx->imgui_context);
22 igSetCurrentContext(
ctx->previous_imgui_context);
30 return ctx &&
ctx->desktop_scale > 0.0f ?
ctx->desktop_scale : 1.0f;
39 return scaled > 0 ? scaled : 1;
43 if (!
ctx || !
ctx->window ||
ctx->logical_window_width <= 0
44 ||
ctx->logical_window_height <= 0) {
56 if (!
ctx || !
ctx->window) {
66 const bool scale_changed = style_changed
76 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
77 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
78 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
79 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
80 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
88 if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
97 ctx->previous_imgui_context = igGetCurrentContext();
98 ctx->imgui_context = igCreateContext(
NULL);
100 ctx->imgui_context_ready =
true;
102 ImGuiIO *io = igGetIO_Nil();
103 io->IniFilename =
NULL;
104 io->LogFilename =
NULL;
105 io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
107 igStyleColorsDark(
NULL);
109 if (!ImGui_ImplSDL3_InitForOpenGL(
ctx->window,
ctx->gl_context)) {
113 ctx->imgui_sdl_ready =
true;
114 if (!ImGui_ImplOpenGL3_Init(
"#version 130")) {
118 ctx->imgui_gl_ready =
true;
137 ctx->logical_window_width = width;
138 ctx->logical_window_height = height;
142 ctx->window = SDL_CreateWindow(
146 SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN
152 ctx->gl_context = SDL_GL_CreateContext(
ctx->window);
153 if (!
ctx->gl_context || !SDL_GL_MakeCurrent(
ctx->window,
ctx->gl_context)) {
157 SDL_GL_SetSwapInterval(1);
158 if (!gladLoadGL((GLADloadfunc)SDL_GL_GetProcAddress)) {
166 SDL_ShowWindow(
ctx->window);
180 if (
ctx->imgui_gl_ready) {
181 ImGui_ImplOpenGL3_Shutdown();
184 if (
ctx->imgui_sdl_ready) {
185 ImGui_ImplSDL3_Shutdown();
188 if (
ctx->imgui_context_ready) {
189 igDestroyContext(
ctx->imgui_context);
193 if (
ctx->gl_context) {
194 SDL_GL_DestroyContext(
ctx->gl_context);
198 SDL_DestroyWindow(
ctx->window);
209 SDL_QuitSubSystem(SDL_INIT_VIDEO);
216 ImGui_ImplOpenGL3_NewFrame();
217 ImGui_ImplSDL3_NewFrame();
225 SDL_GetWindowSizeInPixels(
ctx->window, &width, &height);
228 glViewport(0, 0, width, height);
229 glClearColor(0.06f, 0.07f, 0.09f, 1.0f);
230 glClear(GL_COLOR_BUFFER_BIT);
231 ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
232 SDL_GL_SwapWindow(
ctx->window);
245 ImGui_ImplSDL3_ProcessEvent(
event);
246 if (
event->type != SDL_EVENT_QUIT) {
257 while (SDL_PollEvent(&
event)) {
259 if (running && !*running) {
269 SDL_GetWindowSize(
ctx->window, &width, &height);
270 igSetNextWindowPos((ImVec2_c){0.0f, 0.0f}, ImGuiCond_Always, (ImVec2_c){0.0f, 0.0f});
271 igSetNextWindowSize((ImVec2_c){(
float)width, (
float)height}, ImGuiCond_Always);
277 ImGuiWindowFlags
flags
280 igPushStyleVar_Vec2(ImGuiStyleVar_WindowPadding, (ImVec2_c){0.0f, 0.0f});
300 igPushStyleVar_Float(
301 ImGuiStyleVar_FrameRounding,
304 const bool clicked = igButton(label,
size);
312 const float window_width = igGetWindowWidth();
313 if (window_width > item_width) {
314 igSetCursorPosX((window_width - item_width) * 0.5f);
319 const ImVec2_c
size = igCalcTextSize(text,
NULL,
false, -1.0f);
321 igTextUnformatted(text,
NULL);
330 const ImGuiStyle *style = igGetStyle();
331 const float title_font_size = (style ? style->FontSizeBase : 0.0f) * 1.35f;
332 igPushFont(
NULL, title_font_size);
349 igTextWrapped(
"%s", message ? message :
"");
360 const int height = (int)(igGetCursorPosY()
362 SDL_SetWindowSize(
ctx->window, scaled_width, height);
DTTR_Graphics_COM_Direct3DDevice7 DWORD block DTTR_Graphics_COM_Direct3DDevice7 DWORD block DTTR_Graphics_COM_Direct3DDevice7 void void void void DWORD f DTTR_Graphics_COM_Direct3DDevice7 DWORD idx float
DTTR_Graphics_COM_Direct3DDevice7 void DWORD flags DWORD void DWORD flags
void void DWORD HANDLE event
DTTR_Graphics_COM_DirectDrawSurface7 DWORD flags void NULL
#define DTTR_IMGUI_COLOR_BUTTON_TEXT
static float DTTR_ImGui_GetCurrentDesktopScale(const DTTR_ImGuiDesktopScaleState *state)
static bool DTTR_ImGui_ScaleChanged(float a, float b)
static bool DTTR_ImGui_ApplyWindowDesktopScale(DTTR_ImGuiDesktopScaleState *state, SDL_Window *window)
#define DTTR_IMGUI_COLOR_BUTTON_BG
#define DTTR_IMGUI_COLOR_BUTTON_BG_HOVERED
#define DTTR_IMGUI_COLOR_BUTTON_BG_ACTIVE
union SDL_Event SDL_Event
static void resize_dialog_window_for_scale(DTTR_ImGuiDialogContext *ctx)
void DTTR_ImGuiDialog_End(DTTR_ImGuiDialogContext *ctx)
void DTTR_ImGuiDialog_DrawHeader(const DTTR_ImGuiDialogContext *ctx, const char *title, const char *version)
void DTTR_ImGuiDialog_CenterNextItem(float item_width)
void DTTR_ImGuiDialog_Render(DTTR_ImGuiDialogContext *ctx)
bool DTTR_ImGuiDialog_RefreshScale(DTTR_ImGuiDialogContext *ctx)
bool DTTR_ImGuiDialog_BeginRoot(DTTR_ImGuiDialogContext *ctx, const char *title, ImGuiWindowFlags flags)
static int scaled_int(const DTTR_ImGuiDialogContext *ctx, float value)
float DTTR_ImGuiDialog_ScaledFloat(const DTTR_ImGuiDialogContext *ctx, float value)
void DTTR_ImGuiDialog_OffsetCursorY(const DTTR_ImGuiDialogContext *ctx, float amount)
void DTTR_ImGuiDialog_DrawPaddedText(const DTTR_ImGuiDialogContext *ctx, const char *message, float padding_x, float padding_y)
static bool sdl_video_ready
static void begin_full_window(const DTTR_ImGuiDialogContext *ctx)
static void draw_centered_text(const char *text)
static void use_dialog_imgui_context(const DTTR_ImGuiDialogContext *ctx)
void DTTR_ImGuiDialog_ProcessEvents(const DTTR_ImGuiDialogContext *ctx, bool *running)
bool DTTR_ImGuiDialog_Button(const DTTR_ImGuiDialogContext *ctx, const char *id, const char *label, ImVec2_c size)
void DTTR_ImGuiDialog_EndRoot()
static bool init_dialog_imgui(DTTR_ImGuiDialogContext *ctx)
void DTTR_ImGuiDialog_NewFrame(const DTTR_ImGuiDialogContext *ctx)
void DTTR_ImGuiDialog_ProcessEvent(const DTTR_ImGuiDialogContext *ctx, const SDL_Event *event, bool *running)
static const ImGuiWindowFlags ROOT_WINDOW_FLAGS
static bool init_sdl_video()
static float context_scale(const DTTR_ImGuiDialogContext *ctx)
static void set_gl_attributes()
void DTTR_ImGuiDialog_FitWindowToContent(DTTR_ImGuiDialogContext *ctx, int width, float padding_y)
void DTTR_ImGuiDialog_Shutdown()
static void restore_previous_imgui_context(const DTTR_ImGuiDialogContext *ctx)
bool DTTR_ImGuiDialog_Begin(DTTR_ImGuiDialogContext *ctx, const char *title, int width, int height)