Shader.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. float distanceFromCamera(float x, float y, float z, float lag) const;
  18. bool isInFrustum(float x, float y, float z, float x2, float y2, float z2) const;
  19. const Vector3D& getFront() const;
  20. const Vector3D& getBack() const;
  21. const Vector3D& getRight() const;
  22. const Vector3D& getLeft() const;
  23. const Vector3D& getUp() const;
  24. const Vector3D& getDown() const;
  25. void setTextureEnabled(bool use);
  26. void setColorEnabled(bool use);
  27. void setMixColorEnabled(bool use);
  28. void setMixColor(float r, float g, float b, float a);
  29. void setTextMode();
  30. void setNormalsEnabled(bool use);
  31. void setUseBlending(bool use);
  32. // model matrix operations
  33. void pop();
  34. void push();
  35. void setToIdentity();
  36. void scale(float sx, float sy, float sz);
  37. void translate(float tx, float ty, float tz);
  38. void translateX(float tx);
  39. void translateY(float ty);
  40. void translateZ(float tz);
  41. void translateTo(float tx, float ty, float tz);
  42. void rotate(float xDegrees, float yDegrees, float zDegrees);
  43. void rotateX(float degrees);
  44. void rotateY(float degrees);
  45. void rotateZ(float degrees);
  46. void updateModelMatrix();
  47. private:
  48. Matrix3D proj;
  49. int unifProjMatrix = 0;
  50. Matrix3D view;
  51. int unifViewMatrix = 0;
  52. Matrix3DStack model;
  53. int unifModelMatrix = 0;
  54. Vector3D oldCamera;
  55. Vector3D camera;
  56. float oldLengthAngle;
  57. float lengthAngle;
  58. float oldWidthAngle;
  59. float widthAngle;
  60. Vector3D front;
  61. Vector3D back;
  62. Vector3D right;
  63. Vector3D left;
  64. Vector3D up;
  65. Vector3D down;
  66. Plane3D frustumPlanes[6];
  67. float fovY = 60;
  68. float nearClip = 0.1f;
  69. float farClip = 1000.0f;
  70. int unifUseTexture = 0;
  71. int unifUseColor = 0;
  72. int unifUseMixColor = 0;
  73. int unifMixColorLoc = 0;
  74. int unifUseNormals = 0;
  75. };
  76. #endif