Changeset View
Standalone View
source/renderer/RenderingOptions.h
- This file was added.
/* Copyright (C) 2019 Wildfire Games. | |||||
* This file is part of 0 A.D. | |||||
* | |||||
* 0 A.D. is free software: you can redistribute it and/or modify | |||||
* it under the terms of the GNU General Public License as published by | |||||
* the Free Software Foundation, either version 2 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* 0 A.D. is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
/** | |||||
* Keeps track of the settings used for rendering. | |||||
* Ideally this header file should remain very quick to parse, | |||||
* so avoid including other headers here unless absolutely necessary. | |||||
*/ | |||||
#ifndef INCLUDED_RENDERINGOPTIONS | |||||
#define INCLUDED_RENDERINGOPTIONS | |||||
class CStr8; | |||||
class CRenderer; | |||||
historic_bruno: Why the change from CStr to CStr8? | |||||
Done Inline ActionsCStr isn't a type. It's a define that takes CStr8 and CStrW alternatively, we include the file twice So it just didn't work iirc. wraitii: CStr isn't a type. It's a define that takes CStr8 and CStrW alternatively, we include the file… | |||||
Not Done Inline ActionsI think it only temporarily becomes CStrW for the purpose of compiling a shared source file. Everywhere else, CStr should be the same as a CStr8 (although it's a macro). There are actually very few places in the code where CStr8 is used compared to CStr or CStrW. It's also discouraged in the coding conventions: https://trac.wildfiregames.com/wiki/Coding_Conventions#Strings Unless the goal was to not include CStr.h here? historic_bruno: I think it only temporarily becomes CStrW for the purpose of compiling a shared source file. | |||||
Done Inline ActionsThe goal was probably to not include CStr.h there. wraitii: The goal was probably to not include CStr.h there. | |||||
Done Inline ActionsOK, that seems to be how it's used elsewhere (sparingly), makes sense. historic_bruno: OK, that seems to be how it's used elsewhere (sparingly), makes sense. | |||||
Done Inline ActionsI've become quite wary of compilation times, and including headers everywhere is a serious problem. So I would actually motion to change our coding conventions on this. wraitii: I've become quite wary of compilation times, and including headers everywhere is a serious… | |||||
enum RenderPath { | |||||
// If no rendering path is configured explicitly, the renderer | |||||
// will choose the path when Open() is called. | |||||
DEFAULT, | |||||
// Classic fixed function. | |||||
FIXED, | |||||
// Use new ARB/GLSL system | |||||
SHADER | |||||
}; | |||||
struct RenderPathEnum | |||||
{ | |||||
static RenderPath FromString(const CStr8& name); | |||||
static CStr8 ToString(RenderPath); | |||||
}; | |||||
struct SRenderingOptions | |||||
{ | |||||
// The renderer needs access to our private variables directly because capabilities have not yet been extracted | |||||
// and thus sometimes it needs to change the rendering options without the side-effects. | |||||
friend class CRenderer; | |||||
SRenderingOptions(); | |||||
void ReadConfig(); | |||||
#define OPTION_DEFAULT_SETTER(NAME, TYPE) \ | |||||
public: void Set##NAME(TYPE value) { m_##NAME = value; }\ | |||||
#define OPTION_CUSTOM_SETTER(NAME, TYPE) \ | |||||
public: void Set##NAME(TYPE value);\ | |||||
#define OPTION_GETTER(NAME, TYPE)\ | |||||
public: TYPE Get##NAME() const { return m_##NAME; }\ | |||||
#define OPTION_DEF(NAME, TYPE)\ | |||||
private: TYPE m_##NAME; | |||||
#define OPTION(NAME, TYPE)\ | |||||
OPTION_DEFAULT_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE); | |||||
#define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)\ | |||||
OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE); | |||||
OPTION(NoVBO, bool); | |||||
OPTION(Shadows, bool); | |||||
OPTION_WITH_SIDE_EFFECT(RenderPath, RenderPath); | |||||
OPTION(WaterEffects, bool); | |||||
OPTION(WaterFancyEffects, bool); | |||||
OPTION(WaterRealDepth, bool); | |||||
OPTION(WaterRefraction, bool); | |||||
OPTION(WaterReflection, bool); | |||||
OPTION(WaterShadows, bool); | |||||
OPTION(ShadowAlphaFix, bool); | |||||
OPTION(ARBProgramShadow, bool); | |||||
OPTION(ShadowPCF, bool); | |||||
OPTION(Particles, bool); | |||||
OPTION(PreferGLSL, bool); | |||||
OPTION(ForceAlphaTest, bool); | |||||
OPTION(GPUSkinning, bool); | |||||
OPTION(Fog, bool); | |||||
OPTION(Silhouettes, bool); | |||||
OPTION(SmoothLOS, bool); | |||||
OPTION(ShowSky, bool); | |||||
OPTION(PostProc, bool); | |||||
OPTION(DisplayFrustum, bool); | |||||
OPTION(RenderActors, bool); | |||||
#undef OPTION_DEFAULT_SETTER | |||||
#undef OPTION_CUSTOM_SETTER | |||||
#undef OPTION_GETTER | |||||
#undef OPTION_DEF | |||||
#undef OPTION | |||||
#undef OPTION_WITH_SIDE_EFFECT | |||||
}; | |||||
extern SRenderingOptions g_RenderingOptions; | |||||
#endif // INCLUDED_RENDERINGOPTIONS |
Why the change from CStr to CStr8?