All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Effect.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "VectorMathDecl.h"
7 #include "FogShaderUniforms.h"
8 #include "Lighting.h"
9 #include "Rendering.h"
10 
11 #include <string>
12 
13 namespace Eegeo
14 {
15  typedef enum
16  {
17  EFFECT_ATTRIB_INVALID = 0xffffffff,
18 
19  EFFECT_ATTRIB_VERTEX = 0,
20  EFFECT_ATTRIB_NORMAL,
21  EFFECT_ATTRIB_COLOR,
22  EFFECT_ATTRIB_UV0,
23  EFFECT_ATTRIB_UV1,
24  EFFECT_ATTRIB_FLOAT1,
25  EFFECT_ATTRIB_FLOAT2,
26  EFFECT_ATTRIB_BONE_WEIGHT,
27  EFFECT_ATTRIB_BONE_INDEX,
28 
29  NUM_ATTRIBUTES
30 
31  } EFFECT_ATTRIB;
32 
33  typedef enum
34  {
35  EFFECT_UNIFORM_INVALID = 0xffffffff,
36 
37  EFFECT_UNIFORM_MATRIX44_MODELVIEWPROJECTION = 0,
38  EFFECT_UNIFORM_MATRIX44_MODELVIEW,
39  EFFECT_UNIFORM_VECTOR4_MODELWORLDOFFSET,
40  EFFECT_UNIFORM_VECTOR3_LIGHTDIR,
41  EFFECT_UNIFORM_VECTOR3_LIGHTCOL,
42  EFFECT_UNIFORM_VECTOR3_LIGHTAMBIENT,
43  EFFECT_UNIFORM_VECTOR3_EYEPOSITION,
44  EFFECT_UNIFORM_TEXTURE0,
45  EFFECT_UNIFORM_TEXTURE1,
46  EFFECT_UNIFORM_NORMALMAP,
47  EFFECT_UNIFORM_REFLECTIONMAP,
48  EFFECT_UNIFORM_MATRIX44_LIGHTDIR,
49  EFFECT_UNIFORM_MATRIX44_LIGHTCOL,
50  EFFECT_UNIFORM_FLOAT_SCALE,
51 
52  EFFECT_UNIFORM_MATRIX44_BONE_LIST,
53 
54  EFFECT_UNIFORM_VECTOR4_ANIMUV,
55 
56  EFFECT_UNIFORM_FLOAT_SHADOWEXTRUDEDHEIGHTADJUST,
57 
58  EFFECT_UNIFORM_FLOAT_ALPHA,
59  NUM_UNIFORMS,
60 
61  } EFFECT_UNIFORM;
62 
63 
64  class Effect {
65 
66  u32 m_uProgram;
67  s32 m_uniforms[NUM_UNIFORMS];
68 
69  Rendering::Shaders::FogShaderUniforms m_fogShaderUniforms;
70 
71  bool LinkProgram (s32 prog);
72 
73  public:
74 
75  Effect ();
76  ~Effect ();
77 
78  void LoadEffect (std::string& vertShaderSource,
79  std::string& fragShaderSource,
80  EFFECT_ATTRIB* attribList,
81  u32 numAttribs,
82  EFFECT_UNIFORM* uniformList,
83  u32 numUniforms);
84 
85  void PreWarm (Rendering::GLState& glState);
86 
87 
88  void UseProgram_GlState (Eegeo::Rendering::GLState& glState);
89 
90 
91  bool IsUniformValid (EFFECT_UNIFORM uniform);
92 
93  void SetInt (EFFECT_UNIFORM uniform, int val);
94  void SetFloat (EFFECT_UNIFORM uniform, float val);
95  void SetVector2 (EFFECT_UNIFORM uniform, const Eegeo::v2* vector);
96  void SetVector3 (EFFECT_UNIFORM uniform, const Eegeo::v3* vector);
97  void SetVector4 (EFFECT_UNIFORM uniform, const Eegeo::v4* vector);
98  void SetMatrix33 (EFFECT_UNIFORM uniform, const Eegeo::m33* matrix);
99  void SetMatrix44 (EFFECT_UNIFORM uniform, const Eegeo::m44* matrix);
100  void SetMatrix44List(EFFECT_UNIFORM uniform, const Eegeo::m44* matrix, u32 numMatrices);
101  void SetFogState(const Lighting::GlobalFoggingUniformValues& foggingValues, const Eegeo::v3& cameraRelativeModelOrigin);
102  void SetPerMaterialFogState(const Lighting::GlobalFoggingUniformValues& foggingValues);
103  void SetPerModelFogState(const Eegeo::v3& cameraRelativeModelOrigin);
104 
105  };
106 }