From 864048a7334f1c3a37d41d33db63b80a7f330674 Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Sun, 7 Dec 2025 15:53:05 +0800 Subject: [PATCH] change the location of initSDL --- src/core/GameApplication.cpp | 6 ++++++ src/main.cpp | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/GameApplication.cpp b/src/core/GameApplication.cpp index 1f88584..99b8f7c 100644 --- a/src/core/GameApplication.cpp +++ b/src/core/GameApplication.cpp @@ -9,6 +9,12 @@ GameApplication::~GameApplication() { } bool GameApplication::initialize() { + // 初始化SDL视频子系统[6,7](@ref) + if (!SDL_Init(SDL_INIT_VIDEO)) { + SDL_Log("SDL初始化失败: %s", SDL_GetError()); + return false; + } + m_inputManager = std::make_unique(); m_windowManager = std::make_unique(); diff --git a/src/main.cpp b/src/main.cpp index 20a5745..8b50112 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,11 +17,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) { // 设置应用元数据[8](@ref) SDL_SetAppMetadata("孢子棋", "1.0.0", "com.zhenyan121.sporebgconid"); - // 初始化SDL视频子系统[6,7](@ref) - if (!SDL_Init(SDL_INIT_VIDEO)) { - SDL_Log("SDL初始化失败: %s", SDL_GetError()); - return SDL_APP_FAILURE; - } + // 创建游戏实例 auto gameapp = new GameApplication();