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.

29 lines
810 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 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. std::map<std::string, UniformTexture*> mUniformTextures;
  23. std::map<std::string, UniformVector4f*> mUniformVec4s;
  24. GLint mModelMatrixLocation, mViewMatrixLocation, mProjectionMatrixLocation;
  25. GLint mPositionLocation, mColorLocation, mTexcoordLocation, mNormalLocation;
  26. void Init(const char*vs, const char*fs);
  27. void Bind(float *M, float *V, float*P);
  28. void SetTexture(const char * name, const char*imagePath);
  29. void SetVec4(const char * name, float x, float y, float z, float w);
  30. };