My Project: openb3dlib.mod/openb3d/src/shaderobject.h Source File

My Project

shaderobject.h
Go to the documentation of this file.
1 ;
2 #include <map>
3 #include <vector>
4
5
6
7 class ProgramObject;
8 class Surface;
9
10 //list<ProgramObject*> ProgramObjectList;
11
12 class ShaderObject{
13 public:
14 static list<ShaderObject*> ShaderObjectList;
15
16 int ShaderObj;
17 int ShaderType; // 1 = Vert, 2 = Frag
18 list<ProgramObject*> Attached; // Shaders can be attached, or 'referenced by', more than 1 ProgramObject
19 string shaderName;
20
21 static ShaderObject* CreateVertShader(string shaderFileName);
22 static ShaderObject* CreateFragShader(string shaderFileName);
23 static ShaderObject* CreateVertShaderFromString(string shadercode);
24 static ShaderObject* CreateFragShaderFromString(string shadercode);
25 void DeleteVertShader(ShaderObject* vShader);
26 void DeleteFragShader(ShaderObject* fShader);
27
28 };
29
30 class ProgramObject{
31 public:
32 static list<ProgramObject*> ProgramObjectList;
33
34 int Program; // The ProgramObject
35 list<ShaderObject*> vList; // Vertex shader list. A List of what Vert shaders are attached to this ProgramObject
36 list<ShaderObject*> fList; // Frag shader list. A List of what Frag shaders are attached to this ProgramObject
37 string progName;
38
39 int vertShaderCount;
40 int fragShaderCount;
41
42 map<string,int> TypeMap;
43
44 static ProgramObject* Create(string name = "null");
45
46 void Activate();
47 void DeActivate();
48 void RefreshTypeMap();
49
50 // Get the Uniform Variable Location from a ProgramObject
51 int GetUniLoc(string name);
52
53 // Get the Attribute Variable Location from a ProgramObject
54 int GetAttribLoc(string name);
55 void SetParameter1S(string name, float v1);
56 void SetParameter2S(string name, float v1, float v2);
57 void SetParameter3S(string name, float v1, float v2, float v3);
58 void SetParameter4S(string name, float v1, float v2, float v3, float v4);
59
60 //------------------------------------------------------------
61 // Int Parameter
62
63 void SetParameter1I(string name, int v1);
64 void SetParameter2I(string name, int v1, int v2);
65 void SetParameter3I(string name, int v1, int v2, int v3);
66 void SetParameter4I(string name, int v1, int v2, int v3, int v4);
67
68 //----------------------------------------------------------------------------------
69 // Int Vectors
70
71 void SetVector1I(string name, int* v1);
72 void SetVector2I(string name, int* v1);
73 void SetVector3I(string name, int* v1);
74 void SetVector4I(string name, int* v1);
75
76 //-------------------------------------------------------------------------------------
77 // Double Parameter ( automatically Attributes, because Uniform doubles does not exist)
78
79 void SetParameter1D(string name, double v1);
80 void SetParameter2D(string name, double v1, double v2);
81 void SetParameter3D(string name, double v1, double v2, double v3);
82 void SetParameter4D(string name, double v1, double v2, double v3, double v4);
83
84 //-------------------------------------------------------------------------------------
85 // Array Parameter
86 void SetParameterArray(string name, Surface* surf, int vbo);
87 void SetParameterArray(string name, vector<float>* vertices, int vbo);
88
89 //-------------------------------------------------------------------------------------
90 // Float Parameter
91
92 void SetParameter1F(string name, float v);
93 void SetParameter2F(string name, float v1, float v2);
94 void SetParameter3F(string name, float v1, float v2, float v3);
95 void SetParameter4F(string name, float v1, float v2, float v3, float v4);
96
97 //---------------------------------------------------------------------------------------------------
98 // Float Vectors
99
100
101 void SetVector1F(string name, float* v1);
102 void SetVector2F(string name, float* v1);
103 void SetVector3F(string name, float* v1);
104 void SetVector4F(string name, float* v1);
105
106 //--------------------------------------------------------------------------------------------------
107 // Matrices
108
109 void SetMatrix2F(string name, float* m);
110 void SetMatrix3F(string name, float* m);
111 void SetMatrix4F(string name, float* m);
112
113
114 //----------------------------------------------------------
115 //Attach & Link a Vertex Shader Object to this ProgramObject
116 //----------------------------------------------------------
117 int AttachVertShader(ShaderObject* myShader);
118
119 //------------------------------------------------------------
120 //Attach & Link a Fragment Shader Object to this ProgramObject
121 //------------------------------------------------------------
122 int AttachFragShader(ShaderObject* myShader);
123
124 //-------------------------------------------------------
125 //Detach a VertShader:tShaderObject from a tProgramObject
126 //-------------------------------------------------------
127 void DetachVertShader(ShaderObject* vShader);
128
129 //-------------------------------------------------------
130 //Detach a FragShader:tShaderObject from a tProgramObject
131 //-------------------------------------------------------
132 void DetachFragShader(ShaderObject* fShader);
133
134 };
135
ProgramObject::vList
list< ShaderObject * > vList
Definition: shaderobject.h:35
ShaderObject::CreateVertShader
static ShaderObject * CreateVertShader(string shaderFileName)
Definition: material.cpp:74
Surface
Definition: surface.h:19
ProgramObject::TypeMap
map< string, int > TypeMap
Definition: shaderobject.h:42
ShaderObject::DeleteVertShader
void DeleteVertShader(ShaderObject *vShader)
Definition: material.cpp:355
ProgramObject::fragShaderCount
int fragShaderCount
Definition: shaderobject.h:40
ProgramObject::vertShaderCount
int vertShaderCount
Definition: shaderobject.h:39
ProgramObject
Definition: shaderobject.h:30
ProgramObject::ProgramObjectList
static list< ProgramObject * > ProgramObjectList
Definition: shaderobject.h:32
ShaderObject::ShaderObjectList
static list< ShaderObject * > ShaderObjectList
Definition: shaderobject.h:14
ShaderObject::ShaderObj
int ShaderObj
Definition: shaderobject.h:16
ShaderObject::Attached
list< ProgramObject * > Attached
Definition: shaderobject.h:18
ShaderObject::CreateFragShaderFromString
static ShaderObject * CreateFragShaderFromString(string shadercode)
Definition: material.cpp:292
ProgramObject::progName
string progName
Definition: shaderobject.h:37
ProgramObject::fList
list< ShaderObject * > fList
Definition: shaderobject.h:36
ShaderObject
Definition: shaderobject.h:12
ShaderObject::CreateFragShader
static ShaderObject * CreateFragShader(string shaderFileName)
Definition: material.cpp:150
ShaderObject::ShaderType
int ShaderType
Definition: shaderobject.h:17
ShaderObject::shaderName
string shaderName
Definition: shaderobject.h:19
ShaderObject::DeleteFragShader
void DeleteFragShader(ShaderObject *fShader)
Definition: material.cpp:374
ShaderObject::CreateVertShaderFromString
static ShaderObject * CreateVertShaderFromString(string shadercode)
Definition: material.cpp:221
ProgramObject::Program
int Program
Definition: shaderobject.h:34