You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.3 KiB
62 lines
1.3 KiB
#pragma once
|
|
#include "ggl.h"
|
|
|
|
struct UniformTexture {
|
|
GLint mLocation;
|
|
GLuint mTexture;
|
|
UniformTexture() {
|
|
mLocation = -1;
|
|
mTexture = 0;
|
|
}
|
|
};
|
|
|
|
struct UniformTextureCube {
|
|
GLint mLocation;
|
|
GLuint mTexture;
|
|
UniformTextureCube() {
|
|
mLocation = -1;
|
|
mTexture = 0;
|
|
}
|
|
};
|
|
|
|
struct UniformVector4f {
|
|
GLint mLocation;
|
|
float v[4];
|
|
UniformVector4f() {
|
|
mLocation = -1;
|
|
memset(v, 0, sizeof(float) * 4);
|
|
}
|
|
};
|
|
|
|
class Shader {
|
|
public:
|
|
static GLuint CompileShader(GLuint shaderType, const char* shaderCode);
|
|
static GLuint CreateProgram(GLuint vsShader, GLuint fsShader);
|
|
public:
|
|
GLuint mProgram;
|
|
GLint mModelMatrixLocation, mViewMatrixLocation, mProjectionMatrixLocation;
|
|
GLint mPositionLocation, mColorLocation, mTexcoordLocation, mNormalLocation;
|
|
std::map<std::string, UniformTexture*> mUniformTextures;
|
|
std::map<std::string, UniformTextureCube*> mUniformTextureCubes;
|
|
std::map<std::string, UniformVector4f*> mUniformVec4s;
|
|
void Init(const char* vs, const char* fs);
|
|
void Bind(float* M, float* V, float* P);
|
|
void SetTexture(const char* name, const char* imagePath);
|
|
GLuint SetTexture(const char* name, GLuint texture);
|
|
GLuint SetTextureCube(const char * name, GLuint texture);
|
|
void SetVec4(const char * name, float x, float y, float z, float w);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|