Viewport.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "Base.h"
  2. #include "Viewport.h"
  3. namespace gameplay
  4. {
  5. Viewport::Viewport()
  6. {
  7. }
  8. Viewport::Viewport(int x, int y, int width, int height)
  9. {
  10. set(x, y, width, height);
  11. }
  12. Viewport::Viewport(const Viewport& viewport)
  13. {
  14. set(viewport);
  15. }
  16. Viewport::~Viewport()
  17. {
  18. }
  19. void Viewport::set(int x, int y, int width, int height)
  20. {
  21. _x = x;
  22. _y = y;
  23. _width = width;
  24. _height = height;
  25. }
  26. void Viewport::set(const Viewport& viewport)
  27. {
  28. _x = viewport._x;
  29. _y = viewport._y;
  30. _width = viewport._width;
  31. _height = viewport._height;
  32. }
  33. int Viewport::getX() const
  34. {
  35. return _x;
  36. }
  37. void Viewport::setX(int x)
  38. {
  39. _x = x;
  40. }
  41. int Viewport::getY() const
  42. {
  43. return _y;
  44. }
  45. void Viewport::setY(int y)
  46. {
  47. _y = y;
  48. }
  49. int Viewport::getWidth() const
  50. {
  51. return _width;
  52. }
  53. void Viewport::setWidth(int width)
  54. {
  55. _width = width;
  56. }
  57. int Viewport::getHeight() const
  58. {
  59. return _height;
  60. }
  61. void Viewport::setHeight(int height)
  62. {
  63. _height = height;
  64. }
  65. void Viewport::bind()
  66. {
  67. GL_ASSERT( glViewport(_x, _y, _width, _height) );
  68. }
  69. }