- 新增 d3d12_surface 类,管理交换链和渲染目标 - 实现三重缓冲后台缓冲区管理 - 添加视口和裁剪矩形配置 - 修复 GraphicsPlatformInterface.h 循环包含问题 - 添加完整的中文 Doxygen 注释 - 更新 D3D12 学习 Wiki,添加交换链章节
113 lines
2.2 KiB
C++
113 lines
2.2 KiB
C++
#pragma once
|
|
#include "Platform/Window.h"
|
|
|
|
|
|
namespace XEngine::graphics {
|
|
|
|
DEFINE_TYPED_ID(surface_id);
|
|
|
|
/**
|
|
* @brief 表面类
|
|
* @details 定义了渲染表面的属性与操作
|
|
*/
|
|
class surface
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 由表面 ID 构造句柄。
|
|
* @param id 表面 ID。
|
|
*/
|
|
constexpr explicit surface(surface_id id) : _id{ id } {}
|
|
/**
|
|
* @brief 构造无效表面句柄。
|
|
*/
|
|
constexpr surface() = default;
|
|
/**
|
|
* @brief 获取表面 ID。
|
|
* @return 表面 ID。
|
|
*/
|
|
constexpr surface_id get_id() const { return _id; }
|
|
/**
|
|
* @brief 判断表面句柄是否有效。
|
|
* @return 有效返回 true。
|
|
*/
|
|
constexpr bool is_valid() const { return id::is_valid(_id); }
|
|
|
|
|
|
/**
|
|
* @brief 调整表面大小。
|
|
* @param width 目标宽度。
|
|
* @param height 目标高度。
|
|
*/
|
|
void resize(u32 width, u32 height) const;
|
|
/**
|
|
* @brief 获取表面宽度。
|
|
* @return 宽度像素值。
|
|
*/
|
|
u32 width() const;
|
|
/**
|
|
* @brief 获取表面高度。
|
|
* @return 高度像素值。
|
|
*/
|
|
u32 height() const;
|
|
|
|
void render() const;
|
|
|
|
private:
|
|
surface_id _id{ id::invalid_id };
|
|
};
|
|
|
|
/**
|
|
* @brief 渲染表面结构体
|
|
* @details 定义了渲染表面的窗口与表面对象
|
|
*/
|
|
struct render_surface
|
|
{
|
|
platform::window window{};
|
|
surface surface{};
|
|
};
|
|
|
|
/**
|
|
* @brief 图形渲染平台枚举
|
|
* @details 定义了支持的图形渲染平台类型
|
|
*/
|
|
enum class graphics_platform : u32
|
|
{
|
|
direct3d12 = 0,
|
|
vulkan = 1,
|
|
opengl = 2,
|
|
};
|
|
|
|
/**
|
|
* @brief 初始化图形渲染平台
|
|
* @details 调用设置平台接口函数,初始化指定的图形渲染平台
|
|
* @param platform 图形渲染平台类型
|
|
* @return true 如果初始化成功,否则返回 false
|
|
*/
|
|
bool initialize(graphics_platform platform);
|
|
/**
|
|
* @brief 关闭图形渲染平台
|
|
* @details 调用关闭函数指针,关闭指定的图形渲染平台
|
|
*/
|
|
void shutdown();
|
|
|
|
/**
|
|
* @brief 渲染调用接口
|
|
* @details 调用渲染函数指针,渲染当前渲染表面
|
|
*/
|
|
void render();
|
|
|
|
/**
|
|
* @brief 创建渲染表面
|
|
* @details window 渲染表面的窗口
|
|
* @return 渲染表面对象柄
|
|
*/
|
|
surface create_surface(platform::window window);
|
|
|
|
/**
|
|
* @brief 移除渲染表面
|
|
* @details id 渲染表面的 ID
|
|
*/
|
|
void remove_surface(surface_id id);
|
|
|
|
} |