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

My Project

shadermat.h
Go to the documentation of this file.
1 #ifndef SHADER_MAT_H
2 #define SHADER_MAT_H
3
4
5 //#include "global.h"
6 #include "matrix.h"
7 //#include "surface.h"
8 #include "texture.h"
9 #include "shaderobject.h"
10
11 #include <string>
12 #include <sstream>
13
14 class Surface;
15 class Entity;
16
17 class ShaderData{
18 public:
19 string name;
20 int type;
21 union{
22 //float valuef[3];
23 //int valuei[3];
24 //double valued[3];
25 float* fp[4];
26 int* ip[4];
27 Entity* ent;
28 struct {
29 Surface* surf;
30 int vbo;
31 };
32 };
33 };
34
35 class Material : public Texture{
36 public:
37 static Material* LoadMaterial(string filename,int flags=0, int frame_width=0,int frame_height=0,int first_frame=0,int frame_count=1);
38 void BufferToMaterial(unsigned char* buffer);
39 void MaterialToBuffer(unsigned char* buffer);
40 };
41
42
43 class Sampler{
44 public:
45 string Name;
46 Texture* texture;
47 int Slot;
48 int is3D;
49
50 static Sampler* Create(string Name, int Slot, Texture* Tex);
51
52 };
53
54
55
56 class Shader {//: public MaterialPlugin{
57 static int ShaderIDCount;
58
59 int texCount;
60 Sampler* Shader_Tex[255];
61 ProgramObject* arb_program;
62 int ID;
63 string name;
64 char UpdateSampler;
65
66 vector<ShaderData> Parameters;
67
68
69 //-------------------------------------------------------------------------------
70
71 //void UpdateData(Surface* surf);
72
73 // internal
74 public:
75 static Shader* CreateShaderMaterial(string Name = "");
76 void TurnOn(Matrix& mat, Surface* surf, vector<float>* vertices=0);
77 void TurnOff();
78 void AddShader(string _vert, string _frag);
79 void AddShaderFromString(string _vert, string _frag);
80 Texture* AddSampler2D(string Name, int Slot, Texture* Tex);
81 void AddSampler3D(string Name, int Slot, Texture* Tex);
82 void ProgramAttriBegin();
83 void ProgramAttriEnd();
84 void FreeShader();
85
86 void SetFloat(string name, float v1);
87 void SetFloat2(string name, float v1, float v2);
88 void SetFloat3(string name, float v1, float v2, float v3);
89 void SetFloat4(string name, float v1, float v2, float v3, float v4);
90 void UseFloat(string name, float* v1);
91 void UseFloat2(string name, float* v1, float* v2);
92 void UseFloat3(string name, float* v1, float* v2, float* v3);
93 void UseFloat4(string name, float* v1, float* v2, float* v3, float* v4);
94 void SetInteger(string name, int v1);
95 void SetInteger2(string name, int v1, int v2);
96 void SetInteger3(string name, int v1, int v2, int v3);
97 void SetInteger4(string name, int v1, int v2, int v3, int v4);
98 void UseInteger(string name, int* v1);
99 void UseInteger2(string name, int* v1, int* v2);
100 void UseInteger3(string name, int* v1, int* v2, int* v3);
101 void UseInteger4(string name, int* v1, int* v2, int* v3, int* v4);
102
103 void UseSurface(string name, Surface* surf, int vbo);
104 void UseMatrix(string name, int mode);
105
106 /*void SetParameter1S(string name, float v1);
107 void SetParameter2S(string name, float v1, float v2);
108 void SetParameter3S(string name, float v1, float v2, float v3);
109 void SetParameter4S(string name, float v1, float v2, float v3, float v4);
110 void SetParameter1I(string name, int v1);
111 void SetParameter2I(string name, int v1, int v2);
112 void SetParameter3I(string name, int v1, int v2, int v3);
113 void SetParameter4I(string name, int v1, int v2, int v3, int v4);
114 void SetVector1I(string name, int* v1);
115 void SetVector2I(string name, int* v1);
116 void SetVector3I(string name, int* v1);
117 void SetVector4I(string name, int* v1);
118 void SetParameter1F(string name, float v1);
119 void SetParameter2F(string name, float v1, float v2);
120 void SetParameter3F(string name, float v1, float v2, float v3);
121 void SetParameter4F(string name, float v1, float v2, float v3, float v4);
122 void SetVector1F(string name, float* v1);
123 void SetVector2F(string name, float* v1);
124 void SetVector3F(string name, float* v1);
125 void SetVector4F(string name, float* v1);
126 void SetMatrix2F(string name, float* m);
127 void SetMatrix3F(string name, float* m);
128 void SetMatrix4F(string name, float* m);
129 void SetParameter1D(string name, double v1);
130 void SetParameter2D(string name, double v1, double v2);
131 void SetParameter3D(string name, double v1, double v2, double v3);
132 void SetParameter4D(string name, double v1, double v2, double v3, double v4);*/
133
134 };
135
136 #endif
FreeShader
void FreeShader(Shader *shader)
Definition: functions.cpp:23
UseMatrix
void UseMatrix(Shader *material, char *name, int mode)
Definition: functions.cpp:1925
Sampler::texture
Texture * texture
Definition: shadermat.h:46
SetFloat3
void SetFloat3(Shader *material, char *name, float v1, float v2, float v3)
Definition: functions.cpp:1865
shaderobject.h
Surface
Definition: surface.h:19
SetInteger3
void SetInteger3(Shader *material, char *name, int v1, int v2, int v3)
Definition: functions.cpp:1897
ShaderData::fp
float * fp[4]
Definition: shadermat.h:25
ShaderData::ent
Entity * ent
Definition: shadermat.h:27
ProgramObject
Definition: shaderobject.h:30
ShaderData::name
string name
Definition: shadermat.h:19
Sampler::is3D
int is3D
Definition: shadermat.h:48
texture.h
SetFloat
void SetFloat(Shader *material, char *name, float v1)
Definition: functions.cpp:1857
SetInteger2
void SetInteger2(Shader *material, char *name, int v1, int v2)
Definition: functions.cpp:1893
UseFloat2
void UseFloat2(Shader *material, char *name, float *v1, float *v2)
Definition: functions.cpp:1877
SetInteger4
void SetInteger4(Shader *material, char *name, int v1, int v2, int v3, int v4)
Definition: functions.cpp:1901
Sampler::Name
string Name
Definition: shadermat.h:45
Entity
Definition: entity.h:27
Material
Definition: shadermat.h:35
UseInteger3
void UseInteger3(Shader *material, char *name, int *v1, int *v2, int *v3)
Definition: functions.cpp:1913
matrix.h
SetFloat4
void SetFloat4(Shader *material, char *name, float v1, float v2, float v3, float v4)
Definition: functions.cpp:1869
UseFloat4
void UseFloat4(Shader *material, char *name, float *v1, float *v2, float *v3, float *v4)
Definition: functions.cpp:1885
Sampler
Definition: shadermat.h:43
Texture
Definition: texture.h:23
Matrix
Definition: matrix.h:18
Sampler::Slot
int Slot
Definition: shadermat.h:47
UseInteger4
void UseInteger4(Shader *material, char *name, int *v1, int *v2, int *v3, int *v4)
Definition: functions.cpp:1917
Shader
Definition: shadermat.h:56
UseFloat
void UseFloat(Shader *material, char *name, float *v1)
Definition: functions.cpp:1873
UseInteger2
void UseInteger2(Shader *material, char *name, int *v1, int *v2)
Definition: functions.cpp:1909
ShaderData::ip
int * ip[4]
Definition: shadermat.h:26
ShaderData::type
int type
Definition: shadermat.h:20
ShaderData
Definition: shadermat.h:17
UseInteger
void UseInteger(Shader *material, char *name, int *v1)
Definition: functions.cpp:1905
UseSurface
void UseSurface(Shader *material, char *name, Surface *surf, int vbo)
Definition: functions.cpp:1921
ShaderData::surf
Surface * surf
Definition: shadermat.h:29
SetFloat2
void SetFloat2(Shader *material, char *name, float v1, float v2)
Definition: functions.cpp:1861
UseFloat3
void UseFloat3(Shader *material, char *name, float *v1, float *v2, float *v3)
Definition: functions.cpp:1881
LoadMaterial
Material * LoadMaterial(char *filename, int flags, int frame_width, int frame_height, int first_frame, int frame_count)
Definition: functions.cpp:1929
ShaderData::vbo
int vbo
Definition: shadermat.h:30
SetInteger
void SetInteger(Shader *material, char *name, int v1)
Definition: functions.cpp:1889