载入中...
搜索中...
未找到
LightingMode.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
4#include "common/Diagnostic.h"
5#include "common/GpuInfo.h"
6
7#include <SDL2/SDL.h>
8
9#include <cctype>
10#include <cstdlib>
11#include <string>
12
13namespace eve::graphics {
14namespace {
15
16std::string toLower(std::string s) {
17 for (char& c : s) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
18 return s;
19}
20
21bool containsInsensitive(const std::string& hay, const char* needle) {
22 return toLower(hay).find(needle) != std::string::npos;
23}
24
25} // namespace
26
28 if (const char* presetEnv = std::getenv("EVENGINE_LIGHTING_PRESET")) {
29 const std::string p = toLower(presetEnv);
30 if (p == "desktop") return LightingPreset::Desktop;
31 if (p == "mobile") return LightingPreset::Mobile;
32 if (p == "ci") return LightingPreset::Ci;
33 }
34
35 const char* platform = SDL_GetPlatform();
36 if (platform) {
37 const std::string os = toLower(platform);
38 if (os.find("android") != std::string::npos || os.find("ios") != std::string::npos)
40 }
41
42 if (auto* gpu = eve::cap::query<eve::caps::IGpuInfo>()) {
43 if (gpu->gpuReady()) {
44 const std::string type = toLower(gpu->gpuDeviceType());
45 const std::string name = gpu->gpuName();
46 if (type == "cpu" || containsInsensitive(name, "llvmpipe") || containsInsensitive(name, "lavapipe"))
47 return LightingPreset::Ci;
48 }
49 }
50 // Hosted CI often runs before GPU info is ready; prefer ForwardPlus there.
51 if (std::getenv("CI") || std::getenv("GITHUB_ACTIONS") || std::getenv("EVENGINE_CI")) return LightingPreset::Ci;
53}
54
56 const char* modeEnv = std::getenv("EVENGINE_LIGHTING_MODE");
57 if (!modeEnv || !*modeEnv) {
59 Diagnostic::error(DiagnosticCode::NotFound, "EVENGINE_LIGHTING_MODE unset", "graphics.LightingMode.env"));
60 }
61 const std::string m = toLower(modeEnv);
62 if (m == "forwardplus" || m == "forward+") return Result<LightingMode>::success(LightingMode::ForwardPlus);
65 Diagnostic::error(DiagnosticCode::Unsupported, "EVENGINE_LIGHTING_MODE must be \"forwardPlus\" or \"hybrid\"",
66 "graphics.LightingMode.env"));
67}
68
69} // namespace eve::graphics
const std::string & s
glm::vec4 p[6]
Stable, structured diagnostics shared by engine modules.
std::int32_t c
std::string name
float m[16]
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Result< LightingMode > lightingModeFromEnv()
Optional explicit mode from EVENGINE_LIGHTING_MODE=forwardPlus|hybrid.
LightingPreset suggestedLightingPreset()
Suggest a lighting preset from OS, GPU type/name, and env.
LightingPreset
Platform lighting quality preset (does not replace an explicit setLightingMode).