Skip to content

Commit 2cd8e53

Browse files
author
Tom Seddon
committed
Merge branch 'master' into wip/master
2 parents 25d2579 + e1c9b84 commit 2cd8e53

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/b2/BeebWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3599,7 +3599,7 @@ bool BeebWindow::InitInternal() {
35993599
#else
36003600
bool imgui_enable_test_engine = false;
36013601
#endif
3602-
m_imgui_stuff = new ImGuiStuff(m_renderer, imgui_enable_test_engine, display_size_x, display_size_y);
3602+
m_imgui_stuff = new ImGuiStuff(m_window, m_renderer, imgui_enable_test_engine, display_size_x, display_size_y);
36033603
if (!m_imgui_stuff->Init(ImGuiConfigFlags_DockingEnable)) {
36043604
m_msg.e.f("failed to initialise ImGui\n");
36053605
return false;

src/b2/b2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,9 @@ static bool InitSystem(
10621062

10631063
if (IsHighDPIEnabled(options, app_handler)) {
10641064
#if SYSTEM_WINDOWS
1065+
#ifdef SDL_HINT_WINDOWS_DPI_AWARENESS
10651066
SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2");
1067+
#endif
10661068
#endif
10671069
}
10681070

src/b2/dear_imgui.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ ImGuiContextSetter::~ImGuiContextSetter() {
100100
//////////////////////////////////////////////////////////////////////////
101101
//////////////////////////////////////////////////////////////////////////
102102

103-
ImGuiStuff::ImGuiStuff(SDL_Renderer *renderer, bool enable_test_engine, float default_display_size_x, float default_display_size_y)
104-
: m_renderer(renderer)
103+
ImGuiStuff::ImGuiStuff(SDL_Window *window, SDL_Renderer *renderer, bool enable_test_engine, float default_display_size_x, float default_display_size_y)
104+
: m_window(window)
105+
, m_renderer(renderer)
105106
, m_default_display_size_x(default_display_size_x)
106107
, m_default_display_size_y(default_display_size_y) {
107108
m_last_new_frame_ticks = GetCurrentTickCount();
@@ -296,21 +297,18 @@ bool ImGuiStuff::Init(ImGuiConfigFlags extra_config_flags) {
296297

297298
// See ImGui_ImplSDL2_Init.
298299

299-
SDL_Window *window;
300300
uint32_t window_flags;
301-
if (m_renderer) {
302-
window = SDL_RenderGetWindow(m_renderer);
303-
window_flags = SDL_GetWindowFlags(window);
301+
if (m_window) {
302+
window_flags = SDL_GetWindowFlags(m_window);
304303
} else {
305-
window = nullptr;
306304
window_flags = 0;
307305
}
308306

309307
if (window_flags & SDL_WINDOW_ALLOW_HIGHDPI) {
310308
#if SYSTEM_WINDOWS
311309
SDL_SysWMinfo wm_info;
312310
SDL_VERSION(&wm_info.version);
313-
SDL_GetWindowWMInfo(window, &wm_info);
311+
SDL_GetWindowWMInfo(m_window, &wm_info);
314312

315313
ImGuiViewport *main_vp = ImGui::GetMainViewport();
316314
main_vp->PlatformHandleRaw = wm_info.info.win.window;
@@ -328,7 +326,7 @@ bool ImGuiStuff::Init(ImGuiConfigFlags extra_config_flags) {
328326
#elif SYSTEM_OSX
329327

330328
ImGuiViewport *main_vp = ImGui::GetMainViewport();
331-
main_vp->PlatformHandle = window;
329+
main_vp->PlatformHandle = m_window;
332330

333331
platform_io.Platform_GetWindowDpiScale = &HandleGetWindowDpiScaleOSX;
334332

@@ -338,7 +336,7 @@ bool ImGuiStuff::Init(ImGuiConfigFlags extra_config_flags) {
338336

339337
// The correct initial scale factor does still need to be set.
340338
ImGuiStyle &style = ImGui::GetStyle();
341-
style.FontScaleDpi = GetDpiScale(window);
339+
style.FontScaleDpi = GetDpiScale(m_window);
342340

343341
#elif SYSTEM_LINUX
344342

@@ -496,10 +494,8 @@ void ImGuiStuff::NewFrame() {
496494
}
497495

498496
if (m_renderer) {
499-
SDL_Window *window = SDL_RenderGetWindow(m_renderer);
500-
501497
int window_width, window_height;
502-
SDL_GetWindowSize(window, &window_width, &window_height);
498+
SDL_GetWindowSize(m_window, &window_width, &window_height);
503499

504500
int output_width, output_height;
505501
SDL_GetRendererOutputSize(m_renderer, &output_width, &output_height);

src/b2/dear_imgui.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
struct SDL_Texture;
5454
struct SDL_Renderer;
55+
struct SDL_Window;
5556
struct SDL_Cursor;
5657
class Messages;
5758
class RecentPaths;
@@ -76,7 +77,7 @@ extern const ImGuiStyle IMGUI_DEFAULT_STYLE;
7677
class ImGuiStuff {
7778
public:
7879
// Default display size is used if the renderer is NULL.
79-
explicit ImGuiStuff(SDL_Renderer *renderer, bool enable_test_engine, float default_display_size_x, float default_display_size_y);
80+
explicit ImGuiStuff(SDL_Window *window, SDL_Renderer *renderer, bool enable_test_engine, float default_display_size_x, float default_display_size_y);
8081
~ImGuiStuff();
8182

8283
ImGuiStuff(const ImGuiStuff &) = delete;
@@ -135,6 +136,7 @@ class ImGuiStuff {
135136
ConsumePressedKeycodeState_Consumed,
136137
};
137138

139+
SDL_Window *m_window = nullptr;
138140
SDL_Renderer *m_renderer = nullptr;
139141
ImGuiContext *m_context = nullptr;
140142

0 commit comments

Comments
 (0)