Skip to content

Commit

Permalink
Fix ImGui conditional compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
N7Alpha committed Aug 24, 2024
1 parent ac6f3f1 commit ba0b696
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions Source/UnrealLibretro/Private/LibretroContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ extern "C"
extern void LibretroSam2LogWrite(int level, const char* file, int line, const char* fmt, ...);
}

#include "UnrealLibretro.h" // For Libretro debug log category
#define ULNET_IMPLEMENTATION
#if UNREALLIBRETRO_NETIMGUI
#define ULNET_IMGUI
#endif
#define SAM2_IMPLEMENTATION

#define SAM2_LOG_WRITE(level, file, line, ...) LibretroSam2LogWrite(level, file, line, "Netplay: " __VA_ARGS__)
Expand All @@ -15,7 +18,6 @@ THIRD_PARTY_INCLUDES_START
#include "ulnet.h"
THIRD_PARTY_INCLUDES_END

#include "UnrealLibretro.h" // For Libretro debug log category
#if UNREALLIBRETRO_NETIMGUI
#include "NetImgui_Api.h"
#endif
Expand Down Expand Up @@ -1068,7 +1070,7 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn
AbsoluteCoreDirectory.Len());
};

#ifdef UNREALLIBRETRO_NETIMGUI
#if UNREALLIBRETRO_NETIMGUI
static ImFontAtlas* GlobalFontAtlas = nullptr;
if (GlobalFontAtlas == nullptr) {
GlobalFontAtlas = new ImFontAtlas();
Expand All @@ -1079,7 +1081,9 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn
#endif

l->netplay_session = (ulnet_session_t *) calloc(1, sizeof(ulnet_session_t));
#if UNREALLIBRETRO_NETIMGUI
l->netplay_session->sample_size = ULNET_MAX_SAMPLE_SIZE;
#endif
l->netplay_session->delay_frames = 2; // @todo Make configurable

auto LibretroSettings = GetDefault<ULibretroSettings>();
Expand Down Expand Up @@ -1112,9 +1116,6 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn
#endif
);

uint64 frames = 0;
auto start = FDateTime::Now();

verify(IPlatformFile::GetPlatformPhysical().CopyFile(*InstancedCorePath, *core));

l->core.hw.version_major = 4;
Expand Down Expand Up @@ -1301,9 +1302,9 @@ FLibretroContext* FLibretroContext::Launch(ULibretroCoreInstance* LibretroCoreIn
// These ImGui routines all cleanup thread_local objects if they aren't NULL
#if UNREALLIBRETRO_NETIMGUI
NetImgui::Shutdown();
#endif
ImPlot::DestroyContext();
ImGui::DestroyContext();
#endif

if (l->CoreState.load(std::memory_order_relaxed) == ECoreState::StartFailed)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/UnrealLibretro/Public/UnrealLibretro.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern char UnrealLibretroVersionAnsi[];
#define UNREALLIBRETRO_NETIMGUI 1
#elif PLATFORM_MAC
#define UNREALLIBRETRO_NETIMGUI 1
#elif
#else
#define UNREALLIBRETRO_NETIMGUI 0
#endif

Expand Down

0 comments on commit ba0b696

Please sign in to comment.