|
@ -8,13 +8,23 @@ struct UniformTexture { |
|
|
mTexture = 0; |
|
|
mTexture = 0; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
struct UniformVector4f { |
|
|
|
|
|
GLint mLocation; |
|
|
|
|
|
float v[4]; |
|
|
|
|
|
UniformVector4f() { |
|
|
|
|
|
mLocation = -1; |
|
|
|
|
|
memset(v, 0, sizeof(float) * 4); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
class Shader { |
|
|
class Shader { |
|
|
public: |
|
|
public: |
|
|
GLuint mProgram; |
|
|
GLuint mProgram; |
|
|
std::map<std::string, UniformTexture*> mUniformTextures; |
|
|
std::map<std::string, UniformTexture*> mUniformTextures; |
|
|
|
|
|
std::map<std::string, UniformVector4f*> mUniformVec4s; |
|
|
GLint mModelMatrixLocation, mViewMatrixLocation, mProjectionMatrixLocation; |
|
|
GLint mModelMatrixLocation, mViewMatrixLocation, mProjectionMatrixLocation; |
|
|
GLint mPositionLocation, mColorLocation, mTexcoordLocation, mNormalLocation; |
|
|
GLint mPositionLocation, mColorLocation, mTexcoordLocation, mNormalLocation; |
|
|
void Init(const char*vs, const char*fs); |
|
|
void Init(const char*vs, const char*fs); |
|
|
void Bind(float *M, float *V, float*P); |
|
|
void Bind(float *M, float *V, float*P); |
|
|
void SetTexture(const char * name, const char*imagePath); |
|
|
void SetTexture(const char * name, const char*imagePath); |
|
|
|
|
|
void SetVec4(const char * name, float x, float y, float z, float w); |
|
|
}; |
|
|
}; |