mirror of https://github.com/yaz0r/FITD.git
Migrate to SDL3. Update imgui. Fork soloud for support of SDL3 static
This commit is contained in:
parent
5b9cee04b6
commit
b305a4a44c
|
@ -6,7 +6,7 @@
|
|||
url = https://github.com/ocornut/imgui.git
|
||||
[submodule "ThirdParty/soloud"]
|
||||
path = ThirdParty/soloud.cmake/soloud
|
||||
url = https://github.com/jarikomppa/soloud.git
|
||||
url = https://github.com/yaz0r/soloud.git
|
||||
[submodule "ThirdParty/bgfx.cmake"]
|
||||
path = ThirdParty/bgfx.cmake
|
||||
url = https://github.com/bkaradzic/bgfx.cmake.git
|
||||
|
|
|
@ -10,7 +10,7 @@ add_subdirectory( ${THIRD_PARTY}/bgfx.cmake )
|
|||
add_subdirectory( ${THIRD_PARTY}/soloud.cmake )
|
||||
|
||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(LIBC ON CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
add_subdirectory( ${THIRD_PARTY}/SDL )
|
||||
|
||||
set(SKIP_INSTALL_ALL on)
|
||||
|
|
|
@ -36,7 +36,7 @@ set( CMAKE_EXE_LINKER_FLAGS_SHIPPING "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /
|
|||
|
||||
add_executable (Fitd ${SOURCES})
|
||||
|
||||
TARGET_LINK_LIBRARIES(Fitd SDL2main SDL2-static soloud FitdLib bgfx zlibstatic ${EXTRA_LIBS})
|
||||
TARGET_LINK_LIBRARIES(Fitd SDL3-static soloud FitdLib bgfx zlibstatic ${EXTRA_LIBS})
|
||||
|
||||
set_target_properties(Fitd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/data/AITD1_CD")
|
||||
set_target_properties(Fitd PROPERTIES WIN32_EXECUTABLE FALSE)
|
||||
|
|
|
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.9)
|
|||
|
||||
include_directories(
|
||||
"."
|
||||
"${THIRD_PARTY}/SDL/include/SDL3"
|
||||
"${THIRD_PARTY}/SDL/include"
|
||||
"${THIRD_PARTY}/imgui"
|
||||
"${THIRD_PARTY}/soloud.cmake/soloud/include"
|
||||
|
@ -32,7 +33,7 @@ set(SOURCES
|
|||
"${THIRD_PARTY}/imgui/imgui_draw.cpp"
|
||||
"${THIRD_PARTY}/imgui/imgui_tables.cpp"
|
||||
"${THIRD_PARTY}/imgui/imgui_widgets.cpp"
|
||||
"${THIRD_PARTY}/imgui/backends/imgui_impl_sdl.cpp"
|
||||
"${THIRD_PARTY}/imgui/backends/imgui_impl_sdl3.cpp"
|
||||
)
|
||||
|
||||
function(assign_source_group)
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
#include <SDL.h>
|
||||
#include <SDL_syswm.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/platform.h>
|
||||
#include <backends/imgui_impl_sdl.h>
|
||||
#include <backends/imgui_impl_sdl3.h>
|
||||
#include "imguiBGFX.h"
|
||||
#include "SDL3/SDL.h"
|
||||
|
||||
#if BX_PLATFORM_OSX
|
||||
extern "C" {
|
||||
void* cbSetupMetalLayer(void*);
|
||||
}
|
||||
#elif BX_PLATFORM_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -61,7 +63,7 @@ void StartFrame()
|
|||
}
|
||||
|
||||
// Pull the input from SDL2 instead
|
||||
ImGui_ImplSDL2_NewFrame(gWindowBGFX);
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
imguiBeginFrame(0, 0, 0, 0, outputResolution[0], outputResolution[1], -1);
|
||||
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
|
@ -83,7 +85,7 @@ void StartFrame()
|
|||
extern bool debuggerVar_debugMenuDisplayed;
|
||||
void EndFrame()
|
||||
{
|
||||
if (ImGui::GetIO().KeysDown[SDL_SCANCODE_GRAVE] && (ImGui::GetIO().KeysDownDuration[SDL_SCANCODE_GRAVE] == 0.f))
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_GraveAccent, false))
|
||||
{
|
||||
debuggerVar_debugMenuDisplayed = !debuggerVar_debugMenuDisplayed;
|
||||
}
|
||||
|
@ -95,7 +97,7 @@ void EndFrame()
|
|||
else
|
||||
{
|
||||
ImGui::Render();
|
||||
}
|
||||
}
|
||||
bgfx::frame();
|
||||
|
||||
{
|
||||
|
@ -119,31 +121,31 @@ bgfx::Init initparam;
|
|||
|
||||
void createBgfxInitParams()
|
||||
{
|
||||
SDL_SysWMinfo wmi;
|
||||
SDL_VERSION(&wmi.version);
|
||||
if (!SDL_GetWindowWMInfo(gWindowBGFX, &wmi)) {
|
||||
return;
|
||||
#if BX_PLATFORM_LINUX
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
|
||||
{
|
||||
initparam.platformData.ndt = (Display*)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, NULL);
|
||||
initparam.platformData.nwh = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
|
||||
}
|
||||
else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0)
|
||||
{
|
||||
/*struct wl_display *display*/ initparam.platformData.ndt = (struct wl_display*)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, NULL);
|
||||
/*struct wl_surface *surface*/ initparam.platformData.nwh = (struct wl_surface*)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, NULL);
|
||||
}
|
||||
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
|
||||
initparam.platformData.ndt = wmi.info.x11.display;
|
||||
initparam.platformData.nwh = (void*)(uintptr_t)wmi.info.x11.window;
|
||||
#elif BX_PLATFORM_OSX
|
||||
initparam.platformData.ndt = NULL;
|
||||
initparam.platformData.nwh = cbSetupMetalLayer(wmi.info.cocoa.window);
|
||||
#elif BX_PLATFORM_WINDOWS
|
||||
initparam.platformData.ndt = NULL;
|
||||
initparam.platformData.nwh = wmi.info.win.window;
|
||||
#elif BX_PLATFORM_STEAMLINK
|
||||
initparam.platformData.ndt = wmi.info.vivante.display;
|
||||
initparam.platformData.nwh = wmi.info.vivante.window;
|
||||
initparam.platformData.nwh = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(gWindowBGFX), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
#endif // BX_PLATFORM_
|
||||
}
|
||||
|
||||
int initBgfxGlue(int argc, char* argv[])
|
||||
{
|
||||
createBgfxInitParams();
|
||||
//initparam.type = bgfx::RendererType::OpenGL;
|
||||
//initparam.type = bgfx::RendererType::Vulkan;
|
||||
initparam.type = bgfx::RendererType::Vulkan;
|
||||
bgfx::init(initparam);
|
||||
|
||||
imguiCreate();
|
||||
|
@ -152,11 +154,11 @@ int initBgfxGlue(int argc, char* argv[])
|
|||
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
ImGui_ImplSDL2_InitForD3D(gWindowBGFX);
|
||||
ImGui_ImplSDL3_InitForD3D(gWindowBGFX);
|
||||
#elif BX_PLATFORM_OSX
|
||||
ImGui_ImplSDL2_InitForMetal(gWindowBGFX);
|
||||
ImGui_ImplSDL3_InitForMetal(gWindowBGFX);
|
||||
#else
|
||||
ImGui_ImplSDL2_InitForVulkan(gWindowBGFX);
|
||||
ImGui_ImplSDL3_InitForVulkan(gWindowBGFX);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
void createBgfxInitParams();
|
||||
int initBgfxGlue(int argc, char* argv[]);
|
||||
void deleteBgfxGlue();
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#endif
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bgfx/embedded_shader.h>
|
||||
#include <bx/allocator.h>
|
||||
|
@ -18,9 +22,7 @@
|
|||
|
||||
//#include "ImGuizmo.h"
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#endif
|
||||
|
||||
#include <imgui_internal.h>
|
||||
#include <../3rdparty/dear-imgui/widgets/dock.inl>
|
||||
//#include <../3rdparty/dear-imgui/widgets/gizmo.inl>
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace ImGui
|
|||
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
)
|
||||
{
|
||||
return ImageButton(toId(_handle, _flags, _mip), _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
||||
return ImageButton("image", toId(_handle, _flags, _mip), _size, _uv0, _uv1, _bgCol, _tintCol);
|
||||
}
|
||||
|
||||
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "common.h"
|
||||
#include <SDL.h>
|
||||
#include <backends/imgui_impl_sdl3.h>
|
||||
|
||||
extern float nearVal;
|
||||
extern float farVal;
|
||||
|
@ -10,7 +11,7 @@ extern bool debuggerVar_debugMenuDisplayed;
|
|||
|
||||
void handleKeyDown(SDL_Event& event)
|
||||
{
|
||||
switch (event.key.keysym.scancode)
|
||||
switch (event.key.key)
|
||||
{
|
||||
case SDL_SCANCODE_GRAVE:
|
||||
debuggerVar_debugMenuDisplayed ^= 1;
|
||||
|
@ -23,7 +24,7 @@ void readKeyboard(void)
|
|||
SDL_Event event;
|
||||
int size;
|
||||
int j;
|
||||
const unsigned char *keyboard;
|
||||
const bool *keyboard;
|
||||
|
||||
JoyD = 0;
|
||||
Click = 0;
|
||||
|
@ -31,11 +32,13 @@ void readKeyboard(void)
|
|||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
|
||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||
|
||||
switch (event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
handleKeyDown(event);
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
case SDL_EVENT_QUIT:
|
||||
cleanupAndExit();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@ email : yaz0r@yaz0r.net
|
|||
#include "bgfxGlue.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_thread.h>
|
||||
#include <SDL_mutex.h>
|
||||
#include "osystem.h"
|
||||
#include "osystemAL.h"
|
||||
#include <backends/imgui_impl_sdl.h>
|
||||
#include <backends/imgui_impl_sdl3.h>
|
||||
|
||||
void detectGame(void);
|
||||
void renderGameWindow();
|
||||
|
@ -75,8 +76,8 @@ extern "C" {
|
|||
int FitdMain(void* unkused);
|
||||
}
|
||||
|
||||
SDL_semaphore* startOfRender = NULL;
|
||||
SDL_semaphore* endOfRender = NULL;
|
||||
SDL_Semaphore* startOfRender = NULL;
|
||||
SDL_Semaphore* endOfRender = NULL;
|
||||
|
||||
//SDL_sem* emptyCount = NULL;
|
||||
//SDL_sem* fullCount = NULL;
|
||||
|
@ -93,14 +94,9 @@ int FitdInit(int argc, char* argv[])
|
|||
|
||||
osystem_init();
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) != 0)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
unsigned int flags = 0;
|
||||
flags |= SDL_WINDOW_RESIZABLE;
|
||||
flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
//flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
flags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
@ -111,7 +107,7 @@ int FitdInit(int argc, char* argv[])
|
|||
int scale = 4;
|
||||
int resolution[2] = { 320 * scale, 240 * scale };
|
||||
|
||||
gWindowBGFX = SDL_CreateWindow("FITD", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, resolution[0], resolution[1], flags);
|
||||
gWindowBGFX = SDL_CreateWindow("FITD", resolution[0], resolution[1], flags);
|
||||
|
||||
char version[256];
|
||||
|
||||
|
@ -120,9 +116,7 @@ int FitdInit(int argc, char* argv[])
|
|||
printf(version);
|
||||
|
||||
detectGame();
|
||||
|
||||
createBgfxInitParams();
|
||||
|
||||
|
||||
SDL_CreateThread(FitdMain, "FitdMainThread", NULL);
|
||||
|
||||
unsigned long int t_start = SDL_GetTicks();
|
||||
|
@ -159,8 +153,6 @@ int FitdInit(int argc, char* argv[])
|
|||
t_lastUpdate = t_sinceStart;
|
||||
}
|
||||
|
||||
readKeyboard();
|
||||
|
||||
osystemAL_udpate();
|
||||
|
||||
SDL_PumpEvents();
|
||||
|
@ -170,28 +162,15 @@ int FitdInit(int argc, char* argv[])
|
|||
// Don't process events on first frame to avoid race condition with the init code
|
||||
if(!bFirstFrame)
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
gCloseApp = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
readKeyboard();
|
||||
}
|
||||
else {
|
||||
bFirstFrame = false;
|
||||
}
|
||||
|
||||
SDL_SemPost(startOfRender);
|
||||
SDL_SignalSemaphore(startOfRender);
|
||||
|
||||
SDL_SemWait(endOfRender);
|
||||
SDL_WaitSemaphore(endOfRender);
|
||||
|
||||
//SDL_RenderPresent(SDL_GetRenderer(gWindowBGFX));
|
||||
}
|
||||
|
@ -205,7 +184,7 @@ u32 lastFrameTime = 0;
|
|||
|
||||
u32 osystem_startOfFrame()
|
||||
{
|
||||
SDL_SemWait(startOfRender);
|
||||
SDL_WaitSemaphore(startOfRender);
|
||||
|
||||
StartFrame();
|
||||
osystem_startFrame();
|
||||
|
@ -257,7 +236,7 @@ void osystem_endOfFrame()
|
|||
if (bFirst)
|
||||
bFirst = false;
|
||||
|
||||
SDL_SemPost(endOfRender);
|
||||
SDL_SignalSemaphore(endOfRender);
|
||||
//SDL_SemPost(emptyCount);
|
||||
|
||||
}
|
||||
|
@ -279,10 +258,7 @@ int fileExists(const char* name)
|
|||
void osystem_init() // that's the constructor of the system dependent
|
||||
// object used for the SDL port
|
||||
{
|
||||
const unsigned char *keyboard;
|
||||
int size;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
assert(0);
|
||||
|
@ -294,10 +270,6 @@ void osystem_init() // that's the constructor of the system dependent
|
|||
|
||||
SDL_PumpEvents();
|
||||
|
||||
keyboard = SDL_GetKeyboardState(&size);
|
||||
|
||||
//keyboard[SDLK_RETURN] = 0;
|
||||
|
||||
int screen_width = 800;
|
||||
int screen_height = 600;
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4f7f72c257165ecd30654f80d8b45fcc02d608da
|
||||
Subproject commit 877399b2b2cf21e67554ed9046410f268ce1d1b2
|
|
@ -1 +1 @@
|
|||
Subproject commit 14466a6d19ca97f4dcf07688ebe4411aeb51958a
|
||||
Subproject commit f5befd2d29e66809cd1110a152e375a7f1981f06
|
|
@ -15,11 +15,11 @@ file(GLOB_RECURSE SOLOUD_HEADERS ${soloud_SOURCE_DIR}/soloud/include/*.h)
|
|||
file(GLOB_RECURSE SOLOUD_SOURCES
|
||||
${soloud_SOURCE_DIR}/soloud/src/core/*.cpp
|
||||
${soloud_SOURCE_DIR}/soloud/src/audiosource/wav/*.c*
|
||||
${soloud_SOURCE_DIR}/soloud/src/backend/sdl2_static/*.cpp
|
||||
${soloud_SOURCE_DIR}/soloud/src/backend/sdl3_static/*.cpp
|
||||
${soloud_SOURCE_DIR}/soloud/src/backend/null/*.cpp
|
||||
)
|
||||
|
||||
include_directories(${soloud_SOURCE_DIR}/soloud/include "${THIRD_PARTY}/SDL/include")
|
||||
include_directories(${soloud_SOURCE_DIR}/soloud/include "${THIRD_PARTY}/SDL/include" "${THIRD_PARTY}/SDL/include/SDL3")
|
||||
|
||||
set(SOLOUD_SOURCES
|
||||
${SOLOUD_HEADERS}
|
||||
|
@ -32,5 +32,5 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
|||
IF(${CMAKE_SYSTEM_NAME} STREQUAL watchOS)
|
||||
target_compile_definitions(${SOLOUD_LIB_NAME} PRIVATE WITH_NULL=1)
|
||||
ELSE()
|
||||
target_compile_definitions(${SOLOUD_LIB_NAME} PRIVATE WITH_SDL2_STATIC=1)
|
||||
target_compile_definitions(${SOLOUD_LIB_NAME} PRIVATE WITH_SDL3_STATIC=1)
|
||||
ENDIF()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b3468d366ed9342cfa731475d267d1e2e7a3e81e
|
||||
Subproject commit 467259ef305251b43b26ad91229189f659240c91
|
Loading…
Reference in New Issue