mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Added fullscreen funtion
This commit is contained in:
@@ -34,6 +34,7 @@ bool WindowManager::Initialize(GameConfig& config) {
|
||||
"创建渲染器失败: %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
// 关键设置:启用像素模式
|
||||
|
||||
// 设置逻辑呈现模式,实现分辨率自适应[3](@ref)
|
||||
SDL_SetRenderLogicalPresentation(m_renderer,
|
||||
@@ -66,4 +67,14 @@ SDL_Renderer* WindowManager::GetRenderer() {
|
||||
|
||||
SDL_Window* WindowManager::GetWindow() {
|
||||
return m_window;
|
||||
}
|
||||
|
||||
bool WindowManager::setFullscreen(bool isFullscreen) {
|
||||
if (isFullscreen == m_isFullscreen) {
|
||||
return true; // 状态未改变,直接返回
|
||||
}
|
||||
SDL_SetWindowFullscreen(m_window, isFullscreen);
|
||||
m_isFullscreen = isFullscreen;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
void Clear();
|
||||
//呈现窗口
|
||||
void Present();
|
||||
|
||||
bool setFullscreen(bool isFullscreen);
|
||||
|
||||
SDL_Renderer* GetRenderer();
|
||||
SDL_Window* GetWindow();
|
||||
@@ -25,5 +25,5 @@ private:
|
||||
SDL_Renderer* m_renderer;
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
bool m_isFullscreen = false;
|
||||
};
|
||||
@@ -24,6 +24,11 @@ SDL_AppResult InputManager::handleInputEvent(const SDL_Event* event) {
|
||||
m_currentInputState.mouseCurrentPosition = {static_cast<float>(event->motion.x),
|
||||
static_cast<float>(event->motion.y)};
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
if (event->key.key == SDLK_F11) {
|
||||
m_currentInputState.isFullscreen = !m_currentInputState.isFullscreen;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ struct InputState
|
||||
std::pair<float, float> mouseCilckOn;
|
||||
bool leftMouseDown = false;
|
||||
std::pair<float, float> mouseCurrentPosition;
|
||||
bool isFullscreen = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user