Shader.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef CAMERA_H
  2. #define CAMERA_H
  3. #include "../math/Plane3D.h"
  4. #include "../math/Vector3D.h"
  5. #include "../math/Matrix3D.h"
  6. #include "../math/Matrix3DStack.h"
  7. class Shader
  8. {
  9. public:
  10. Shader();
  11. Shader(const Shader& orig);
  12. virtual ~Shader();
  13. void set3DMode(float lag);
  14. void set2DMode();
  15. void storeCamera();
  16. void setCamera(float x, float y, float z, float length, float width);
  17. bool isInFrustum(float x, float y, float z, float x2, float y2, float z2) const;
  18. const Vector3D& getFront() const;
  19. const Vector3D& getBack() const;
  20. const Vector3D& getRight() const;
  21. const Vector3D& getLeft() const;
  22. const Vector3D& getUp() const;
  23. const Vector3D& getDown() const;
  24. void setTextureEnabled(bool use);
  25. void setColorEnabled(bool use);
  26. void setMixColorEnabled(bool use);
  27. void setMixColor(float r, float g, float b, float a);
  28. void setTextMode();
  29. void setNormalsEnabled(bool use);
  30. void setUseBlending(bool use);
  31. // model matrix operations
  32. void pop();
  33. void push();
  34. void setToIdentity();
  35. void scale(float sx, float sy, float sz);
  36. void translate(float tx, float ty, float tz);
  37. void translateX(float tx);
  38. void translateY(float ty);
  39. void translateZ(float tz);
  40. void translateTo(float tx, float ty, float tz);
  41. void rotate(float xDegrees, float yDegrees, float zDegrees);
  42. void rotateX(float degrees);
  43. void rotateY(float degrees);
  44. void rotateZ(float degrees);
  45. void updateModelMatrix();
  46. private:
  47. Matrix3D proj;
  48. int unifProjMatrix = 0;
  49. Matrix3D view;
  50. int unifViewMatrix = 0;
  51. Matrix3DStack model;
  52. int unifModelMatrix = 0;
  53. Vector3D oldCamera;
  54. Vector3D camera;
  55. float oldLengthAngle;
  56. float lengthAngle;
  57. float oldWidthAngle;
  58. float widthAngle;
  59. Vector3D front;
  60. Vector3D back;
  61. Vector3D right;
  62. Vector3D left;
  63. Vector3D up;
  64. Vector3D down;
  65. Plane3D frustumPlanes[6];
  66. float fovY = 60;
  67. float nearClip = 0.1f;
  68. float farClip = 1000.0f;
  69. int unifUseTexture = 0;
  70. int unifUseColor = 0;
  71. int unifUseMixColor = 0;
  72. int unifMixColorLoc = 0;
  73. int unifUseNormals = 0;
  74. };
  75. #endif