00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #import "string"
00027
00028 #import <OpenGLES/ES2/gl.h>
00029 #import <OpenGLES/ES2/glext.h>
00030
00031 #import "sgDebug.h"
00032 #import "sgBase.h"
00033 #import "sgRessourceManager.h"
00034
00038 class sgShader : public sgBase
00039 {
00040 public:
00045 sgShader();
00046
00053 sgShader(const char *vsfilename, const char *fsfilename);
00054
00059 ~sgShader();
00060
00068 static sgShader *getShader(const char *vsfilename, const char *fsfilename);
00069
00076 static sgShader *getShader(unsigned int shad);
00077
00085 void destroy();
00086
00092 BOOL validateProgram();
00093
00098 unsigned int maxlights;
00099
00104 GLuint program;
00105
00106
00107 unsigned int matproj;
00108 unsigned int matview;
00109 unsigned int matmodel;
00110 unsigned int matnormal;
00111 unsigned int mattex;
00112
00113 unsigned int position;
00114 unsigned int normal;
00115 unsigned int texcoord0;
00116 unsigned int color;
00117
00118 unsigned int mambientloc;
00119 unsigned int mdiffuseloc;
00120 unsigned int mspecularloc;
00121 unsigned int mshininessloc;
00122 unsigned int memissiveloc;
00123 unsigned int malphatestvalue;
00124
00125 unsigned int lambientloc;
00126 unsigned int ldiffuseloc;
00127 unsigned int lspecularloc;
00128 unsigned int lpositionloc;
00129 unsigned int lattenuationloc;
00130
00131 private:
00132 BOOL create(const char *vsfilename, const char *fsfilename);
00133 BOOL compileShader(GLuint *shader, GLenum type, const char *filepath);
00134 BOOL linkProgram(GLuint prog);
00135 void getEngineUniforms();
00136 };