Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #pragma once
  2. #include <GL/glut.h>
  3.  
  4. class Daylight
  5. {
  6. public:
  7. Daylight(GLenum light);
  8. ~Daylight();
  9. void update(bool isEnabled);
  10.  
  11. private:
  12. GLenum m_light;
  13. float m_x = 0.0f;
  14. float m_y = 1.0f;
  15. float m_z = 0.0f;
  16. float m_w = 0.0f;
  17. };
  18.  
  19. Daylight::Daylight(GLenum light)
  20. {
  21. m_light = light;
  22.  
  23. float diffuse[4] = { 0.75f, 0.75f, 0.75f, 1.0f };
  24. glLightfv(m_light, GL_DIFFUSE, diffuse);
  25. }
  26.  
  27.  
  28. Daylight::~Daylight()
  29. {
  30. }
  31.  
  32. void Daylight::update(bool isEnabled)
  33. {
  34. if (!isEnabled)
  35. {
  36. glDisable(m_light);
  37. return;
  38. }
  39.  
  40. GLfloat pos[4] = { m_x, m_y, m_z, m_w };
  41. glLightfv(m_light, GL_POSITION, pos);
  42.  
  43. glEnable(m_light);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement