Skip to content

Commit

Permalink
Correct WinMain issues with SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Nov 29, 2023
1 parent 8b58436 commit aa7d1e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/hello_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ endif()
if (IOS OR (MACOSX AND NOT HELLOIMGUI_MACOS_NO_BUNDLE))
target_compile_definitions(${target_name} PUBLIC HELLOIMGUI_INSIDE_APPLE_BUNDLE)
endif()
if (HELLOIMGUI_WIN32_AUTO_WINMAIN)
target_compile_definitions(${target_name} PUBLIC HELLOIMGUI_WIN32_AUTO_WINMAIN)
endif()

# install
if (PROJECT_IS_TOP_LEVEL AND NOT IOS AND NOT ANDROID)
Expand Down
9 changes: 8 additions & 1 deletion src/hello_imgui/hello_imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
#include <cstdint>

#ifdef HELLOIMGUI_USE_SDL_OPENGL3
#include <SDL.h> // So that SDL can surreptitiously define its own main...
// Let SDL redefine main under iOS and co., but not under Windows, where we redefine WinMain
#ifdef _WIN32
#ifndef HELLOIMGUI_WIN32_AUTO_WINMAIN
#include <SDL.h>
#endif
#else
#include <SDL.h>
#endif
#endif

struct ImGuiTestEngine;
Expand Down

0 comments on commit aa7d1e0

Please sign in to comment.