raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
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 "./Matrix.hpp"
7#include "./RadiansDegrees.hpp"
8#include "./raylib-cpp-utils.hpp"
9
10namespace raylib {
14class Camera2D : public ::Camera2D {
15 public:
16 Camera2D(const ::Camera2D& camera) {
17 set(camera);
18 }
19
20 Camera2D() {}
21 Camera2D(::Vector2 offset, ::Vector2 target,
22 Degree rotation = 0.0f, float zoom = 1.0f) : ::Camera2D{offset, target, rotation, zoom} {}
23
24 Camera2D& BeginMode() {
25 ::BeginMode2D(*this);
26 return *this;
27 }
28
29 Camera2D& EndMode() {
30 ::EndMode2D();
31 return *this;
32 }
33
34 GETTERSETTER(::Vector2, Offset, offset)
35 GETTERSETTER(::Vector2, Target, target)
36 GETTERSETTER(Degree, Rotation, rotation)
37 GETTERSETTER(float, Zoom, zoom)
38
39 Camera2D& operator=(const ::Camera2D& camera) {
40 set(camera);
41 return *this;
42 }
43
47 Matrix GetMatrix() const {
48 return ::GetCameraMatrix2D(*this);
49 }
50
54 Vector2 GetScreenToWorld(::Vector2 position) const {
55 return ::GetScreenToWorld2D(position, *this);
56 }
57
61 Vector2 GetWorldToScreen(::Vector2 position) const {
62 return ::GetWorldToScreen2D(position, *this);
63 }
64
65 protected:
66 void set(const ::Camera2D& camera) {
67 offset = camera.offset;
68 target = camera.target;
69 rotation = camera.rotation;
70 zoom = camera.zoom;
71 }
72};
73} // namespace raylib
74
76
77#endif // RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
Camera2D type, defines a 2d camera.
Definition: Camera2D.hpp:14
Vector2 GetScreenToWorld(::Vector2 position) const
Returns the world space position for a 2d camera screen space position.
Definition: Camera2D.hpp:54
Matrix GetMatrix() const
Returns camera 2d transform matrix.
Definition: Camera2D.hpp:47
Vector2 GetWorldToScreen(::Vector2 position) const
Returns the screen space position for a 3d world space position.
Definition: Camera2D.hpp:61
Degree type (allows automatic worry free conversion between radians and degrees)
Matrix type (OpenGL style 4x4 - right handed, column major)
Definition: Matrix.hpp:18
Vector2 type.
Definition: Vector2.hpp:19