All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SdfTextShader.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Shader.h"
6 #include "IdTypes.h"
7 #include "Graphics.h"
8 #include "Rendering.h"
9 #include "VectorMath.h"
10 #include <string>
11 
12 namespace Eegeo
13 {
14  namespace Rendering
15  {
16  namespace Shaders
17  {
18  class SdfTextShader : public Shader
19  {
20  public:
21  static SdfTextShader* CreateNull(const TShaderId shaderId);
22 
23  static SdfTextShader* CreateSignedDistanceFieldUniformScale(const TShaderId shaderId);
24 
25  static SdfTextShader* CreateSignedDistanceFieldUniformScaleSuperSampled(const TShaderId shaderId);
26 
27  static SdfTextShader* CreateSignedDistanceField(const TShaderId shaderId);
28 
29  static SdfTextShader* CreateSignedDistanceFieldSuperSampled(const TShaderId shaderId);
30 
31 
32  const GLuint GetDiffuseSamplerId() const;
33 
34  void SetMVP(const m44& mvp) const;
35 
36  void SetScale(const v3& scale) const;
37 
38  void SetGlyphColor(const v4& rgba) const;
39 
40  void SetSdfConstants(const float sdfSpread, const float textureSize, const float texelToPixelRatio, const float haloSize, const float haloHardness, const float antiAliasTweakMultiplier) const;
41 
42  void Use(Rendering::GLState& glState) const;
43 
44  private:
45  GLuint m_modelViewProjectionUniformLocation;
46  GLuint m_scaleUniformLocation;
47  GLuint m_glyphColorUniformLocation;
48  GLuint m_diffuseTextureSampleUniformLocation;
49  GLuint m_sdfConstantsUniformLocation;
50 
51  const bool m_isUniformScale;
52  const bool m_isNull;
53 
54  SdfTextShader(const TShaderId shaderId, const std::string& vertexCode, const std::string& fragmentCode, bool isUniformScale, bool isNull = false);
55  };
56  }
57  }
58 }