Files
2026-06-08 19:58:35 +08:00

73 lines
2.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
namespace frostbite2D {
/**
* @brief 2D 渲染风格预设 ID
*/
enum class RenderStyleProfileId {
PixelArt2D, ///< 世界与 UI 都按像素风策略渲染
Smooth2D, ///< 世界与 UI 都按平滑 2D 策略渲染
Hybrid2D ///< 世界走像素风,UI 走平滑策略
};
/**
* @brief 渲染风格作用层级
*/
enum class RenderStyleLayerRole {
World, ///< 世界层,如地图、角色、场景特效
UI ///< UI 层,如 HUD、菜单、文字
};
/**
* @brief 单个层级的渲染风格开关集合
*/
struct RenderStyleLayerSettings {
bool cameraPixelSnap = false; ///< 是否让相机位置吸附到像素网格
bool vertexPixelSnap = false; ///< 是否让世界顶点在提交前做像素对齐
bool pixelArtSampling = false; ///< 是否优先使用像素风采样(如 GL_NEAREST
bool shrinkSubTextureUVs = false; ///< 是否对子纹理 UV 做向内收缩,减轻图集边缘闪烁
};
/**
* @brief 一套完整的 2D 渲染风格设置
*/
struct RenderStyleSettings {
RenderStyleLayerSettings world; ///< 世界层使用的渲染风格
RenderStyleLayerSettings ui; ///< UI 层使用的渲染风格
/**
* @brief 根据预设 ID 生成对应的渲染风格
*/
static RenderStyleSettings FromProfile(RenderStyleProfileId profile) {
RenderStyleSettings settings;
switch (profile) {
case RenderStyleProfileId::PixelArt2D:
settings.world = {true, true, true, true};
settings.ui = {true, true, true, true};
break;
case RenderStyleProfileId::Smooth2D:
settings.world = {false, false, false, false};
settings.ui = {false, false, false, false};
break;
case RenderStyleProfileId::Hybrid2D:
default:
settings.world = {true, true, true, true};
settings.ui = {false, false, false, false};
break;
}
return settings;
}
/**
* @brief 获取指定层级对应的风格设置
*/
const RenderStyleLayerSettings& layer(RenderStyleLayerRole role) const {
return role == RenderStyleLayerRole::UI ? ui : world;
}
};
} // namespace frostbite2D