projection.cpp 783 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "projection.h"
  2. #include "../../core.h"
  3. using namespace wp::core::scenes;
  4. projection::projection (irr::u32 width, irr::u32 height) :
  5. m_width (width),
  6. m_height (height)
  7. {
  8. }
  9. irr::u32 projection::getWidth ()
  10. {
  11. return this->m_width;
  12. }
  13. irr::u32 projection::getHeight ()
  14. {
  15. return this->m_height;
  16. }
  17. projection* projection::fromJSON (json data)
  18. {
  19. json::const_iterator width_it = data.find ("width");
  20. json::const_iterator height_it = data.find ("height");
  21. if (width_it == data.end ())
  22. {
  23. throw std::runtime_error ("Projection must have width");
  24. }
  25. if (height_it == data.end ())
  26. {
  27. throw std::runtime_error ("Projection must have height");
  28. }
  29. return new projection (
  30. *width_it,
  31. *height_it
  32. );
  33. }