* Camera2D type, defines a 2d camera */
| 10 | * Camera2D type, defines a 2d camera |
| 11 | */ |
| 12 | class Camera2D : public ::Camera2D { |
| 13 | public: |
| 14 | Camera2D(const ::Camera2D& camera) |
| 15 | : ::Camera2D(camera) { |
| 16 | // Nothing. |
| 17 | } |
| 18 | |
| 19 | Camera2D(::Vector2 offset = {}, ::Vector2 target = {}, float rotation = 0.0f, float zoom = 1.0f) |
| 20 | : ::Camera2D{offset, target, rotation, zoom} {} |
| 21 | |
| 22 | Camera2D& BeginMode() { |
| 23 | ::BeginMode2D(*this); |
| 24 | return *this; |
| 25 | } |
| 26 | |
| 27 | 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 | |
| 42 | /** |
| 43 | * Returns camera 2d transform matrix |
| 44 | */ |
| 45 | RLCPP_NODISCARD Matrix GetMatrix() const { return ::GetCameraMatrix2D(*this); } |
| 46 | |
| 47 | /** |
| 48 | * Returns the world space position for a 2d camera screen space position |
| 49 | */ |
| 50 | RLCPP_NODISCARD Vector2 GetScreenToWorld(::Vector2 position) const { return ::GetScreenToWorld2D(position, *this); } |
| 51 | |
| 52 | /** |
| 53 | * Returns the screen space position for a 2d world space position |
| 54 | */ |
| 55 | RLCPP_NODISCARD Vector2 GetWorldToScreen(::Vector2 position) const { return ::GetWorldToScreen2D(position, *this); } |
| 56 | protected: |
| 57 | void set(const ::Camera2D& camera) { |
| 58 | offset = camera.offset; |
| 59 | target = camera.target; |
| 60 | rotation = camera.rotation; |
| 61 | zoom = camera.zoom; |
| 62 | } |
| 63 | }; |
| 64 | } // namespace raylib |
| 65 | |
| 66 | using RCamera2D = raylib::Camera2D; |
nothing calls this directly
no outgoing calls
no test coverage detected