From 3a6e7bbdd373ab189722fd72745ea2f9026af097 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 14 Nov 2024 13:33:56 -0500 Subject: [PATCH] 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