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 "./Vector2.hpp"
5#include "./Matrix.hpp"
6#include "./RadiansDegrees.hpp"
7#include "./raylib-cpp-utils.hpp"
8#include "./raylib.hpp"
9
10namespace raylib {
14class Camera2D : public ::Camera2D {
15public:
16 Camera2D(const ::Camera2D& camera)
17 : ::Camera2D(camera) {
18 // Nothing.
19 }
20
21 Camera2D() {}
22 Camera2D(::Vector2 offset, ::Vector2 target,
23 Degree rotation = 0.0f, float zoom = 1.0f) : ::Camera2D{offset, target, rotation, zoom} {}
24
25 Camera2D& BeginMode() {
26 ::BeginMode2D(*this);
27 return *this;
28 }
29
30 Camera2D& EndMode() {
31 ::EndMode2D();
32 return *this;
33 }
34
35 GETTERSETTER(::Vector2, Offset, offset)
36 GETTERSETTER(::Vector2, Target, target)
37 GETTERSETTER(Degree, Rotation, rotation)
38 GETTERSETTER(float, Zoom, zoom)
39
40 Camera2D& operator=(const ::Camera2D& camera) {
41 set(camera);
42 return *this;
43 }
44
48 [[nodiscard]] Matrix GetMatrix() const { return ::GetCameraMatrix2D(*this); }
49
53 [[nodiscard]] Vector2 GetScreenToWorld(::Vector2 position) const { return ::GetScreenToWorld2D(position, *this); }
54
58 [[nodiscard]] Vector2 GetWorldToScreen(::Vector2 position) const { return ::GetWorldToScreen2D(position, *this); }
59protected:
60 void set(const ::Camera2D& camera) {
61 offset = camera.offset;
62 target = camera.target;
63 rotation = camera.rotation;
64 zoom = camera.zoom;
65 }
66};
67} // namespace raylib
68
70
71#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:53
Matrix GetMatrix() const
Returns camera 2d transform matrix.
Definition: Camera2D.hpp:48
Vector2 GetWorldToScreen(::Vector2 position) const
Returns the screen space position for a 2d world space position.
Definition: Camera2D.hpp:58
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:20
All raylib-cpp classes and functions appear in the raylib namespace.
Definition: AudioDevice.hpp:8