raylib-cpp
C++ object-oriented wrapper library for raylib.
Camera2D.hpp
1 #ifndef RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
2 #define RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
3 
4 #include "./raylib.hpp"
5 #include "./Vector2.hpp"
6 #include "./raylib-cpp-utils.hpp"
7 
8 namespace raylib {
12 class Camera2D : public ::Camera2D {
13  public:
14  Camera2D() {}
15  Camera2D(const ::Camera2D& camera) {
16  set(camera);
17  }
18 
19  Camera2D(::Vector2 offsetValue, ::Vector2 targetValue, float rotationValue = 0,
20  float zoomValue = 1) {
21  offset = offsetValue;
22  target = targetValue;
23  rotation = rotationValue;
24  zoom = zoomValue;
25  }
26 
27  inline Camera2D& BeginMode() {
28  ::BeginMode2D(*this);
29  return *this;
30  }
31 
32  inline Camera2D& EndMode() {
33  ::EndMode2D();
34  return *this;
35  }
36 
37  GETTERSETTER(::Vector2, Offset, offset)
38  GETTERSETTER(::Vector2, Target, target)
39  GETTERSETTER(float, Rotation, rotation)
40  GETTERSETTER(float, Zoom, zoom)
41 
42  Camera2D& operator=(const ::Camera2D& camera) {
43  set(camera);
44  return *this;
45  }
46 
50  inline Matrix GetMatrix() const {
51  return ::GetCameraMatrix2D(*this);
52  }
53 
57  inline Vector2 GetWorldToScreen(::Vector2 position) const {
58  return ::GetWorldToScreen2D(position, *this);
59  }
60 
64  inline Vector2 GetScreenToWorld(::Vector2 position) const {
65  return ::GetScreenToWorld2D(position, *this);
66  }
67 
68  private:
69  inline void set(const ::Camera2D& camera) {
70  offset = camera.offset;
71  target = camera.target;
72  rotation = camera.rotation;
73  zoom = camera.zoom;
74  }
75 };
76 } // namespace raylib
77 
78 #endif // RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
raylib
All raylib-cpp classes and functions appear in the raylib namespace.
Definition: AudioDevice.hpp:7
raylib::Matrix
Matrix type (OpenGL style 4x4 - right handed, column major)
Definition: Matrix.hpp:16
raylib::Camera2D::GetScreenToWorld
Vector2 GetScreenToWorld(::Vector2 position) const
Returns the world space position for a 2d camera screen space position.
Definition: Camera2D.hpp:64
raylib::Camera2D::GetMatrix
Matrix GetMatrix() const
Returns camera 2d transform matrix.
Definition: Camera2D.hpp:50
raylib::Camera2D
Camera2D type, defines a 2d camera.
Definition: Camera2D.hpp:12
raylib::Vector2
Vector2 type.
Definition: Vector2.hpp:16
raylib::Camera2D::GetWorldToScreen
Vector2 GetWorldToScreen(::Vector2 position) const
Returns the screen space position for a 3d world space position.
Definition: Camera2D.hpp:57