12 #include "rendering/RenderSystem.h"    13 #include "utils/ColorUtils.h"    14 #include "utils/Map.h"    19 #include <fmt/format.h>    21 #include "system_gl.h"    23 enum class ShaderMethodGL
    37 struct fmt::formatter<ShaderMethodGL> : fmt::formatter<std::string_view>
    39   template<
typename FormatContext>
    40   constexpr 
auto format(
const ShaderMethodGL& shaderMethod, FormatContext& ctx)
    42     const auto it = ShaderMethodGLMap.find(shaderMethod);
    43     if (it == ShaderMethodGLMap.cend())
    44       throw std::range_error(
"no string mapping found for shader method");
    46     return fmt::formatter<string_view>::format(it->second, ctx);
    50   static constexpr 
auto ShaderMethodGLMap = make_map<ShaderMethodGL, std::string_view>({
    51       {ShaderMethodGL::SM_DEFAULT, 
"default"},
    52       {ShaderMethodGL::SM_TEXTURE, 
"texture"},
    53       {ShaderMethodGL::SM_TEXTURE_LIM, 
"texture limited"},
    54       {ShaderMethodGL::SM_MULTI, 
"multi"},
    55       {ShaderMethodGL::SM_FONTS, 
"fonts"},
    56       {ShaderMethodGL::SM_FONTS_SHADER_CLIP, 
"fonts with vertex shader based clipping"},
    57       {ShaderMethodGL::SM_TEXTURE_NOBLEND, 
"texture no blending"},
    58       {ShaderMethodGL::SM_MULTI_BLENDCOLOR, 
"multi blend colour"},
    61   static_assert(static_cast<size_t>(ShaderMethodGL::SM_MAX) == ShaderMethodGLMap.size(),
    62                 "ShaderMethodGLMap doesn't match the size of ShaderMethodGL, did you forget to "    63                 "add/remove a mapping?");
    71   bool InitRenderSystem() 
override;
    72   bool DestroyRenderSystem() 
override;
    73   bool ResetRenderSystem(
int width, 
int height) 
override;
    75   bool BeginRender() 
override;
    76   bool EndRender() 
override;
    77   void PresentRender(
bool rendered, 
bool videoLayer) 
override;
    78   bool ClearBuffers(UTILS::COLOR::Color color) 
override;
    79   bool IsExtSupported(
const char* extension) 
const override;
    81   void SetVSync(
bool vsync);
    82   void ResetVSync() { m_bVsyncInit = 
false; }
    84   void SetViewPort(
const CRect& viewPort) 
override;
    85   void GetViewPort(
CRect& viewPort) 
override;
    87   bool ScissorsCanEffectClipping() 
override;
    88   CRect ClipRectToScissorRect(
const CRect &rect) 
override;
    89   void SetScissors(
const CRect &rect) 
override;
    90   void ResetScissors() 
override;
    92   void CaptureStateBlock() 
override;
    93   void ApplyStateBlock() 
override;
    95   void SetCameraPosition(
const CPoint &camera, 
int screenWidth, 
int screenHeight, 
float stereoFactor = 0.0f) 
override;
    97   void SetStereoMode(RENDER_STEREO_MODE mode, RENDER_STEREO_VIEW view) 
override;
    98   bool SupportsStereo(RENDER_STEREO_MODE mode) 
const override;
    99   bool SupportsNPOT(
bool dxt) 
const override;
   101   void Project(
float &x, 
float &y, 
float &z) 
override;
   103   std::string GetShaderPath(
const std::string &filename) 
override;
   105   void GetGLVersion(
int& major, 
int& minor);
   106   void GetGLSLVersion(
int& major, 
int& minor);
   108   void ResetGLErrors();
   111   void EnableShader(ShaderMethodGL method);
   112   void DisableShader();
   113   GLint ShaderGetPos();
   114   GLint ShaderGetCol();
   115   GLint ShaderGetCoord0();
   116   GLint ShaderGetCoord1();
   117   GLint ShaderGetUniCol();
   118   GLint ShaderGetModel();
   119   GLint ShaderGetMatrix();
   120   GLint ShaderGetClip();
   121   GLint ShaderGetCoordStep();
   124   virtual void SetVSyncImpl(
bool enable) = 0;
   125   virtual void PresentRenderImpl(
bool rendered) = 0;
   126   void CalculateMaxTexturesize();
   127   void InitialiseShaders();
   128   void ReleaseShaders();
   130   bool m_bVsyncInit = 
false;
   134   std::string m_RenderExtensions;
   141   std::map<ShaderMethodGL, std::unique_ptr<CGLShader>> m_pShader;
   142   ShaderMethodGL m_method = ShaderMethodGL::SM_DEFAULT;
   143   GLuint m_vertexArray = GL_NONE;
 
Definition: RenderSystemGL.h:66
Definition: RenderSystem.h:27