diff --git a/.gitmodules b/.gitmodules index d401869..8566f79 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "3rd_Party/rem"] path = 3rd_Party/rem url = https://github.com/pound-emu/rem.git +[submodule "3rd_Party/SDL3"] + path = 3rd_Party/SDL3 + url = https://github.com/libsdl-org/SDL.git diff --git a/3rd_Party/CMakeLists.txt b/3rd_Party/CMakeLists.txt index a8e6a7e..095f18b 100644 --- a/3rd_Party/CMakeLists.txt +++ b/3rd_Party/CMakeLists.txt @@ -17,6 +17,14 @@ if (NOT TARGET rem) add_subdirectory(rem) endif() +# SDL3 +if (NOT TARGET SDL3::SDL3) + set(SDL_DISKAUDIO OFF) + set(SDL_TEST_LIBRARY OFF) + set(SDL_PIPEWIRE OFF) + add_subdirectory(SDL3) +endif() + # Toml11 if (NOT TARGET toml11::toml11) add_subdirectory(toml11) diff --git a/3rd_Party/SDL3 b/3rd_Party/SDL3 new file mode 160000 index 0000000..c9a6709 --- /dev/null +++ b/3rd_Party/SDL3 @@ -0,0 +1 @@ +Subproject commit c9a6709bd21750f1ad9597be21abace78c6378c9 diff --git a/CMakeLists.txt b/CMakeLists.txt index df0c678..44b5c25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ endif() project(Pound) find_package(fmt 10.2.1 CONFIG) +find_package(SDL3 3.2.10 CONFIG) find_package(toml11 4.4.0 CONFIG) include_directories(core) @@ -36,7 +37,7 @@ add_executable(Pound target_precompile_headers(Pound PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/core/Base/Types.h) # Link libraries -target_link_libraries(Pound PRIVATE fmt::fmt rem toml11::toml11) +target_link_libraries(Pound PRIVATE fmt::fmt rem SDL3::SDL3 toml11::toml11) if (WIN32) add_compile_definitions(NOMINMAX WIN32_LEAN_AND_MEAN) diff --git a/core/main.cpp b/core/main.cpp index 4d6f8b1..b13bbd8 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -2,9 +2,36 @@ #include "Base/Logging/Backend.h" +#include + #include "ARM/cpu.h" #include "JIT/jit.h" +SDL_Window *Window{}; +SDL_Event windowEvent; + +void initSDL3() { + + if (!SDL_Init(SDL_INIT_VIDEO)) { + LOG_ERROR(Render, "Error while creating SDL3 Context!"); + } + + SDL_PropertiesID props = SDL_CreateProperties(); + SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, "Pound Emulator"); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_CENTERED); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, SDL_WINDOWPOS_CENTERED); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, /*Config::windowWidth()*/ 800); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, /*Config::windowHeight()*/ 600); + // For a new Vulkan support, don't forget to change 'SDL_WINDOW_OPENGL' by 'SDL_WINDOW_VULKAN'. + SDL_SetNumberProperty(props, "flags", SDL_WINDOW_OPENGL); + SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, true); + SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true); + Window = SDL_CreateWindowWithProperties(props); + SDL_DestroyProperties(props); + + SDL_SetWindowMinimumSize(Window, 640, 480); +} + int main() { Base::Log::Initialize(); @@ -13,6 +40,8 @@ int main() { const auto config_dir = Base::FS::GetUserPath(Base::FS::PathType::BinaryDir); Config::Load(config_dir / "config.toml"); + initSDL3(); + CPU cpu; cpu.pc = 0; @@ -31,5 +60,22 @@ int main() { LOG_INFO(ARM, "X0 = {}", cpu.x(0)); + bool rendering = true; + + while (rendering) { + // Process events. + while (SDL_PollEvent(&windowEvent)) { + switch (windowEvent.type) { + case SDL_EVENT_QUIT: + SDL_DestroyWindow(Window); + SDL_Quit(); + rendering = false; + break; + default: + break; + } + } + } + return 0; }