mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Change Fix the scale bug, and abandon using sfml and still use sdl3
This commit is contained in:
@@ -18,7 +18,7 @@ bool WindowManager::Initialize(GameConfig& config) {
|
||||
"孢子棋", // 窗口标题,显示在标题栏上
|
||||
m_logicalWidth, // 窗口的逻辑宽度(例如 800),用于统一布局,不受屏幕 DPI 影响
|
||||
m_logicalHeight, // 窗口的逻辑高度(例如 600)
|
||||
//SDL_WINDOW_HIGH_PIXEL_DENSITY | // 启用高像素密度支持(HiDPI/Retina),确保在高分屏上画面清晰
|
||||
SDL_WINDOW_HIGH_PIXEL_DENSITY | // 启用高像素密度支持(HiDPI/Retina),确保在高分屏上画面清晰
|
||||
SDL_WINDOW_RESIZABLE // 允许用户调整窗口大小(可拉伸)
|
||||
);
|
||||
if (!m_window) {
|
||||
@@ -54,7 +54,8 @@ bool WindowManager::Initialize(GameConfig& config) {
|
||||
m_logicalWidth,
|
||||
m_logicalHeight
|
||||
);
|
||||
|
||||
// 设置纹理缩放模式为最近邻
|
||||
SDL_SetTextureScaleMode(m_logicalTexture, SDL_SCALEMODE_NEAREST);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -74,6 +75,17 @@ void WindowManager::Clear() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void WindowManager::Clear() {
|
||||
|
||||
// 设置画笔颜色
|
||||
SDL_SetRenderDrawColor(m_renderer, 255, 255, 255, 255); // 白色背景
|
||||
// 使用画笔颜色填充整个逻辑画布
|
||||
SDL_RenderClear(m_renderer);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void WindowManager::Present() {
|
||||
|
||||
// 4. 切回默认渲染目标(窗口)
|
||||
@@ -90,6 +102,7 @@ void WindowManager::Present() {
|
||||
SDL_RenderPresent(m_renderer);
|
||||
}
|
||||
|
||||
|
||||
SDL_Renderer* WindowManager::GetRenderer() {
|
||||
return m_renderer;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,11 @@ void UIRenderer::renderButtonBackground(const ButtonData& buttonData) {
|
||||
SDL_SetRenderDrawColor(m_renderer, m_backgroundColor.r, m_backgroundColor.g, m_backgroundColor.b, m_backgroundColor.a);
|
||||
auto [width, height] = m_textRenderer->getTextSize(buttonData.text, buttonData.textstytle);
|
||||
// 绘制普通矩形
|
||||
SDL_FRect rect = { static_cast<float>(m_rect.x),
|
||||
static_cast<float>(m_rect.y),
|
||||
static_cast<float>(width),
|
||||
static_cast<float>(height) };
|
||||
SDL_FRect rect = { static_cast<float>(m_rect.x) + 0.375f,
|
||||
static_cast<float>(m_rect.y) + 0.375f,
|
||||
static_cast<float>(m_rect.w) - 0.75f,
|
||||
static_cast<float>(m_rect.h) - 0.75f };
|
||||
//SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_NONE);
|
||||
SDL_RenderFillRect(m_renderer, &rect);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user