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(const ::Camera2D& camera) {
15  set(camera);
16  }
17 
18  Camera2D() {}
19  Camera2D(::Vector2 offset, ::Vector2 target,
20  float rotation = 0.0f, float zoom = 1.0f) : ::Camera2D{offset, target, rotation, zoom} {}
21 
22  inline Camera2D& BeginMode() {
23  ::BeginMode2D(*this);
24  return *this;
25  }
26 
27  inline Camera2D& EndMode() {
28  ::EndMode2D();
29  return *this;
30  }
31 
32  GETTERSETTER(::Vector2, Offset, offset)
33  GETTERSETTER(::Vector2, Target, target)
34  GETTERSETTER(float, Rotation, rotation)
35  GETTERSETTER(float, Zoom, zoom)
36 
37  Camera2D& operator=(const ::Camera2D& camera) {
38  set(camera);
39  return *this;
40  }
41 
45  inline Matrix GetMatrix() const {
46  return ::GetCameraMatrix2D(*this);
47  }
48 
52  inline Vector2 GetWorldToScreen(::Vector2 position) const {
53  return ::GetWorldToScreen2D(position, *this);
54  }
55 
59  inline Vector2 GetScreenToWorld(::Vector2 position) const {
60  return ::GetScreenToWorld2D(position, *this);
61  }
62 
63  private:
64  inline void set(const ::Camera2D& camera) {
65  offset = camera.offset;
66  target = camera.target;
67  rotation = camera.rotation;
68  zoom = camera.zoom;
69  }
70 };
71 } // namespace raylib
72 
73 #endif // RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
raylib
All raylib-cpp classes and functions appear in the raylib namespace.
Definition: AudioDevice.hpp:8
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:59
raylib::Camera2D::GetMatrix
Matrix GetMatrix() const
Returns camera 2d transform matrix.
Definition: Camera2D.hpp:45
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:52