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.

34 lines
934 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #pragma once
  2. #include "ggl.h"
  3. struct UniformTexture {
  4. GLint mLocation;
  5. GLuint mTexture;
  6. UniformTexture() {
  7. mLocation = -1;
  8. mTexture = 0;
  9. }
  10. };
  11. struct UniformVector4f {
  12. GLint mLocation;
  13. float v[4];
  14. UniformVector4f() {
  15. mLocation = -1;
  16. memset(v, 0, sizeof(float) * 4);
  17. }
  18. };
  19. class Shader {
  20. public:
  21. GLuint mProgram;
  22. GLuint mPosition;
  23. GLuint mColor;
  24. GLuint mTexcoord;
  25. GLuint mNormal;
  26. std::map<std::string, UniformTexture*> mUniformTextures;
  27. std::map<std::string, UniformVector4f*> mUniformVec4s;
  28. GLint mModelMatrixLocation, mViewMatrixLocation, mProjectionMatrixLocation;
  29. GLint mPositionLocation, mColorLocation, mTexcoordLocation, mNormalLocation;
  30. void Init(const char*vs, const char*fs);
  31. void Bind(float *M, float *V, float*P);
  32. void SetTexture(const char * name, const char*imagePath);
  33. void SetTexture(const char * name, GLuint texture);
  34. void SetVec4(const char * name, float x, float y, float z, float w);
  35. };