diff --git a/clib.json b/clib.json index bbdd1cc9..66e52e15 100644 --- a/clib.json +++ b/clib.json @@ -1,6 +1,6 @@ { "name": "raylib-cpp", - "version": "5.0.1", + "version": "5.5.0", "repo": "RobLoach/raylib-cpp", "description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib", "homepage": "https://github.com/robloach/raylib-cpp", diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f074f093..6f4c3681 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -15,7 +15,7 @@ if (NOT raylib_FOUND) FetchContent_Declare( raylib GIT_REPOSITORY https://github.com/raysan5/raylib.git - GIT_TAG 5e6cdf3 + GIT_TAG 5.5 GIT_SHALLOW 1 ) FetchContent_GetProperties(raylib) diff --git a/include/Camera3D.hpp b/include/Camera3D.hpp index feb5a796..784692b9 100644 --- a/include/Camera3D.hpp +++ b/include/Camera3D.hpp @@ -91,6 +91,13 @@ class Camera3D : public ::Camera3D { */ Vector2 GetWorldToScreen(::Vector3 position) const { return ::GetWorldToScreen(position, *this); } + /** + * Get a ray trace from screen position (i.e mouse) in a viewport + */ + Ray GetScreenToWorldRay(::Vector2 position, int width, int height) { + return ::GetScreenToWorldRayEx(position, *this, width, height); + } + /** * Draw a billboard texture. */ diff --git a/include/Color.hpp b/include/Color.hpp index 0f084d08..b01bb216 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -181,6 +181,13 @@ class Color : public ::Color { void DrawRectangleLines(::Rectangle rec, float lineThick) const { ::DrawRectangleLinesEx(rec, lineThick, *this); } + bool IsEqual(::Color color) { + return ::ColorIsEqual(*this, color); + } + + bool operator==(const ::Color& other) const { return ::ColorIsEqual(*this, other); } + bool operator!=(const ::Color& other) const { return !::ColorIsEqual(*this, other); } + /** * Get color multiplied with another color */ @@ -201,6 +208,10 @@ class Color : public ::Color { */ Color Alpha(float alpha) const { return ::ColorAlpha(*this, alpha); } + Color Lerp(::Color color2, float factor) { + return ::ColorLerp(*this, color2, factor); + } + /** * Returns src alpha-blended into dst color with tint */ diff --git a/include/Gamepad.hpp b/include/Gamepad.hpp index 4c76d63d..27588f05 100644 --- a/include/Gamepad.hpp +++ b/include/Gamepad.hpp @@ -85,6 +85,13 @@ class Gamepad { float GetAxisMovement(int axis) const { return ::GetGamepadAxisMovement(number, axis); } int SetMappings(const std::string& mappings) { return SetGamepadMappings(mappings.c_str()); } + + /** + * Set gamepad vibration for both motors (duration in seconds) + */ + void SetVibration(float leftMotor, float rightMotor, float duration) { + ::SetGamepadVibration(number, leftMotor, rightMotor, duration); + } protected: void set(int gamepadNumber) { number = gamepadNumber; } }; diff --git a/include/Image.hpp b/include/Image.hpp index 329bc77e..c3d40336 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -164,6 +164,11 @@ class Image : public ::Image { */ static ::Image Cellular(int width, int height, int tileSize) { return ::GenImageCellular(width, height, tileSize); } + /** + * Get clipboard image content. + */ + static ::Image GetClipboard() { return ::GetClipboardImage(); } + ~Image() { Unload(); } Image& operator=(const ::Image& image) { @@ -605,6 +610,13 @@ class Image : public ::Image { ::ImageDrawLineV(this, start, end, color); } + /** + * Description: Draw a line defining thickness within an image + */ + void DrawLine(::Vector2 start, ::Vector2 end, int thick, ::Color color = {255, 255, 255, 255}) { + ImageDrawLineEx(this, start, end, thick, color); + } + void DrawCircle(int centerX, int centerY, int radius, ::Color color = {255, 255, 255, 255}) { ::ImageDrawCircle(this, centerX, centerY, radius, color); } @@ -629,6 +641,8 @@ class Image : public ::Image { ::ImageDrawRectangleLines(this, rec, thick, color); } + // TODO: Add ImageDrawTriangle() + void Draw(const ::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = {255, 255, 255, 255}) { ::ImageDraw(this, src, srcRec, dstRec, tint); } @@ -729,6 +743,18 @@ class Image : public ::Image { * @return True or false depending on whether the Image has been loaded. */ bool IsValid() const { return ::IsImageValid(*this); } + + /** + * Create an image from a selected channel of another image (GRAYSCALE) + */ + ::Image Channel(int selectedChannel) { return ::ImageFromChannel(*this, selectedChannel); } + + /** + * Apply custom square convolution kernel to image + */ + void KernelConvolution(const float* kernel, int kernelSize) { + ::ImageKernelConvolution(this, kernel, kernelSize); + } protected: void set(const ::Image& image) { data = image.data; diff --git a/include/MeshUnmanaged.hpp b/include/MeshUnmanaged.hpp index 4a54ba1c..fa176a0a 100644 --- a/include/MeshUnmanaged.hpp +++ b/include/MeshUnmanaged.hpp @@ -183,6 +183,17 @@ class MeshUnmanaged : public ::Mesh { } } + /** + * Export mesh as code file (.h) defining multiple arrays of vertex attributes + * + * @throws raylib::RaylibException Throws if failed to export the Mesh. + */ + void ExportCode(const std::string& fileName) { + if (!::ExportMeshAsCode(*this, fileName.c_str())) { + throw RaylibException("Failed to export the Mesh"); + } + } + /** * Compute mesh bounding box limits */ diff --git a/include/Model.hpp b/include/Model.hpp index eb412b11..f1359de4 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -127,6 +127,14 @@ class Model : public ::Model { return *this; } + /** + * Update model animation pose + */ + Model& UpdateAnimationBones(const ::ModelAnimation& anim, int frame) { + ::UpdateModelAnimationBones(*this, anim, frame); + return *this; + } + /** * Check model animation skeleton match */ @@ -170,6 +178,20 @@ class Model : public ::Model { ::DrawModelWiresEx(*this, position, rotationAxis, rotationAngle, scale, tint); } + /** + * Draw a model as points + */ + void DrawPoints(::Vector3 position, float scale = 1.0f, ::Color tint = {255, 255, 255, 255}) { + ::DrawModelPoints(*this, position, scale, tint); + } + + /** + * Draw a model as points + */ + void DrawPoints(::Vector3 position, ::Vector3 rotationAxis, float rotationAngle = 0.0f, ::Vector3 scale = {1.0f, 1.0f, 1.0f}, ::Color tint = {255, 255, 255, 255}) { + ::DrawModelPointsEx(*this, position, rotationAxis, rotationAngle, scale, tint); + } + /** * Compute model bounding box limits (considers all meshes) */ diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index ef44fe26..76a690cb 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -83,6 +83,14 @@ class ModelAnimation : public ::ModelAnimation { return *this; } + /** + * Update model animation mesh bone matrices (GPU skinning) + */ + ModelAnimation& UpdateBones(const ::Model& model, int frame) { + ::UpdateModelAnimationBones(model, *this, frame); + return *this; + } + /** * Check model animation skeleton match */ diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 44a5ba74..439a0363 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -66,8 +66,8 @@ class Rectangle : public ::Rectangle { color2); } - void DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) const { - ::DrawRectangleGradientEx(*this, col1, col2, col3, col4); + void DrawGradient(::Color topLeft, ::Color bottomLeft, ::Color topRight, ::Color bottomRight) const { + ::DrawRectangleGradientEx(*this, topLeft, bottomLeft, topRight, bottomRight); } void DrawLines(::Color color) const { @@ -86,19 +86,11 @@ class Rectangle : public ::Rectangle { } void DrawRoundedLines(float roundness, int segments, ::Color color) const { -#if RAYLIB_VERSION_MAJOR == 5 && RAYLIB_VERSION_MINOR == 0 - ::DrawRectangleRoundedLines(*this, roundness, segments, 1.0f, color); -#else ::DrawRectangleRoundedLines(*this, roundness, segments, color); -#endif } void DrawRoundedLines(float roundness, int segments, float lineThick, ::Color color) const { -#if RAYLIB_VERSION_MAJOR == 5 && RAYLIB_VERSION_MINOR == 0 - ::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color); -#else DrawRectangleRoundedLinesEx(*this, roundness, segments, lineThick, color); -#endif } /**