feat: 透明窗口支持 + 退出确认流程 + ImGui 总开关

用户自主改进批次:
- 透明窗口:GLFW_TRANSPARENT_FRAMEBUFFER + 窗口 opacity 0.5,
  swapchain composite alpha 按能力自适应(Opaque/Pre/PostMultiplied),
  Forward 清屏 alpha=0,tonemap 透传 HDR alpha——物体实体、背景透明
- 退出确认:Window 挂 WindowCloseCallback 发事件,App 侧 OnWindowClose
  置确认标记,OnRenderOverlay 弹 ImGui 确认框后 Close();
  主循环退出条件改为 m_Running(close 事件驱动)
- ImGui 总开关:` 键切换 ImGuiLayer::SetEnabled,禁用时跳过
  NewFrame/OnRenderOverlay/BuildDrawData 整段
- 帧率控制简化:去掉 LimitFps 开关,非 vsync 时恒按 target 限帧
  (默认 60,可调 ≥24);m_VSync 默认 false(Mailbox 不限速)
- 清理:Model.cpp const 修正,swapchain 日志带 present mode,
  GPU 遥测暂时注释

验证:0 error 0 warning,composite alpha 实测选 PreMultiplied(0x2),
present=Mailbox
This commit is contained in:
2026-09-23 10:57:48 +08:00
parent d8274e8bdc
commit df4871a49b
10 changed files with 174 additions and 95 deletions
+8 -4
View File
@@ -26,6 +26,8 @@
#include <chrono>
#include <string>
#include "Engine/ImGui/ImGuiLayer.h"
namespace Engine {
class Window;
@@ -59,8 +61,6 @@ namespace Engine {
// 限帧目标最低 24fps(防止过低刷新导致交互卡死),无上限
void SetVSync(bool vsync);
bool GetVSync() const { return m_VSync; }
void SetLimitFps(bool on) { m_LimitFps = on; }
bool GetLimitFps() const { return m_LimitFps; }
void SetTargetFps(f32 fps) { m_TargetFps = std::max(24.0f, fps); }
f32 GetTargetFps() const { return m_TargetFps; }
@@ -72,6 +72,11 @@ namespace Engine {
f32 GetDeltaTime() const { return m_DeltaTime; }
u64 GetFrameCount() const { return m_FrameCount; }
// ImGui相关
void SetImGuiEnabled(const bool enable) { if (m_ImGuiLayer) m_ImGuiLayer->SetEnabled(enable); }
// 理论上ImGuiLayer不应该会空,暂时静默处理
bool GetImGuiEnabled() const { return m_ImGuiLayer ? m_ImGuiLayer->IsEnabled() : false; }
protected:
// ---- 生命周期钩子 ----
@@ -119,8 +124,7 @@ namespace Engine {
u64 m_FrameCount = 0;
// 帧率控制
bool m_VSync = true; // 垂直同步(present 自带节奏)
bool m_LimitFps = false; // 手动限帧开关(vsync 开启时不生效)
bool m_VSync = false; // 垂直同步(present 自带节奏)
f32 m_TargetFps = 60.0f; // 限帧目标(≥24)
std::chrono::steady_clock::time_point m_LastFrameTime;
+2
View File
@@ -87,6 +87,8 @@ namespace Engine {
static void CursorPosCallback(GLFWwindow* window, double xpos, double ypos);
static void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
static void WindowFocusCallback(GLFWwindow* window, int focused);
static void WindowCloseCallback(GLFWwindow* window);
};
} // namespace Engine