11 #include "GLESShader.h" 12 #include "rendering/RenderSystem.h" 13 #include "utils/ColorUtils.h" 14 #include "utils/Map.h" 18 #include <fmt/format.h> 20 #include "system_gl.h" 22 enum class ShaderMethodGLES
32 SM_TEXTURE_RGBA_BLENDCOLOR,
34 SM_TEXTURE_RGBA_BOB_OES,
40 struct fmt::formatter<ShaderMethodGLES> : fmt::formatter<std::string_view>
42 template<
typename FormatContext>
43 constexpr
auto format(
const ShaderMethodGLES& shaderMethod, FormatContext& ctx)
45 const auto it = ShaderMethodGLESMap.find(shaderMethod);
46 if (it == ShaderMethodGLESMap.cend())
47 throw std::range_error(
"no string mapping found for shader method");
49 return fmt::formatter<string_view>::format(it->second, ctx);
53 static constexpr
auto ShaderMethodGLESMap = make_map<ShaderMethodGLES, std::string_view>({
54 {ShaderMethodGLES::SM_DEFAULT,
"default"},
55 {ShaderMethodGLES::SM_TEXTURE,
"texture"},
56 {ShaderMethodGLES::SM_MULTI,
"multi"},
57 {ShaderMethodGLES::SM_FONTS,
"fonts"},
58 {ShaderMethodGLES::SM_TEXTURE_NOBLEND,
"texture no blending"},
59 {ShaderMethodGLES::SM_MULTI_BLENDCOLOR,
"multi blend colour"},
60 {ShaderMethodGLES::SM_TEXTURE_RGBA,
"texure rgba"},
61 {ShaderMethodGLES::SM_TEXTURE_RGBA_OES,
"texture rgba OES"},
62 {ShaderMethodGLES::SM_TEXTURE_RGBA_BLENDCOLOR,
"texture rgba blend colour"},
63 {ShaderMethodGLES::SM_TEXTURE_RGBA_BOB,
"texture rgba bob"},
64 {ShaderMethodGLES::SM_TEXTURE_RGBA_BOB_OES,
"texture rgba bob OES"},
65 {ShaderMethodGLES::SM_TEXTURE_NOALPHA,
"texture no alpha"},
68 static_assert(static_cast<size_t>(ShaderMethodGLES::SM_MAX) == ShaderMethodGLESMap.size(),
69 "ShaderMethodGLESMap doesn't match the size of ShaderMethodGLES, did you forget to " 70 "add/remove a mapping?");
79 bool InitRenderSystem()
override;
80 bool DestroyRenderSystem()
override;
81 bool ResetRenderSystem(
int width,
int height)
override;
83 bool BeginRender()
override;
84 bool EndRender()
override;
85 void PresentRender(
bool rendered,
bool videoLayer)
override;
86 bool ClearBuffers(UTILS::COLOR::Color color)
override;
87 bool IsExtSupported(
const char* extension)
const override;
89 void SetVSync(
bool vsync);
90 void ResetVSync() { m_bVsyncInit =
false; }
92 void SetViewPort(
const CRect& viewPort)
override;
93 void GetViewPort(
CRect& viewPort)
override;
95 bool ScissorsCanEffectClipping()
override;
96 CRect ClipRectToScissorRect(
const CRect &rect)
override;
97 void SetScissors(
const CRect& rect)
override;
98 void ResetScissors()
override;
100 void CaptureStateBlock()
override;
101 void ApplyStateBlock()
override;
103 void SetCameraPosition(
const CPoint &camera,
int screenWidth,
int screenHeight,
float stereoFactor = 0.0f)
override;
105 bool SupportsStereo(RENDER_STEREO_MODE mode)
const override;
107 void Project(
float &x,
float &y,
float &z)
override;
109 std::string GetShaderPath(
const std::string &filename)
override {
return "GLES/2.0/"; }
111 void InitialiseShaders();
112 void ReleaseShaders();
113 void EnableGUIShader(ShaderMethodGLES method);
114 void DisableGUIShader();
116 GLint GUIShaderGetPos();
117 GLint GUIShaderGetCol();
118 GLint GUIShaderGetCoord0();
119 GLint GUIShaderGetCoord1();
120 GLint GUIShaderGetUniCol();
121 GLint GUIShaderGetCoord0Matrix();
122 GLint GUIShaderGetField();
123 GLint GUIShaderGetStep();
124 GLint GUIShaderGetContrast();
125 GLint GUIShaderGetBrightness();
126 GLint GUIShaderGetModel();
129 virtual void SetVSyncImpl(
bool enable) = 0;
130 virtual void PresentRenderImpl(
bool rendered) = 0;
131 void CalculateMaxTexturesize();
133 bool m_bVsyncInit{
false};
137 std::string m_RenderExtensions;
139 std::map<ShaderMethodGLES, std::unique_ptr<CGLESShader>> m_pShader;
140 ShaderMethodGLES m_method = ShaderMethodGLES::SM_DEFAULT;
Definition: RenderSystemGLES.h:73
Definition: RenderSystem.h:27