From 70139aed3fb855a3eb17f158a832d3749b53d04f Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Sat, 4 May 2024 15:50:51 +0200 Subject: [PATCH 1/6] added overload for `DrawRoundedLines` This also fixes a compile-time error as the signature of `DrawRectangleRoundedLines()` had changed. --- include/Rectangle.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index c234538d..a3966819 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -80,9 +80,13 @@ class Rectangle : public ::Rectangle { ::DrawRectangleRounded(*this, roundness, segments, color); } + void DrawRoundedLines(float roundness, int segments, ::Color color) const { + ::DrawRectangleRoundedLines(*this, roundness, segments, color); + } + void DrawRoundedLines(float roundness, int segments, float lineThick, ::Color color) const { - ::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color); + ::DrawRectangleRoundedLinesEx(*this, roundness, segments, lineThick, color); } /** From 2b76a33413166f388349dee8ab734438581a4200 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 4 May 2024 15:41:01 -0400 Subject: [PATCH 2/6] Update raylib in the branch --- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 2 +- include/raylib.hpp | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 619e3bc7..3857c066 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.11) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") project (raylib_cpp - VERSION 5.0.1 + VERSION 5.1.0 DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib" HOMEPAGE_URL "https://github.com/robloach/raylib-cpp" LANGUAGES C CXX diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b4093566..ff32fb24 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 ae50bfa2cc569c0f8d5bc4315d39db64005b1b08 + GIT_TAG f1007554a0a8145060797c0aa8169bdaf2c1c6b8 GIT_SHALLOW 1 ) FetchContent_GetProperties(raylib) diff --git a/include/raylib.hpp b/include/raylib.hpp index 1fd071ca..d219f2c7 100644 --- a/include/raylib.hpp +++ b/include/raylib.hpp @@ -24,6 +24,10 @@ extern "C" { #error "raylib-cpp targets raylib 5. Use the `next` branch for the next version of raylib." #endif +#if RAYLIB_VERSION_MINOR < 1 +#error "raylib-cpp targets raylib 5.1 or higher." +#endif + #ifdef __cplusplus } #endif From 1a45d71bfc499e27880e604d119e3fe5fb812bf9 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 4 May 2024 15:43:47 -0400 Subject: [PATCH 3/6] Disable wayland --- .github/workflows/Tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 53fce823..dd02215e 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -43,7 +43,7 @@ jobs: run: sudo apt-get update && sudo apt-get install -y libasound2-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev - name: Configure - run: cmake -B build -S . -DBUILD_TESTING=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic" ${{ matrix.platform.flags }} ${{ matrix.type.flags }} ${{ matrix.config.flags }} + run: cmake -B build -S . -DGLFW_BUILD_WAYLAND=OFF -DBUILD_TESTING=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic" ${{ matrix.platform.flags }} ${{ matrix.type.flags }} ${{ matrix.config.flags }} - name: Build run: cmake --build build From f2ec83838c514b389249d9c00d5ae3024e8e9ec6 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 16 Oct 2024 11:20:57 -0400 Subject: [PATCH 4/6] Update raylib --- examples/CMakeLists.txt | 2 +- projects/CMake/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 884dc494..34303298 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 785ec74 + GIT_TAG 9b3d019 GIT_SHALLOW 1 ) FetchContent_GetProperties(raylib) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index a02607b4..bef41ebe 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -8,7 +8,7 @@ if (NOT raylib_FOUND) FetchContent_Declare( raylib GIT_REPOSITORY https://github.com/raysan5/raylib.git - GIT_TAG 5.0 + GIT_TAG 9b3d019 GIT_SHALLOW 1 ) FetchContent_MakeAvailable(raylib) From 3a6e7bbdd373ab189722fd72745ea2f9026af097 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 14 Nov 2024 13:33:56 -0500 Subject: [PATCH 5/6] Remove duplicate operator statements (#338) * Remove duplicate operator statements * Make raylib not introduce the operators --- examples/CMakeLists.txt | 2 +- include/AudioStream.hpp | 6 +++--- include/AutomationEventList.hpp | 6 +++--- include/Font.hpp | 10 +++++----- include/Image.hpp | 12 ++++++------ include/Material.hpp | 2 +- include/MeshUnmanaged.hpp | 6 ++++++ include/Model.hpp | 6 +++--- include/Music.hpp | 6 +++--- include/RenderTexture.hpp | 2 +- include/ShaderUnmanaged.hpp | 2 +- include/Sound.hpp | 6 +++--- include/TextureUnmanaged.hpp | 8 ++++---- include/Vector2.hpp | 1 + include/Wave.hpp | 6 +++--- include/raymath.hpp | 1 + package.json | 2 +- projects/CMake/CMakeLists.txt | 4 ++-- projects/Doxygen/doxygen-awesome-css | 2 +- tests/raylib_cpp_test.cpp | 4 ++-- 20 files changed, 51 insertions(+), 43 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 34303298..f074f093 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 9b3d019 + GIT_TAG 5e6cdf3 GIT_SHALLOW 1 ) FetchContent_GetProperties(raylib) diff --git a/include/AudioStream.hpp b/include/AudioStream.hpp index d41aa171..5b6217aa 100644 --- a/include/AudioStream.hpp +++ b/include/AudioStream.hpp @@ -88,7 +88,7 @@ class AudioStream : public ::AudioStream { * Unload audio stream and free memory */ void Unload() { - if (IsReady()) { + if (IsValid()) { ::UnloadAudioStream(*this); } } @@ -182,7 +182,7 @@ class AudioStream : public ::AudioStream { /** * Retrieve whether or not the audio stream is ready. */ - bool IsReady() const { return ::IsAudioStreamReady(*this); } + bool IsValid() const { return ::IsAudioStreamValid(*this); } /** * Load audio stream (to stream raw audio pcm data) @@ -192,7 +192,7 @@ class AudioStream : public ::AudioStream { void Load(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels = 2) { Unload(); set(::LoadAudioStream(SampleRate, SampleSize, Channels)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load audio stream"); } } diff --git a/include/AutomationEventList.hpp b/include/AutomationEventList.hpp index 6bdb0991..1c71560b 100644 --- a/include/AutomationEventList.hpp +++ b/include/AutomationEventList.hpp @@ -71,7 +71,7 @@ class AutomationEventList : public ::AutomationEventList { void Load(const char* fileName) { Unload(); set(::LoadAutomationEventList(fileName)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load automation event list"); } } @@ -80,7 +80,7 @@ class AutomationEventList : public ::AutomationEventList { * Update audio stream buffers with data */ void Unload() { - if (!IsReady()) { + if (!IsValid()) { return; } @@ -96,7 +96,7 @@ class AutomationEventList : public ::AutomationEventList { #endif } - bool IsReady() { return events != nullptr; } + bool IsValid() { return events != nullptr; } bool Export(const char* fileName) { return ::ExportAutomationEventList(*this, fileName); } diff --git a/include/Font.hpp b/include/Font.hpp index 4a62567c..2bcda420 100644 --- a/include/Font.hpp +++ b/include/Font.hpp @@ -158,7 +158,7 @@ class Font : public ::Font { */ void Load(const std::string& fileName) { set(::LoadFont(fileName.c_str())); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Font with from file: " + fileName); } } @@ -175,14 +175,14 @@ class Font : public ::Font { */ void Load(const std::string& fileName, int fontSize, int* fontChars, int charCount) { set(::LoadFontEx(fileName.c_str(), fontSize, fontChars, charCount)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Font with from file with font size: " + fileName); } } void Load(const ::Image& image, ::Color key, int firstChar) { set(::LoadFontFromImage(image, key, firstChar)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Font with from image"); } } @@ -195,7 +195,7 @@ class Font : public ::Font { int* fontChars, int charsCount) { set(::LoadFontFromMemory(fileType.c_str(), fileData, dataSize, fontSize, fontChars, charsCount)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Font " + fileType + " with from file data"); } } @@ -203,7 +203,7 @@ class Font : public ::Font { /** * Returns if the font is ready to be used. */ - bool IsReady() const { return ::IsFontReady(*this); } + bool IsValid() const { return ::IsFontValid(*this); } /** * Draw text using font and additional parameters. diff --git a/include/Image.hpp b/include/Image.hpp index c40d3c24..329bc77e 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -208,7 +208,7 @@ class Image : public ::Image { */ void Load(const std::string& fileName) { set(::LoadImage(fileName.c_str())); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Image from file: " + fileName); } } @@ -222,7 +222,7 @@ class Image : public ::Image { */ void Load(const std::string& fileName, int width, int height, int format, int headerSize) { set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Image from file: " + fileName); } } @@ -236,7 +236,7 @@ class Image : public ::Image { */ void Load(const std::string& fileName, int* frames) { set(::LoadImageAnim(fileName.c_str(), frames)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Image from file: " + fileName); } } @@ -250,7 +250,7 @@ class Image : public ::Image { */ void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) { set(::LoadImageFromMemory(fileType.c_str(), fileData, dataSize)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Image data with file type: " + fileType); } } @@ -264,7 +264,7 @@ class Image : public ::Image { */ void Load(const ::Texture2D& texture) { set(::LoadImageFromTexture(texture)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Image from texture."); } } @@ -728,7 +728,7 @@ class Image : public ::Image { * * @return True or false depending on whether the Image has been loaded. */ - bool IsReady() const { return ::IsImageReady(*this); } + bool IsValid() const { return ::IsImageValid(*this); } protected: void set(const ::Image& image) { data = image.data; diff --git a/include/Material.hpp b/include/Material.hpp index f3ca4521..36fac358 100644 --- a/include/Material.hpp +++ b/include/Material.hpp @@ -104,7 +104,7 @@ class Material : public ::Material { /** * Check if material is ready */ - bool IsReady() const { return ::IsMaterialReady(*this); } + bool IsValid() const { return ::IsMaterialValid(*this); } protected: void set(const ::Material& material) { shader = material.shader; diff --git a/include/MeshUnmanaged.hpp b/include/MeshUnmanaged.hpp index 15e09fd4..4a54ba1c 100644 --- a/include/MeshUnmanaged.hpp +++ b/include/MeshUnmanaged.hpp @@ -210,6 +210,12 @@ class MeshUnmanaged : public ::Mesh { * Load model from generated mesh */ operator raylib::Model() { return ::LoadModelFromMesh(*this); } + + /** + * Returns whether or not the Mesh is valid. + */ + bool IsValid() { return ::IsModelValid(*this); } + protected: void set(const ::Mesh& mesh) { vertexCount = mesh.vertexCount; diff --git a/include/Model.hpp b/include/Model.hpp index 8962f0f7..eb412b11 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -183,7 +183,7 @@ class Model : public ::Model { /** * Determines whether or not the Model has data in it. */ - bool IsReady() const { return ::IsModelReady(*this); } + bool IsValid() const { return ::IsModelValid(*this); } /** * Loads a Model from the given file. @@ -192,7 +192,7 @@ class Model : public ::Model { */ void Load(const std::string& fileName) { set(::LoadModel(fileName.c_str())); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Model from " + fileName); } } @@ -204,7 +204,7 @@ class Model : public ::Model { */ void Load(const ::Mesh& mesh) { set(::LoadModelFromMesh(mesh)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Model from Mesh"); } } diff --git a/include/Music.hpp b/include/Music.hpp index 897c4e89..1a90df6a 100644 --- a/include/Music.hpp +++ b/include/Music.hpp @@ -183,7 +183,7 @@ class Music : public ::Music { */ void Load(const std::string& fileName) { set(::LoadMusicStream(fileName.c_str())); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException(TextFormat("Failed to load Music from file: %s", fileName.c_str())); } } @@ -195,7 +195,7 @@ class Music : public ::Music { */ void Load(const std::string& fileType, unsigned char* data, int dataSize) { set(::LoadMusicStreamFromMemory(fileType.c_str(), data, dataSize)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException(TextFormat("Failed to load Music from %s file dat", fileType.c_str())); } } @@ -205,7 +205,7 @@ class Music : public ::Music { * * @return True or false depending on whether the Music has been loaded. */ - bool IsReady() const { return ::IsMusicReady(*this); } + bool IsValid() const { return ::IsMusicValid(*this); } protected: void set(const ::Music& music) { stream = music.stream; diff --git a/include/RenderTexture.hpp b/include/RenderTexture.hpp index c8182c03..9adbb79f 100644 --- a/include/RenderTexture.hpp +++ b/include/RenderTexture.hpp @@ -103,7 +103,7 @@ class RenderTexture : public ::RenderTexture { /** * Retrieves whether or not the render texture is ready. */ - bool IsReady() const { return ::IsRenderTextureReady(*this); } + bool IsValid() const { return ::IsRenderTextureValid(*this); } protected: void set(const ::RenderTexture& renderTexture) { id = renderTexture.id; diff --git a/include/ShaderUnmanaged.hpp b/include/ShaderUnmanaged.hpp index 628cda27..3904acc1 100644 --- a/include/ShaderUnmanaged.hpp +++ b/include/ShaderUnmanaged.hpp @@ -133,7 +133,7 @@ class ShaderUnmanaged : public ::Shader { /** * Retrieves whether or not the shader is ready. */ - bool IsReady() const { return id != 0 && locs != nullptr; } + bool IsValid() const { return ::IsShaderValid(*this); } protected: void set(const ::Shader& shader) { id = shader.id; diff --git a/include/Sound.hpp b/include/Sound.hpp index f7b0ec01..a74f46e9 100644 --- a/include/Sound.hpp +++ b/include/Sound.hpp @@ -164,7 +164,7 @@ class Sound : public ::Sound { */ void Load(const std::string& fileName) { set(::LoadSound(fileName.c_str())); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Sound from file"); } } @@ -176,7 +176,7 @@ class Sound : public ::Sound { */ void Load(const ::Wave& wave) { set(::LoadSoundFromWave(wave)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Wave"); } } @@ -186,7 +186,7 @@ class Sound : public ::Sound { * * @return True or false depending on whether the Sound buffer is loaded. */ - bool IsReady() const { return ::IsSoundReady(*this); } + bool IsValid() const { return ::IsSoundValid(*this); } protected: void set(const ::Sound& sound) { frameCount = sound.frameCount; diff --git a/include/TextureUnmanaged.hpp b/include/TextureUnmanaged.hpp index 241fed50..a7ce9aaa 100644 --- a/include/TextureUnmanaged.hpp +++ b/include/TextureUnmanaged.hpp @@ -96,7 +96,7 @@ class TextureUnmanaged : public ::Texture { */ void Load(const ::Image& image) { set(::LoadTextureFromImage(image)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Texture from Image"); } } @@ -106,7 +106,7 @@ class TextureUnmanaged : public ::Texture { */ void Load(const ::Image& image, int layoutType) { set(::LoadTextureCubemap(image, layoutType)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Texture from Cubemap"); } } @@ -116,7 +116,7 @@ class TextureUnmanaged : public ::Texture { */ void Load(const std::string& fileName) { set(::LoadTexture(fileName.c_str())); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Texture from file: " + fileName); } } @@ -319,7 +319,7 @@ class TextureUnmanaged : public ::Texture { * * @return True or false depending on whether the Texture has data. */ - bool IsReady() const { return id != 0; } + bool IsValid() const { return IsTextureValid(*this); } protected: void set(const ::Texture& texture) { id = texture.id; diff --git a/include/Vector2.hpp b/include/Vector2.hpp index 1834225b..a42eb842 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -140,6 +140,7 @@ class Vector2 : public ::Vector2 { */ Vector2 Divide(const ::Vector2& vector2) const { return Vector2Divide(*this, vector2); } + /** * Divide vector by vector */ diff --git a/include/Wave.hpp b/include/Wave.hpp index ca37f7b7..62c88c73 100644 --- a/include/Wave.hpp +++ b/include/Wave.hpp @@ -172,7 +172,7 @@ class Wave : public ::Wave { */ void Load(const std::string& fileName) { set(::LoadWave(fileName.c_str())); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Wave from file: " + fileName); } } @@ -184,7 +184,7 @@ class Wave : public ::Wave { */ void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) { set(::LoadWaveFromMemory(fileType.c_str(), fileData, dataSize)); - if (!IsReady()) { + if (!IsValid()) { throw RaylibException("Failed to load Wave from file data of type: " + fileType); } } @@ -194,7 +194,7 @@ class Wave : public ::Wave { * * @return True or false depending on whether the wave data has been loaded. */ - bool IsReady() const { return ::IsWaveReady(*this); } + bool IsValid() const { return ::IsWaveValid(*this); } protected: void set(const ::Wave& wave) { frameCount = wave.frameCount; diff --git a/include/raymath.hpp b/include/raymath.hpp index d7f03520..f166488e 100644 --- a/include/raymath.hpp +++ b/include/raymath.hpp @@ -15,6 +15,7 @@ extern "C" { #pragma GCC diagnostic push // These throw a warnings on visual studio, need to check if __GNUC__ is defined to use it. #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif +#define RAYMATH_DISABLE_CPP_OPERATORS #include "raymath.h" // NOLINT #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/package.json b/package.json index 3f9b0d75..615102d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "raylib-cpp", - "version": "5.0.2", + "version": "5.5.0", "description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib", "main": "index.js", "private": true, diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index bef41ebe..8fe355ca 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -8,7 +8,7 @@ if (NOT raylib_FOUND) FetchContent_Declare( raylib GIT_REPOSITORY https://github.com/raysan5/raylib.git - GIT_TAG 9b3d019 + GIT_TAG 5e6cdf3 GIT_SHALLOW 1 ) FetchContent_MakeAvailable(raylib) @@ -18,7 +18,7 @@ endif() find_package(raylib_cpp QUIET) if (NOT raylib_cpp_FOUND) if (NOT DEFINED RAYLIB_CPP_VERSION) - set(RAYLIB_CPP_VERSION v5.0.2) + set(RAYLIB_CPP_VERSION next) endif() include(FetchContent) FetchContent_Declare( diff --git a/projects/Doxygen/doxygen-awesome-css b/projects/Doxygen/doxygen-awesome-css index 40e9b25b..568f56cd 160000 --- a/projects/Doxygen/doxygen-awesome-css +++ b/projects/Doxygen/doxygen-awesome-css @@ -1 +1 @@ -Subproject commit 40e9b25b6174dd3b472d8868f63323a870dfeeb8 +Subproject commit 568f56cde6ac78b6dfcc14acd380b2e745c301ea diff --git a/tests/raylib_cpp_test.cpp b/tests/raylib_cpp_test.cpp index 59fee1b5..45524095 100644 --- a/tests/raylib_cpp_test.cpp +++ b/tests/raylib_cpp_test.cpp @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) { { // Loading raylib::Image image(path + "/resources/feynman.png"); - Assert(image.IsReady()); + Assert(image.IsValid()); // Chaining image.Crop(100, 100).Resize(50, 50); @@ -108,7 +108,7 @@ int main(int argc, char* argv[]) { // Wave { raylib::Wave wave(path + "/resources/weird.wav"); - Assert(wave.IsReady(), "Expected wave to be loaded correctly"); + Assert(wave.IsValid(), "Expected wave to be loaded correctly"); } // RaylibException From 96aaff597ad9a43d8f7c7dcd6c4e1c079bb87166 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 18 Nov 2024 18:22:55 -0500 Subject: [PATCH 6/6] Update to raylib 5.5 --- clib.json | 2 +- examples/CMakeLists.txt | 2 +- include/Camera3D.hpp | 7 +++++++ include/Color.hpp | 11 +++++++++++ include/Gamepad.hpp | 7 +++++++ include/Image.hpp | 26 ++++++++++++++++++++++++++ include/MeshUnmanaged.hpp | 11 +++++++++++ include/Model.hpp | 22 ++++++++++++++++++++++ include/ModelAnimation.hpp | 8 ++++++++ include/Rectangle.hpp | 12 ++---------- 10 files changed, 96 insertions(+), 12 deletions(-) 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 } /**