diff --git a/CMakeLists.txt b/CMakeLists.txt index bc49c3a8..cf8ea4de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,3 +56,10 @@ if(BUILD_RAYLIB_CPP_EXAMPLES) ) endif() endif() + +# ignore unused functions +if (MSVC) + target_compile_options(raylib_cpp INTERFACE /wd4505) +else() + target_compile_options(raylib_cpp INTERFACE -Wno-unused-function) +endif() diff --git a/examples/shaders/shaders_basic_lighting.cpp b/examples/shaders/shaders_basic_lighting.cpp index 1ef00ce5..aa4f7e7e 100644 --- a/examples/shaders/shaders_basic_lighting.cpp +++ b/examples/shaders/shaders_basic_lighting.cpp @@ -48,9 +48,9 @@ int main(void) // Define the camera to look into our 3d world raylib::Camera camera; - camera.position = (Vector3){ 2.0f, 4.0f, 6.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) + camera.position = Vector3{ 2.0f, 4.0f, 6.0f }; // Camera position + camera.target = Vector3{ 0.0f, 0.5f, 0.0f }; // Camera looking at point + camera.up = Vector3{ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 45.0f; // Camera field-of-view Y camera.projection = CAMERA_PERSPECTIVE; // Camera projection type @@ -70,10 +70,10 @@ int main(void) // Create lights std::array lights = { - CreateLight(LIGHT_POINT, (Vector3) {-2, 1, -2}, Vector3Zero(), YELLOW, shader), - CreateLight(LIGHT_POINT, (Vector3) {2, 1, 2}, Vector3Zero(), RED, shader), - CreateLight(LIGHT_POINT, (Vector3) {-2, 1, 2}, Vector3Zero(), GREEN, shader), - CreateLight(LIGHT_POINT, (Vector3) {2, 1, -2}, Vector3Zero(), BLUE, shader), + CreateLight(LIGHT_POINT, Vector3 {-2, 1, -2}, Vector3Zero(), YELLOW, shader), + CreateLight(LIGHT_POINT, Vector3 {2, 1, 2}, Vector3Zero(), RED, shader), + CreateLight(LIGHT_POINT, Vector3 {-2, 1, 2}, Vector3Zero(), GREEN, shader), + CreateLight(LIGHT_POINT, Vector3 {2, 1, -2}, Vector3Zero(), BLUE, shader), }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second @@ -110,7 +110,7 @@ int main(void) BeginShaderMode(shader); - DrawPlane(Vector3Zero(), (Vector2) { 10.0, 10.0 }, WHITE); + DrawPlane(Vector3Zero(), Vector2 { 10.0, 10.0 }, WHITE); DrawCube(Vector3Zero(), 2.0, 4.0, 2.0, WHITE); EndShaderMode(); diff --git a/examples/shaders/shaders_basic_pbr.cpp b/examples/shaders/shaders_basic_pbr.cpp index 3afeb8ff..04c2deac 100644 --- a/examples/shaders/shaders_basic_pbr.cpp +++ b/examples/shaders/shaders_basic_pbr.cpp @@ -88,9 +88,9 @@ int main() // Define the camera to look into our 3d world raylib::Camera camera; - camera.position = (Vector3){ 2.0f, 2.0f, 6.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) + camera.position = Vector3{ 2.0f, 2.0f, 6.0f }; // Camera position + camera.target = Vector3{ 0.0f, 0.5f, 0.0f }; // Camera looking at point + camera.up = Vector3{ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 45.0f; // Camera field-of-view Y camera.projection = CAMERA_PERSPECTIVE; // Camera projection type @@ -117,8 +117,8 @@ int main() // Setup ambient color and intensity parameters float ambientIntensity = 0.02f; - raylib::Color ambientColor = (Color){ 26, 32, 135, 255 }; - raylib::Vector3 ambientColorNormalized = (Vector3){ ambientColor.r/255.0f, ambientColor.g/255.0f, ambientColor.b/255.0f }; + raylib::Color ambientColor = Color{ 26, 32, 135, 255 }; + raylib::Vector3 ambientColorNormalized = Vector3{ ambientColor.r/255.0f, ambientColor.g/255.0f, ambientColor.b/255.0f }; shader.SetValue(shader.GetLocation("ambientColor"), &ambientColorNormalized, SHADER_UNIFORM_VEC3); shader.SetValue(shader.GetLocation("ambient"), &ambientIntensity, SHADER_UNIFORM_FLOAT); @@ -142,7 +142,7 @@ int main() car.materials[0].maps[MATERIAL_MAP_METALNESS].value = 0.0f; car.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value = 0.0f; car.materials[0].maps[MATERIAL_MAP_OCCLUSION].value = 1.0f; - car.materials[0].maps[MATERIAL_MAP_EMISSION].color = (Color){ 255, 162, 0, 255 }; + car.materials[0].maps[MATERIAL_MAP_EMISSION].color = Color{ 255, 162, 0, 255 }; // Setup materials[0].maps default textures car.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("resources/old_car_d.png"); @@ -172,15 +172,15 @@ int main() // Models texture tiling parameter can be stored in the Material struct if required (CURRENTLY NOT USED) // NOTE: Material.params[4] are available for generic parameters storage (float) - Vector2 carTextureTiling = (Vector2){ 0.5f, 0.5f }; - Vector2 floorTextureTiling = (Vector2){ 0.5f, 0.5f }; + Vector2 carTextureTiling = Vector2{ 0.5f, 0.5f }; + Vector2 floorTextureTiling = Vector2{ 0.5f, 0.5f }; // Create some lights std::array lights = { - CreateLight(0, LightType::POINT, (Vector3) {-1.0f, 1.0f, -2.0f}, (Vector3) {0.0f, 0.0f, 0.0f}, YELLOW, 4.0f, shader), - CreateLight(1, LightType::POINT, (Vector3){ 2.0f, 1.0f, 1.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, GREEN, 3.3f, shader), - CreateLight(2, LightType::POINT, (Vector3){ -2.0f, 1.0f, 1.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, RED, 8.3f, shader), - CreateLight(3, LightType::POINT, (Vector3){ 1.0f, 1.0f, -2.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, BLUE, 2.0f, shader), + CreateLight(0, LightType::POINT, Vector3{-1.0f, 1.0f, -2.0f}, Vector3{0.0f, 0.0f, 0.0f}, YELLOW, 4.0f, shader), + CreateLight(1, LightType::POINT, Vector3{ 2.0f, 1.0f, 1.0f }, Vector3{ 0.0f, 0.0f, 0.0f }, GREEN, 3.3f, shader), + CreateLight(2, LightType::POINT, Vector3{ -2.0f, 1.0f, 1.0f }, Vector3{ 0.0f, 0.0f, 0.0f }, RED, 8.3f, shader), + CreateLight(3, LightType::POINT, Vector3{ 1.0f, 1.0f, -2.0f }, Vector3{ 0.0f, 0.0f, 0.0f }, BLUE, 2.0f, shader), }; // Setup material texture maps usage in shader @@ -228,7 +228,7 @@ int main() raylib::Vector4 floorEmissiveColor = ColorNormalize(floor.materials[0].maps[MATERIAL_MAP_EMISSION].color); SetShaderValue(shader, emissiveColorLoc, &floorEmissiveColor, SHADER_UNIFORM_VEC4); - DrawModel(floor, (Vector3){ 0.0f, 0.0f, 0.0f }, 5.0f, WHITE); // Draw floor model + DrawModel(floor, Vector3{ 0.0f, 0.0f, 0.0f }, 5.0f, WHITE); // Draw floor model // Set old car model texture tiling, emissive color and emissive intensity parameters on shader SetShaderValue(shader, textureTilingLoc, &carTextureTiling, SHADER_UNIFORM_VEC2); @@ -237,15 +237,15 @@ int main() float emissiveIntensity = 0.01f; SetShaderValue(shader, emissiveIntensityLoc, &emissiveIntensity, SHADER_UNIFORM_FLOAT); - car.Draw((Vector3){ 0.0f, 0.0f, 0.0f }, 0.005f, WHITE); // Draw car model + car.Draw(Vector3{ 0.0f, 0.0f, 0.0f }, 0.005f, WHITE); // Draw car model // Draw spheres to show the lights positions for (const auto& light : lights) { - Color lightColor = (Color){ static_cast(light.color[0]*255), - static_cast(light.color[1]*255), - static_cast(light.color[2]*255), - static_cast(light.color[3]*255) }; + Color lightColor = Color{ static_cast(light.color[0]*255), + static_cast(light.color[1]*255), + static_cast(light.color[2]*255), + static_cast(light.color[3]*255) }; if (light.enabled) DrawSphereEx(light.position, 0.2f, 8, 8, lightColor); else DrawSphereWires(light.position, 0.2f, 8, 8, ColorAlpha(lightColor, 0.3f)); @@ -267,12 +267,12 @@ int main() //-------------------------------------------------------------------------------------- // Unbind (disconnect) shader from car.material[0] // to avoid UnloadMaterial() trying to unload it automatically - car.materials[0].shader = (Shader){ 0 }; + car.materials[0].shader = Shader{ 0 }; UnloadMaterial(car.materials[0]); car.materials[0].maps = NULL; //UnloadModel(car); - floor.materials[0].shader = (Shader){ 0 }; + floor.materials[0].shader = Shader{ 0 }; UnloadMaterial(floor.materials[0]); floor.materials[0].maps = NULL; //UnloadModel(floor); diff --git a/include/AudioStreamUnmanaged.hpp b/include/AudioStreamUnmanaged.hpp index 97319264..ea13d7cb 100644 --- a/include/AudioStreamUnmanaged.hpp +++ b/include/AudioStreamUnmanaged.hpp @@ -87,7 +87,7 @@ class AudioStreamUnmanaged : public ::AudioStream { /** * Check if any audio stream buffers require refill. */ - [[nodiscard]] bool IsProcessed() const { return ::IsAudioStreamProcessed(*this); } + RLCPP_NODISCARD bool IsProcessed() const { return ::IsAudioStreamProcessed(*this); } /** * Play audio stream. @@ -116,7 +116,7 @@ class AudioStreamUnmanaged : public ::AudioStream { /** * Check if audio stream is playing. */ - [[nodiscard]] bool IsPlaying() const { return ::IsAudioStreamPlaying(*this); } + RLCPP_NODISCARD bool IsPlaying() const { return ::IsAudioStreamPlaying(*this); } /** * Stop audio stream. @@ -182,7 +182,7 @@ class AudioStreamUnmanaged : public ::AudioStream { /** * Retrieve whether or not the audio stream is ready. */ - [[nodiscard]] bool IsValid() const { return ::IsAudioStreamValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsAudioStreamValid(*this); } protected: void set(const ::AudioStream& stream) { diff --git a/include/BoundingBox.hpp b/include/BoundingBox.hpp index 6d8354cb..3799c5f4 100644 --- a/include/BoundingBox.hpp +++ b/include/BoundingBox.hpp @@ -41,17 +41,17 @@ class BoundingBox : public ::BoundingBox { /** * Detect collision between two boxes */ - [[nodiscard]] bool CheckCollision(const ::BoundingBox& box2) const { return CheckCollisionBoxes(*this, box2); } + RLCPP_NODISCARD bool CheckCollision(const ::BoundingBox& box2) const { return CheckCollisionBoxes(*this, box2); } /** * Detect collision between box and sphere */ - [[nodiscard]] bool CheckCollision(::Vector3 center, float radius) const { return CheckCollisionBoxSphere(*this, center, radius); } + RLCPP_NODISCARD bool CheckCollision(::Vector3 center, float radius) const { return CheckCollisionBoxSphere(*this, center, radius); } /** * Detect collision between ray and bounding box */ - [[nodiscard]] bool CheckCollision(const ::Ray& ray) const { return GetRayCollisionBox(ray, *this).hit; } + RLCPP_NODISCARD bool CheckCollision(const ::Ray& ray) const { return GetRayCollisionBox(ray, *this).hit; } /** * Get collision information between ray and bounding box diff --git a/include/Camera2D.hpp b/include/Camera2D.hpp index 50661c69..500101c1 100644 --- a/include/Camera2D.hpp +++ b/include/Camera2D.hpp @@ -42,17 +42,17 @@ class Camera2D : public ::Camera2D { /** * Returns camera 2d transform matrix */ - [[nodiscard]] Matrix GetMatrix() const { return ::GetCameraMatrix2D(*this); } + RLCPP_NODISCARD Matrix GetMatrix() const { return ::GetCameraMatrix2D(*this); } /** * Returns the world space position for a 2d camera screen space position */ - [[nodiscard]] Vector2 GetScreenToWorld(::Vector2 position) const { return ::GetScreenToWorld2D(position, *this); } + RLCPP_NODISCARD Vector2 GetScreenToWorld(::Vector2 position) const { return ::GetScreenToWorld2D(position, *this); } /** * Returns the screen space position for a 2d world space position */ - [[nodiscard]] Vector2 GetWorldToScreen(::Vector2 position) const { return ::GetWorldToScreen2D(position, *this); } + RLCPP_NODISCARD Vector2 GetWorldToScreen(::Vector2 position) const { return ::GetWorldToScreen2D(position, *this); } protected: void set(const ::Camera2D& camera) { offset = camera.offset; diff --git a/include/Color.hpp b/include/Color.hpp index 84a7e5ee..445b51d9 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -43,26 +43,26 @@ class Color : public ::Color { /** * Returns hexadecimal value for a Color */ - [[nodiscard]] int ToInt() const { return ::ColorToInt(*this); } + RLCPP_NODISCARD int ToInt() const { return ::ColorToInt(*this); } /** * Returns hexadecimal value for a Color */ explicit operator int() const { return ::ColorToInt(*this); } - [[nodiscard]] std::string ToString() const { return TextFormat("Color(%d, %d, %d, %d)", r, g, b, a); } + RLCPP_NODISCARD std::string ToString() const { return TextFormat("Color(%d, %d, %d, %d)", r, g, b, a); } explicit operator std::string() const { return ToString(); } /** * Returns color with alpha applied, alpha goes from 0.0f to 1.0f */ - [[nodiscard]] Color Fade(float alpha) const { return ::Fade(*this, alpha); } + RLCPP_NODISCARD Color Fade(float alpha) const { return ::Fade(*this, alpha); } /** * Returns Color normalized as float [0..1] */ - [[nodiscard]] Vector4 Normalize() const { return ::ColorNormalize(*this); } + RLCPP_NODISCARD Vector4 Normalize() const { return ::ColorNormalize(*this); } /** * Returns Color from normalized values [0..1] @@ -72,7 +72,7 @@ class Color : public ::Color { /** * Returns HSV values for a Color */ - [[nodiscard]] Vector3 ToHSV() const { return ::ColorToHSV(*this); } + RLCPP_NODISCARD Vector3 ToHSV() const { return ::ColorToHSV(*this); } GETTERSETTER(unsigned char, R, r) GETTERSETTER(unsigned char, G, g) @@ -206,7 +206,7 @@ class Color : public ::Color { /** * Returns color with alpha applied, alpha goes from 0.0f to 1.0f */ - [[nodiscard]] Color Alpha(float alpha) const { return ::ColorAlpha(*this, alpha); } + RLCPP_NODISCARD Color Alpha(float alpha) const { return ::ColorAlpha(*this, alpha); } Color Lerp(::Color color2, float factor) { return ::ColorLerp(*this, color2, factor); @@ -215,7 +215,7 @@ class Color : public ::Color { /** * Returns src alpha-blended into dst color with tint */ - [[nodiscard]] Color AlphaBlend(::Color dst, ::Color tint) const { return ::ColorAlphaBlend(dst, *this, tint); } + RLCPP_NODISCARD Color AlphaBlend(::Color dst, ::Color tint) const { return ::ColorAlphaBlend(dst, *this, tint); } static Color LightGray() { return LIGHTGRAY; } static Color Gray() { return GRAY; } diff --git a/include/FileText.hpp b/include/FileText.hpp index c45fc212..e9d89d27 100644 --- a/include/FileText.hpp +++ b/include/FileText.hpp @@ -30,9 +30,9 @@ class FileText { GETTER(const char*, Data, data) GETTER(unsigned int, Length, length) - [[nodiscard]] const char* c_str() const { return data; } + RLCPP_NODISCARD const char* c_str() const { return data; } - [[nodiscard]] std::string ToString() const { return data; } + RLCPP_NODISCARD std::string ToString() const { return data; } explicit operator std::string() const { return data; } void Load(const std::string& fileName) { Load(fileName.c_str()); } diff --git a/include/FontUnmanaged.hpp b/include/FontUnmanaged.hpp index c4caa029..9012bbeb 100644 --- a/include/FontUnmanaged.hpp +++ b/include/FontUnmanaged.hpp @@ -87,7 +87,7 @@ class FontUnmanaged : public ::Font { * Get the texture atlas containing the glyphs. */ TextureUnmanaged GetTexture() { return texture; } - [[nodiscard]] TextureUnmanaged GetTexture() const { return texture; } + RLCPP_NODISCARD TextureUnmanaged GetTexture() const { return texture; } /** * Set the texture atlas containing the glyphs. @@ -167,7 +167,7 @@ class FontUnmanaged : public ::Font { /** * Returns if the font is ready to be used. */ - [[nodiscard]] bool IsValid() const { return ::IsFontValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsFontValid(*this); } /** * Draw text using font and additional parameters. @@ -265,33 +265,33 @@ class FontUnmanaged : public ::Font { /** * Measure string size for Font. */ - [[nodiscard]] Vector2 MeasureText(const char* text, float fontSize, float spacing) const { + RLCPP_NODISCARD Vector2 MeasureText(const char* text, float fontSize, float spacing) const { return ::MeasureTextEx(*this, text, fontSize, spacing); } /** * Measure string size for Font. */ - [[nodiscard]] Vector2 MeasureText(const std::string& text, float fontSize, float spacing) const { + RLCPP_NODISCARD Vector2 MeasureText(const std::string& text, float fontSize, float spacing) const { return ::MeasureTextEx(*this, text.c_str(), fontSize, spacing); } /** * Get index position for a unicode character on font. */ - [[nodiscard]] int GetGlyphIndex(int character) const { return ::GetGlyphIndex(*this, character); } + RLCPP_NODISCARD int GetGlyphIndex(int character) const { return ::GetGlyphIndex(*this, character); } /** * Create an image from text (custom sprite font). */ - [[nodiscard]] ::Image ImageText(const char* text, float fontSize, float spacing, ::Color tint) const { + RLCPP_NODISCARD ::Image ImageText(const char* text, float fontSize, float spacing, ::Color tint) const { return ::ImageTextEx(*this, text, fontSize, spacing, tint); } /** * Create an image from text (custom sprite font). */ - [[nodiscard]] ::Image ImageText(const std::string& text, float fontSize, float spacing, ::Color tint) const { + RLCPP_NODISCARD ::Image ImageText(const std::string& text, float fontSize, float spacing, ::Color tint) const { return ::ImageTextEx(*this, text.c_str(), fontSize, spacing, tint); } diff --git a/include/Functions.hpp b/include/Functions.hpp index 07e822ec..d7e74afb 100644 --- a/include/Functions.hpp +++ b/include/Functions.hpp @@ -21,56 +21,56 @@ namespace raylib { /** * Initialize window and OpenGL context */ -[[maybe_unused]] RLCPPAPI inline void InitWindow(int width, int height, const std::string& title = "raylib") { +RLCPP_MAYBEUNUSED RLCPPAPI inline void InitWindow(int width, int height, const std::string& title = "raylib") { ::InitWindow(width, height, title.c_str()); } /** * Set title for window */ -[[maybe_unused]] RLCPPAPI inline void SetWindowTitle(const std::string& title) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetWindowTitle(const std::string& title) { ::SetWindowTitle(title.c_str()); } /** * Get the human-readable, UTF-8 encoded name of the primary monitor */ -[[maybe_unused]] RLCPPAPI inline std::string GetMonitorName(int monitor = 0) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetMonitorName(int monitor = 0) { return ::GetMonitorName(monitor); } /** * Set clipboard text content */ -[[maybe_unused]] RLCPPAPI inline void SetClipboardText(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetClipboardText(const std::string& text) { ::SetClipboardText(text.c_str()); } /** * Get clipboard text content */ -[[maybe_unused]] RLCPPAPI inline std::string GetClipboardText() { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetClipboardText() { return ::GetClipboardText(); } /** * Takes a screenshot of current screen (saved a .png) */ -[[maybe_unused]] RLCPPAPI inline void TakeScreenshot(const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void TakeScreenshot(const std::string& fileName) { ::TakeScreenshot(fileName.c_str()); } /** * Get gamepad internal name id */ -[[maybe_unused]] RLCPPAPI inline std::string GetGamepadName(int gamepad) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetGamepadName(int gamepad) { return ::GetGamepadName(gamepad); } /** * Load text data from file (read) */ -[[maybe_unused]] RLCPPAPI std::string LoadFileText(const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI std::string LoadFileText(const std::string& fileName) { char* text = ::LoadFileText(fileName.c_str()); std::string output(text); ::UnloadFileText(text); @@ -80,77 +80,77 @@ namespace raylib { /** * Save text data to file (write) */ -[[maybe_unused]] RLCPPAPI inline bool SaveFileText(const std::string& fileName, const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool SaveFileText(const std::string& fileName, const std::string& text) { return ::SaveFileText(fileName.c_str(), text.c_str()); } /** * Check if file exists */ -[[maybe_unused]] RLCPPAPI inline bool FileExists(const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool FileExists(const std::string& fileName) { return ::FileExists(fileName.c_str()); } /** * Check if directory path exists */ -[[maybe_unused]] RLCPPAPI inline bool DirectoryExists(const std::string& dirPath) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool DirectoryExists(const std::string& dirPath) { return ::DirectoryExists(dirPath.c_str()); } /** * Check file extension (including point: .png, .wav) */ -[[maybe_unused]] RLCPPAPI inline bool IsFileExtension(const std::string& fileName, const std::string& ext) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsFileExtension(const std::string& fileName, const std::string& ext) { return ::IsFileExtension(fileName.c_str(), ext.c_str()); } /** * Get pointer to extension for a filename string (including point: ".png") */ -[[maybe_unused]] RLCPPAPI inline std::string GetFileExtension(const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetFileExtension(const std::string& fileName) { return ::GetFileExtension(fileName.c_str()); } /** * Get pointer to filename for a path string */ -[[maybe_unused]] RLCPPAPI inline std::string GetFileName(const std::string& filePath) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetFileName(const std::string& filePath) { return ::GetFileName(filePath.c_str()); } /** * Get filename string without extension */ -[[maybe_unused]] RLCPPAPI inline std::string GetFileNameWithoutExt(const std::string& filePath) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetFileNameWithoutExt(const std::string& filePath) { return ::GetFileNameWithoutExt(filePath.c_str()); } /** * Get full path for a given fileName with path */ -[[maybe_unused]] RLCPPAPI inline std::string GetDirectoryPath(const std::string& filePath) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetDirectoryPath(const std::string& filePath) { return ::GetDirectoryPath(filePath.c_str()); } /** * Get previous directory path for a given path */ -[[maybe_unused]] RLCPPAPI inline std::string GetPrevDirectoryPath(const std::string& dirPath) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetPrevDirectoryPath(const std::string& dirPath) { return ::GetPrevDirectoryPath(dirPath.c_str()); } /** * Get current working directory */ -[[maybe_unused]] RLCPPAPI inline std::string GetWorkingDirectory() { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetWorkingDirectory() { return ::GetWorkingDirectory(); } /** * Get filenames in a directory path */ -[[maybe_unused]] RLCPPAPI std::vector LoadDirectoryFiles(const std::string& dirPath) { +RLCPP_MAYBEUNUSED RLCPPAPI std::vector LoadDirectoryFiles(const std::string& dirPath) { FilePathList files = ::LoadDirectoryFiles(dirPath.c_str()); std::vector output(files.paths, files.paths + files.count); ::UnloadDirectoryFiles(files); @@ -160,7 +160,7 @@ namespace raylib { /** * Load directory filepaths with extension filtering and optional subdirectory scanning */ -[[maybe_unused]] RLCPPAPI std::vector +RLCPP_MAYBEUNUSED RLCPPAPI std::vector LoadDirectoryFilesEx(const std::string& basePath, const std::string& filter, bool scanSubdirs = false) { FilePathList files = ::LoadDirectoryFilesEx(basePath.c_str(), filter.c_str(), scanSubdirs); std::vector output(files.paths, files.paths + files.count); @@ -171,14 +171,14 @@ LoadDirectoryFilesEx(const std::string& basePath, const std::string& filter, boo /** * Change working directory, return true on success */ -[[maybe_unused]] RLCPPAPI inline bool ChangeDirectory(const std::string& dir) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool ChangeDirectory(const std::string& dir) { return ::ChangeDirectory(dir.c_str()); } /** * Get dropped files names */ -[[maybe_unused]] RLCPPAPI std::vector LoadDroppedFiles() { +RLCPP_MAYBEUNUSED RLCPPAPI std::vector LoadDroppedFiles() { if (!::IsFileDropped()) { return std::vector(); } @@ -191,28 +191,28 @@ LoadDirectoryFilesEx(const std::string& basePath, const std::string& filter, boo /** * Get file modification time (last write time) */ -[[maybe_unused]] RLCPPAPI inline long GetFileModTime(const std::string& fileName) { // NOLINT +RLCPP_MAYBEUNUSED RLCPPAPI inline long GetFileModTime(const std::string& fileName) { // NOLINT return ::GetFileModTime(fileName.c_str()); } /** * Open URL with default system browser (if available) */ -[[maybe_unused]] RLCPPAPI inline void OpenURL(const std::string& url) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void OpenURL(const std::string& url) { return ::OpenURL(url.c_str()); } /** * Load an image. */ -[[maybe_unused]] RLCPPAPI inline ::Image LoadImage(const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image LoadImage(const std::string& fileName) { return ::LoadImage(fileName.c_str()); } /** * Load an image from RAW file data */ -[[maybe_unused]] RLCPPAPI inline ::Image +RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image LoadImageRaw(const std::string& fileName, int width, int height, int format, int headerSize) { return ::LoadImageRaw(fileName.c_str(), width, height, format, headerSize); } @@ -220,14 +220,14 @@ LoadImageRaw(const std::string& fileName, int width, int height, int format, int /** * Load animated image data */ -[[maybe_unused]] RLCPPAPI inline ::Image LoadImageAnim(const std::string& fileName, int* frames) { +RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image LoadImageAnim(const std::string& fileName, int* frames) { return ::LoadImageAnim(fileName.c_str(), frames); } /** * Load image from memory buffer, fileType refers to extension like "png" */ -[[maybe_unused]] RLCPPAPI inline ::Image +RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image LoadImageFromMemory(const std::string& fileType, const unsigned char* fileData, int dataSize) { return ::LoadImageFromMemory(fileType.c_str(), fileData, dataSize); } @@ -235,28 +235,28 @@ LoadImageFromMemory(const std::string& fileType, const unsigned char* fileData, /** * Export image data to file */ -[[maybe_unused]] RLCPPAPI inline bool ExportImage(const Image& image, const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool ExportImage(const Image& image, const std::string& fileName) { return ::ExportImage(image, fileName.c_str()); } /** * Export image as code file (.h) defining an array of bytes */ -[[maybe_unused]] RLCPPAPI inline bool ExportImageAsCode(const Image& image, const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool ExportImageAsCode(const Image& image, const std::string& fileName) { return ::ExportImageAsCode(image, fileName.c_str()); } /** * Draw text (using default font) */ -[[maybe_unused]] RLCPPAPI inline void DrawText(const char* text, int posX, int posY, int fontSize, ::Color color) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawText(const char* text, int posX, int posY, int fontSize, ::Color color) { ::DrawText(text, posX, posY, fontSize, color); } /** * Draw text (using default font) */ -[[maybe_unused]] RLCPPAPI inline void +RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawText(const std::string& text, int posX, int posY, int fontSize, ::Color color) { ::DrawText(text.c_str(), posX, posY, fontSize, color); } @@ -264,7 +264,7 @@ DrawText(const std::string& text, int posX, int posY, int fontSize, ::Color colo /** * Draw text using font and additional parameters */ -[[maybe_unused]] RLCPPAPI inline void +RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawTextEx(const Font& font, const char* text, Vector2 position, float fontSize, float spacing, ::Color tint) { ::DrawTextEx(font, text, position, fontSize, spacing, tint); } @@ -272,7 +272,7 @@ DrawTextEx(const Font& font, const char* text, Vector2 position, float fontSize, /** * Draw text using font and additional parameters */ -[[maybe_unused]] RLCPPAPI inline void +RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawTextEx(const Font& font, const std::string& text, Vector2 position, float fontSize, float spacing, ::Color tint) { ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, tint); } @@ -280,7 +280,7 @@ DrawTextEx(const Font& font, const std::string& text, Vector2 position, float fo /** * Draw text using Font and pro parameters (rotation) */ -[[maybe_unused]] RLCPPAPI inline void DrawTextPro( +RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawTextPro( const Font& font, const char* text, Vector2 position, @@ -295,7 +295,7 @@ DrawTextEx(const Font& font, const std::string& text, Vector2 position, float fo /** * Draw text using Font and pro parameters (rotation) */ -[[maybe_unused]] RLCPPAPI inline void DrawTextPro( +RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawTextPro( const Font& font, const std::string& text, Vector2 position, @@ -310,14 +310,14 @@ DrawTextEx(const Font& font, const std::string& text, Vector2 position, float fo /** * Load font from file (filename must include file extension) */ -[[maybe_unused]] RLCPPAPI inline ::Font LoadFont(const std::string& fileName) { +RLCPP_MAYBEUNUSED RLCPPAPI inline ::Font LoadFont(const std::string& fileName) { return ::LoadFont(fileName.c_str()); } /** * Load font from file (filename must include file extension) */ -[[maybe_unused]] RLCPPAPI inline ::Font +RLCPP_MAYBEUNUSED RLCPPAPI inline ::Font LoadFontEx(const std::string& fileName, int fontSize, const int* codepoints = nullptr, int codepointCount = 0) { return ::LoadFontEx(fileName.c_str(), fontSize, codepoints, codepointCount); } @@ -325,56 +325,56 @@ LoadFontEx(const std::string& fileName, int fontSize, const int* codepoints = nu /** * Measure string width for default font */ -[[maybe_unused]] RLCPPAPI inline int MeasureText(const char* text, int fontSize) { +RLCPP_MAYBEUNUSED RLCPPAPI inline int MeasureText(const char* text, int fontSize) { return ::MeasureText(text, fontSize); } /** * Measure string width for default font */ -[[maybe_unused]] RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) { +RLCPP_MAYBEUNUSED RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) { return ::MeasureText(text.c_str(), fontSize); } /** * Check if two text string are equal */ -[[maybe_unused]] RLCPPAPI inline bool TextIsEqual(const char* text1, const char* text2) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool TextIsEqual(const char* text1, const char* text2) { return ::TextIsEqual(text1, text2); } /** * Check if two text string are equal */ -[[maybe_unused]] RLCPPAPI inline bool TextIsEqual(const std::string& text1, const std::string& text2) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool TextIsEqual(const std::string& text1, const std::string& text2) { return ::TextIsEqual(text1.c_str(), text2.c_str()); } /** * Get text length, checks for '\0' ending */ -[[maybe_unused]] RLCPPAPI inline unsigned int TextLength(const char* text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline unsigned int TextLength(const char* text) { return ::TextLength(text); } /** * Get text length, checks for '\0' ending */ -[[maybe_unused]] RLCPPAPI inline unsigned int TextLength(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline unsigned int TextLength(const std::string& text) { return ::TextLength(text.c_str()); } /** * Get a piece of a text string */ -[[maybe_unused]] RLCPPAPI inline std::string TextSubtext(const std::string& text, int position, int length) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextSubtext(const std::string& text, int position, int length) { return ::TextSubtext(text.c_str(), position, length); } /** * Replace text string */ -[[maybe_unused]] RLCPPAPI std::string +RLCPP_MAYBEUNUSED RLCPPAPI std::string TextReplace(const std::string& text, const std::string& replace, const std::string& by) { const char* output = ::TextReplace(text.c_str(), replace.c_str(), by.c_str()); if (output != NULL) { @@ -386,7 +386,7 @@ TextReplace(const std::string& text, const std::string& replace, const std::stri /** * Insert text in a position */ -[[maybe_unused]] RLCPPAPI std::string TextInsert(const std::string& text, const std::string& insert, int position) { +RLCPP_MAYBEUNUSED RLCPPAPI std::string TextInsert(const std::string& text, const std::string& insert, int position) { const char* output = ::TextInsert(text.c_str(), insert.c_str(), position); if (output != NULL) { return std::string(output); @@ -397,7 +397,7 @@ TextReplace(const std::string& text, const std::string& replace, const std::stri /** * Split text into multiple strings */ -[[maybe_unused]] RLCPPAPI std::vector TextSplit(const std::string& text, char delimiter) { +RLCPP_MAYBEUNUSED RLCPPAPI std::vector TextSplit(const std::string& text, char delimiter) { int count; const char* const* split = ::TextSplit(text.c_str(), delimiter, &count); return std::vector(split, split + count); @@ -406,56 +406,56 @@ TextReplace(const std::string& text, const std::string& replace, const std::stri /** * Find first text occurrence within a string */ -[[maybe_unused]] RLCPPAPI inline int TextFindIndex(const std::string& text, const std::string& find) { +RLCPP_MAYBEUNUSED RLCPPAPI inline int TextFindIndex(const std::string& text, const std::string& find) { return ::TextFindIndex(text.c_str(), find.c_str()); } /** * Get upper case version of provided string */ -[[maybe_unused]] RLCPPAPI inline std::string TextToUpper(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToUpper(const std::string& text) { return ::TextToUpper(text.c_str()); } /** * Get lower case version of provided string */ -[[maybe_unused]] RLCPPAPI inline std::string TextToLower(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToLower(const std::string& text) { return ::TextToLower(text.c_str()); } /** * Get Pascal case notation version of provided string */ -[[maybe_unused]] RLCPPAPI inline std::string TextToPascal(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToPascal(const std::string& text) { return ::TextToPascal(text.c_str()); } /** * Get Snake case notation version of provided string */ -[[maybe_unused]] RLCPPAPI inline std::string TextToSnake(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToSnake(const std::string& text) { return ::TextToSnake(text.c_str()); } /** * Get Camel case notation version of provided string */ -[[maybe_unused]] RLCPPAPI inline std::string TextToCamel(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToCamel(const std::string& text) { return ::TextToCamel(text.c_str()); } /** * Get integer value from text (negative values not supported) */ -[[maybe_unused]] RLCPPAPI inline int TextToInteger(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline int TextToInteger(const std::string& text) { return ::TextToInteger(text.c_str()); } /** * Get float value from text */ -[[maybe_unused]] RLCPPAPI inline float TextToFloat(const std::string& text) { +RLCPP_MAYBEUNUSED RLCPPAPI inline float TextToFloat(const std::string& text) { return ::TextToFloat(text.c_str()); } diff --git a/include/Gamepad.hpp b/include/Gamepad.hpp index 0362020c..8a2884d2 100644 --- a/include/Gamepad.hpp +++ b/include/Gamepad.hpp @@ -36,7 +36,7 @@ class Gamepad { /** * Detect if a gamepad is available */ - [[nodiscard]] bool IsAvailable() const { return ::IsGamepadAvailable(number); } + RLCPP_NODISCARD bool IsAvailable() const { return ::IsGamepadAvailable(number); } /** * Detect if a gamepad is available @@ -46,7 +46,7 @@ class Gamepad { /** * Return gamepad internal name id */ - [[nodiscard]] std::string GetName() const { return ::GetGamepadName(number); } + RLCPP_NODISCARD std::string GetName() const { return ::GetGamepadName(number); } /** * Return gamepad internal name id @@ -56,22 +56,22 @@ class Gamepad { /** * Detect if a gamepad button has been pressed once */ - [[nodiscard]] bool IsButtonPressed(int button) const { return ::IsGamepadButtonPressed(number, button); } + RLCPP_NODISCARD bool IsButtonPressed(int button) const { return ::IsGamepadButtonPressed(number, button); } /** * Detect if a gamepad button is being pressed */ - [[nodiscard]] bool IsButtonDown(int button) const { return ::IsGamepadButtonDown(number, button); } + RLCPP_NODISCARD bool IsButtonDown(int button) const { return ::IsGamepadButtonDown(number, button); } /** * Detect if a gamepad button has been released once */ - [[nodiscard]] bool IsButtonReleased(int button) const { return ::IsGamepadButtonReleased(number, button); } + RLCPP_NODISCARD bool IsButtonReleased(int button) const { return ::IsGamepadButtonReleased(number, button); } /** * Detect if a gamepad button is NOT being pressed */ - [[nodiscard]] bool IsButtonUp(int button) const { return ::IsGamepadButtonUp(number, button); } + RLCPP_NODISCARD bool IsButtonUp(int button) const { return ::IsGamepadButtonUp(number, button); } /** * Get the last gamepad button pressed @@ -81,12 +81,12 @@ class Gamepad { /** * Return gamepad axis count for a gamepad */ - [[nodiscard]] int GetAxisCount() const { return ::GetGamepadAxisCount(number); } + RLCPP_NODISCARD int GetAxisCount() const { return ::GetGamepadAxisCount(number); } /** * Return axis movement value for a gamepad axis */ - [[nodiscard]] float GetAxisMovement(int axis) const { return ::GetGamepadAxisMovement(number, axis); } + RLCPP_NODISCARD float GetAxisMovement(int axis) const { return ::GetGamepadAxisMovement(number, axis); } static int SetMappings(const std::string& mappings) { return SetGamepadMappings(mappings.c_str()); } diff --git a/include/Image.hpp b/include/Image.hpp index 2d3224fc..c5c88bde 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -340,17 +340,17 @@ class Image : public ::Image { /** * Retrieve the width and height of the image. */ - [[nodiscard]] ::Vector2 GetSize() const { return {static_cast(width), static_cast(height)}; } + RLCPP_NODISCARD ::Vector2 GetSize() const { return {static_cast(width), static_cast(height)}; } /** * Create an image duplicate (useful for transformations) */ - [[nodiscard]] ::Image Copy() const { return ::ImageCopy(*this); } + RLCPP_NODISCARD ::Image Copy() const { return ::ImageCopy(*this); } /** * Create an image from another image piece */ - [[nodiscard]] ::Image FromImage(::Rectangle rec) const { return ::ImageFromImage(*this, rec); } + RLCPP_NODISCARD ::Image FromImage(::Rectangle rec) const { return ::ImageFromImage(*this, rec); } /** * Convert image data to desired format @@ -569,17 +569,17 @@ class Image : public ::Image { * * @param threshold Threshold is defined as a percentatge: 0.0f -> 1.0f */ - [[nodiscard]] Rectangle GetAlphaBorder(float threshold) const { return ::GetImageAlphaBorder(*this, threshold); } + RLCPP_NODISCARD Rectangle GetAlphaBorder(float threshold) const { return ::GetImageAlphaBorder(*this, threshold); } /** * Get image pixel color at (x, y) position */ - [[nodiscard]] raylib::Color GetColor(int x = 0, int y = 0) const { return ::GetImageColor(*this, x, y); } + RLCPP_NODISCARD raylib::Color GetColor(int x = 0, int y = 0) const { return ::GetImageColor(*this, x, y); } /** * Get image pixel color at vector position */ - [[nodiscard]] raylib::Color GetColor(::Vector2 position) const { + RLCPP_NODISCARD raylib::Color GetColor(::Vector2 position) const { return ::GetImageColor(*this, static_cast(position.x), static_cast(position.y)); } @@ -692,7 +692,7 @@ class Image : public ::Image { /** * Load color data from image as a Color array (RGBA - 32bit) */ - [[nodiscard]] ::Color* LoadColors() const { return ::LoadImageColors(*this); } + RLCPP_NODISCARD ::Color* LoadColors() const { return ::LoadImageColors(*this); } /** * Load colors palette from image as a Color array (RGBA - 32bit) @@ -714,7 +714,7 @@ class Image : public ::Image { /** * Load texture from image data. */ - [[nodiscard]] ::Texture2D LoadTexture() const { return ::LoadTextureFromImage(*this); } + RLCPP_NODISCARD ::Texture2D LoadTexture() const { return ::LoadTextureFromImage(*this); } /** * Loads a texture from the image data. @@ -735,14 +735,14 @@ class Image : public ::Image { * * @return The pixel data size of the image. */ - [[nodiscard]] int GetPixelDataSize() const { return ::GetPixelDataSize(width, height, format); } + RLCPP_NODISCARD int GetPixelDataSize() const { return ::GetPixelDataSize(width, height, format); } /** * Retrieve whether or not the Image has been loaded. * * @return True or false depending on whether the Image has been loaded. */ - [[nodiscard]] bool IsValid() const { return ::IsImageValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsImageValid(*this); } /** * Create an image from a selected channel of another image (GRAYSCALE) diff --git a/include/Keyboard.hpp b/include/Keyboard.hpp index ac4f380c..1632ec9b 100644 --- a/include/Keyboard.hpp +++ b/include/Keyboard.hpp @@ -12,35 +12,35 @@ namespace Keyboard { /** * Detect if a key has been pressed once */ -[[maybe_unused]] RLCPPAPI inline bool IsKeyPressed(int key) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyPressed(int key) { return ::IsKeyPressed(key); } /** * Detect if a key has been pressed again (Only PLATFORM_DESKTOP) */ -[[maybe_unused]] RLCPPAPI inline bool IsKeyPressedRepeat(int key) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyPressedRepeat(int key) { return ::IsKeyPressedRepeat(key); } /** * Detect if a key is being pressed */ -[[maybe_unused]] RLCPPAPI inline bool IsKeyDown(int key) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyDown(int key) { return ::IsKeyDown(key); } /** * Detect if a key has been released once */ -[[maybe_unused]] RLCPPAPI inline bool IsKeyReleased(int key) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyReleased(int key) { return ::IsKeyReleased(key); } /** * Detect if a key is NOT being pressed */ -[[maybe_unused]] RLCPPAPI inline bool IsKeyUp(int key) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyUp(int key) { return ::IsKeyUp(key); } @@ -48,14 +48,14 @@ namespace Keyboard { * Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty */ -[[maybe_unused]] RLCPPAPI inline int GetKeyPressed() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetKeyPressed() { return ::GetKeyPressed(); } /** * Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty */ -[[maybe_unused]] RLCPPAPI inline int GetCharPressed() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetCharPressed() { return ::GetCharPressed(); } } // namespace Keyboard diff --git a/include/MaterialUnmanaged.hpp b/include/MaterialUnmanaged.hpp index 3e0764c6..c5f8797c 100644 --- a/include/MaterialUnmanaged.hpp +++ b/include/MaterialUnmanaged.hpp @@ -77,7 +77,7 @@ class MaterialUnmanaged : public ::Material { /** * Check if material is ready. */ - [[nodiscard]] bool IsValid() const { return ::IsMaterialValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsMaterialValid(*this); } protected: void set(const ::Material& material) { diff --git a/include/Matrix.hpp b/include/Matrix.hpp index b6871e87..5b9a64cc 100644 --- a/include/Matrix.hpp +++ b/include/Matrix.hpp @@ -85,14 +85,14 @@ class Matrix : public ::Matrix { /** * Returns the trace of the matrix (sum of the values along the diagonal) */ - [[nodiscard]] float Trace() const { return ::MatrixTrace(*this); } + RLCPP_NODISCARD float Trace() const { return ::MatrixTrace(*this); } /** * Transposes provided matrix */ - [[nodiscard]] Matrix Transpose() const { return ::MatrixTranspose(*this); } + RLCPP_NODISCARD Matrix Transpose() const { return ::MatrixTranspose(*this); } - [[nodiscard]] Matrix Invert() const { return ::MatrixInvert(*this); } + RLCPP_NODISCARD Matrix Invert() const { return ::MatrixInvert(*this); } static Matrix Identity() { return ::MatrixIdentity(); } @@ -118,9 +118,9 @@ class Matrix : public ::Matrix { static Matrix Scale(float x, float y, float z) { return ::MatrixScale(x, y, z); } - [[nodiscard]] Matrix Multiply(const ::Matrix& right) const { return ::MatrixMultiply(*this, right); } + RLCPP_NODISCARD Matrix Multiply(const ::Matrix& right) const { return ::MatrixMultiply(*this, right); } - [[nodiscard]] Matrix Multiply(float value) const { return ::MatrixMultiplyValue(*this, value); } + RLCPP_NODISCARD Matrix Multiply(float value) const { return ::MatrixMultiplyValue(*this, value); } Matrix operator*(const ::Matrix& matrix) { return ::MatrixMultiply(*this, matrix); } @@ -140,7 +140,7 @@ class Matrix : public ::Matrix { static Matrix LookAt(Vector3 eye, Vector3 target, Vector3 up) { return ::MatrixLookAt(eye, target, up); } - [[nodiscard]] float16 ToFloatV() const { return ::MatrixToFloatV(*this); } + RLCPP_NODISCARD float16 ToFloatV() const { return ::MatrixToFloatV(*this); } operator float16() const { return ToFloatV(); } diff --git a/include/MeshUnmanaged.hpp b/include/MeshUnmanaged.hpp index 4fce20e2..ca0571a4 100644 --- a/include/MeshUnmanaged.hpp +++ b/include/MeshUnmanaged.hpp @@ -198,7 +198,7 @@ class MeshUnmanaged : public ::Mesh { /** * Compute mesh bounding box limits */ - [[nodiscard]] raylib::BoundingBox BoundingBox() const { return ::GetMeshBoundingBox(*this); } + RLCPP_NODISCARD raylib::BoundingBox BoundingBox() const { return ::GetMeshBoundingBox(*this); } /** * Compute mesh bounding box limits @@ -216,7 +216,7 @@ class MeshUnmanaged : public ::Mesh { /** * Load model from generated mesh */ - [[nodiscard]] raylib::Model LoadModelFrom() const { return ::LoadModelFromMesh(*this); } + RLCPP_NODISCARD raylib::Model LoadModelFrom() const { return ::LoadModelFromMesh(*this); } /** * Load model from generated mesh @@ -226,7 +226,7 @@ class MeshUnmanaged : public ::Mesh { /** * Returns whether or not the Mesh is valid. */ - [[nodiscard]] bool IsValid() const { return vaoId != 0 && vertexCount > 0; } + RLCPP_NODISCARD bool IsValid() const { return vaoId != 0 && vertexCount > 0; } protected: void set(const ::Mesh& mesh) { diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index ba04d6d3..03dc427b 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -103,7 +103,7 @@ class ModelAnimation : public ::ModelAnimation { /** * Check model animation skeleton match */ - [[nodiscard]] bool IsValid(const ::Model& model) const { return ::IsModelAnimationValid(model, *this); } + RLCPP_NODISCARD bool IsValid(const ::Model& model) const { return ::IsModelAnimationValid(model, *this); } protected: void set(const ::ModelAnimation& model) { boneCount = model.boneCount; diff --git a/include/ModelUnmanaged.hpp b/include/ModelUnmanaged.hpp index 3c0cbd3b..856fd8c0 100644 --- a/include/ModelUnmanaged.hpp +++ b/include/ModelUnmanaged.hpp @@ -126,7 +126,7 @@ class ModelUnmanaged : public ::Model { /** * Check model animation skeleton match. */ - [[nodiscard]] bool IsModelAnimationValid(const ::ModelAnimation& anim) const { + RLCPP_NODISCARD bool IsModelAnimationValid(const ::ModelAnimation& anim) const { return ::IsModelAnimationValid(*this, anim); } @@ -171,7 +171,7 @@ class ModelUnmanaged : public ::Model { /** * Compute model bounding box limits (considers all meshes). */ - [[nodiscard]] BoundingBox GetBoundingBox() const { return ::GetModelBoundingBox(*this); } + RLCPP_NODISCARD BoundingBox GetBoundingBox() const { return ::GetModelBoundingBox(*this); } /** * Compute model bounding box limits (considers all meshes). @@ -181,7 +181,7 @@ class ModelUnmanaged : public ::Model { /** * Determines whether or not the Model has data in it. */ - [[nodiscard]] bool IsValid() const { return ::IsModelValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsModelValid(*this); } protected: void set(const ::Model& model) { diff --git a/include/Mouse.hpp b/include/Mouse.hpp index 882e47b1..507d2533 100644 --- a/include/Mouse.hpp +++ b/include/Mouse.hpp @@ -13,83 +13,83 @@ namespace Mouse { /** * Detect if a mouse button has been pressed once */ -[[maybe_unused]] RLCPPAPI inline bool IsButtonPressed(int button) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonPressed(int button) { return ::IsMouseButtonPressed(button); } /** * Detect if a mouse button is being pressed */ -[[maybe_unused]] RLCPPAPI inline bool IsButtonDown(int button) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonDown(int button) { return ::IsMouseButtonDown(button); } /** * Detect if a mouse button has been released once */ -[[maybe_unused]] RLCPPAPI inline bool IsButtonReleased(int button) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonReleased(int button) { return ::IsMouseButtonReleased(button); } -[[maybe_unused]] RLCPPAPI inline bool IsButtonUp(int button) { +RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonUp(int button) { return ::IsMouseButtonUp(button); } -[[maybe_unused]] RLCPPAPI inline int GetX() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetX() { return ::GetMouseX(); } -[[maybe_unused]] RLCPPAPI inline int GetY() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetY() { return ::GetMouseY(); } -[[maybe_unused]] RLCPPAPI inline void SetX(int x) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetX(int x) { ::SetMousePosition(x, GetY()); } -[[maybe_unused]] RLCPPAPI inline void SetY(int y) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetY(int y) { ::SetMousePosition(GetX(), y); } -[[maybe_unused]] RLCPPAPI inline Vector2 GetPosition() { +RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetPosition() { return ::GetMousePosition(); } -[[maybe_unused]] RLCPPAPI inline void SetPosition(int x, int y) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetPosition(int x, int y) { ::SetMousePosition(x, y); } -[[maybe_unused]] RLCPPAPI inline void SetPosition(::Vector2 position) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetPosition(::Vector2 position) { ::SetMousePosition(static_cast(position.x), static_cast(position.y)); } /** * Get mouse delta between frames */ -[[maybe_unused]] RLCPPAPI inline Vector2 GetDelta() { +RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetDelta() { return ::GetMouseDelta(); } -[[maybe_unused]] RLCPPAPI inline void SetOffset(int offsetX = 0, int offsetY = 0) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetOffset(int offsetX = 0, int offsetY = 0) { ::SetMouseOffset(offsetX, offsetY); } -[[maybe_unused]] RLCPPAPI inline void SetOffset(::Vector2 offset) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetOffset(::Vector2 offset) { ::SetMouseOffset(static_cast(offset.x), static_cast(offset.y)); } -[[maybe_unused]] RLCPPAPI inline void SetScale(float scaleX = 1.0f, float scaleY = 1.0f) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetScale(float scaleX = 1.0f, float scaleY = 1.0f) { ::SetMouseScale(scaleX, scaleY); } -[[maybe_unused]] RLCPPAPI inline void SetScale(::Vector2 scale) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetScale(::Vector2 scale) { ::SetMouseScale(scale.x, scale.y); } /** * Get mouse wheel movement for X or Y, whichever is larger */ -[[maybe_unused]] RLCPPAPI inline float GetWheelMove() { +RLCPP_MAYBEUNUSED RLCPPAPI inline float GetWheelMove() { return ::GetMouseWheelMove(); } @@ -98,7 +98,7 @@ namespace Mouse { * * @see ::GetMouseWheelMoveV() */ -[[maybe_unused]] RLCPPAPI inline Vector2 GetWheelMoveV() { +RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetWheelMoveV() { return GetMouseWheelMoveV(); } @@ -107,42 +107,42 @@ namespace Mouse { * * @see ::MouseCursor */ -[[maybe_unused]] RLCPPAPI inline void SetCursor(int cursor = MOUSE_CURSOR_DEFAULT) { +RLCPP_MAYBEUNUSED RLCPPAPI inline void SetCursor(int cursor = MOUSE_CURSOR_DEFAULT) { ::SetMouseCursor(cursor); } /** * Get touch position X for touch point 0 (relative to screen size) */ -[[maybe_unused]] RLCPPAPI inline int GetTouchX() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetTouchX() { return ::GetTouchX(); } /** * Get touch position Y for touch point 0 (relative to screen size) */ -[[maybe_unused]] RLCPPAPI inline int GetTouchY() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetTouchY() { return ::GetTouchY(); } /** * Get touch position XY for a touch point index (relative to screen size) */ -[[maybe_unused]] RLCPPAPI inline Vector2 GetTouchPosition(int index) { +RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetTouchPosition(int index) { return ::GetTouchPosition(index); } /** * Get a ray trace from mouse position */ -[[maybe_unused]] RLCPPAPI inline Ray GetRay(::Vector2 mousePosition, const ::Camera& camera) { +RLCPP_MAYBEUNUSED RLCPPAPI inline Ray GetRay(::Vector2 mousePosition, const ::Camera& camera) { return ::GetMouseRay(mousePosition, camera); } /** * Get a ray trace from mouse position */ -[[maybe_unused]] RLCPPAPI inline Ray GetRay(const ::Camera& camera) { +RLCPP_MAYBEUNUSED RLCPPAPI inline Ray GetRay(const ::Camera& camera) { return ::GetMouseRay(::GetMousePosition(), camera); } } // namespace Mouse diff --git a/include/MusicUnmanaged.hpp b/include/MusicUnmanaged.hpp index 4b8cee43..734a3af3 100644 --- a/include/MusicUnmanaged.hpp +++ b/include/MusicUnmanaged.hpp @@ -146,7 +146,7 @@ class MusicUnmanaged : public ::Music { /** * Check if music is playing. */ - [[nodiscard]] bool IsPlaying() const { return ::IsMusicStreamPlaying(*this); } + RLCPP_NODISCARD bool IsPlaying() const { return ::IsMusicStreamPlaying(*this); } /** * Set volume for music. @@ -175,19 +175,19 @@ class MusicUnmanaged : public ::Music { /** * Get music time length (in seconds). */ - [[nodiscard]] float GetTimeLength() const { return ::GetMusicTimeLength(*this); } + RLCPP_NODISCARD float GetTimeLength() const { return ::GetMusicTimeLength(*this); } /** * Get current music time played (in seconds). */ - [[nodiscard]] float GetTimePlayed() const { return ::GetMusicTimePlayed(*this); } + RLCPP_NODISCARD float GetTimePlayed() const { return ::GetMusicTimePlayed(*this); } /** * Retrieve whether or not the Music has been loaded. * * @return True or false depending on whether the Music has been loaded. */ - [[nodiscard]] bool IsValid() const { return ::IsMusicValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsMusicValid(*this); } protected: void set(const ::Music& music) { diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 5056920e..7e216c8d 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -100,26 +100,26 @@ class Rectangle : public ::Rectangle { /** * Check collision between two rectangles */ - [[nodiscard]] bool CheckCollision(::Rectangle rec2) const { return ::CheckCollisionRecs(*this, rec2); } + RLCPP_NODISCARD bool CheckCollision(::Rectangle rec2) const { return ::CheckCollisionRecs(*this, rec2); } /** * Get collision rectangle for two rectangles collision */ - [[nodiscard]] ::Rectangle GetCollision(::Rectangle rec2) const { return ::GetCollisionRec(*this, rec2); } + RLCPP_NODISCARD ::Rectangle GetCollision(::Rectangle rec2) const { return ::GetCollisionRec(*this, rec2); } /** * Check if point is inside rectangle */ - [[nodiscard]] bool CheckCollision(::Vector2 point) const { return ::CheckCollisionPointRec(point, *this); } + RLCPP_NODISCARD bool CheckCollision(::Vector2 point) const { return ::CheckCollisionPointRec(point, *this); } /** * Check collision between circle and rectangle */ - [[nodiscard]] bool CheckCollision(::Vector2 center, float radius) const { + RLCPP_NODISCARD bool CheckCollision(::Vector2 center, float radius) const { return ::CheckCollisionCircleRec(center, radius, *this); } - [[nodiscard]] Vector2 GetSize() const { return {width, height}; } + RLCPP_NODISCARD Vector2 GetSize() const { return {width, height}; } Rectangle& SetSize(float newWidth, float newHeight) { width = newWidth; @@ -134,7 +134,7 @@ class Rectangle : public ::Rectangle { return *this; } - [[nodiscard]] Vector2 GetPosition() const { return {x, y}; } + RLCPP_NODISCARD Vector2 GetPosition() const { return {x, y}; } Rectangle& SetPosition(float newX, float newY) { x = newX; diff --git a/include/RenderTextureUnmanaged.hpp b/include/RenderTextureUnmanaged.hpp index 7894564e..4cc9a7aa 100644 --- a/include/RenderTextureUnmanaged.hpp +++ b/include/RenderTextureUnmanaged.hpp @@ -44,7 +44,7 @@ class RenderTextureUnmanaged : public ::RenderTexture { * Get the color buffer attachment texture. */ TextureUnmanaged GetTexture() { return texture; } - [[nodiscard]] TextureUnmanaged GetTexture() const { return texture; } + RLCPP_NODISCARD TextureUnmanaged GetTexture() const { return texture; } void SetTexture(const ::Texture& newTexture) { texture = newTexture; } /** @@ -99,7 +99,7 @@ class RenderTextureUnmanaged : public ::RenderTexture { /** * Retrieves whether or not the render texture is ready. */ - [[nodiscard]] bool IsValid() const { return ::IsRenderTextureValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsRenderTextureValid(*this); } protected: void set(const ::RenderTexture& renderTexture) { diff --git a/include/ShaderUnmanaged.hpp b/include/ShaderUnmanaged.hpp index d32fb2da..e9640ca7 100644 --- a/include/ShaderUnmanaged.hpp +++ b/include/ShaderUnmanaged.hpp @@ -78,14 +78,14 @@ class ShaderUnmanaged : public ::Shader { * * @see GetShaderLocation() */ - [[nodiscard]] int GetLocation(const std::string& uniformName) const { return ::GetShaderLocation(*this, uniformName.c_str()); } + RLCPP_NODISCARD int GetLocation(const std::string& uniformName) const { return ::GetShaderLocation(*this, uniformName.c_str()); } /** * Get shader attribute location * * @see GetShaderLocationAttrib() */ - [[nodiscard]] int GetLocationAttrib(const std::string& attribName) const { + RLCPP_NODISCARD int GetLocationAttrib(const std::string& attribName) const { return ::GetShaderLocationAttrib(*this, attribName.c_str()); } @@ -142,7 +142,7 @@ class ShaderUnmanaged : public ::Shader { /** * Retrieves whether or not the shader is ready. */ - [[nodiscard]] bool IsValid() const { return ::IsShaderValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsShaderValid(*this); } protected: void set(const ::Shader& shader) { id = shader.id; diff --git a/include/SoundUnmanaged.hpp b/include/SoundUnmanaged.hpp index 3ea632dc..4237ad15 100644 --- a/include/SoundUnmanaged.hpp +++ b/include/SoundUnmanaged.hpp @@ -140,7 +140,7 @@ class SoundUnmanaged : public ::Sound { /** * Check if a sound is currently playing. */ - [[nodiscard]] bool IsPlaying() const { return ::IsSoundPlaying(*this); } + RLCPP_NODISCARD bool IsPlaying() const { return ::IsSoundPlaying(*this); } /** * Set volume for a sound (1.0 is max level). @@ -171,7 +171,7 @@ class SoundUnmanaged : public ::Sound { * * @return True or false depending on whether the Sound buffer is loaded. */ - [[nodiscard]] bool IsValid() const { return ::IsSoundValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsSoundValid(*this); } protected: void set(const ::Sound& sound) { diff --git a/include/Text.hpp b/include/Text.hpp index 6a2100b7..f7b692ed 100644 --- a/include/Text.hpp +++ b/include/Text.hpp @@ -120,12 +120,12 @@ class Text { /** * Measure string width for default font */ - [[nodiscard]] int Measure() const { return ::MeasureText(text.c_str(), static_cast(fontSize)); } + RLCPP_NODISCARD int Measure() const { return ::MeasureText(text.c_str(), static_cast(fontSize)); } /** * Measure string size for Font */ - [[nodiscard]] Vector2 MeasureEx() const { return ::MeasureTextEx(font, text.c_str(), fontSize, spacing); } + RLCPP_NODISCARD Vector2 MeasureEx() const { return ::MeasureTextEx(font, text.c_str(), fontSize, spacing); } Text& operator=(const Text& other) { if (this == &other) { diff --git a/include/TextureUnmanaged.hpp b/include/TextureUnmanaged.hpp index fa65431f..3b5cfa15 100644 --- a/include/TextureUnmanaged.hpp +++ b/include/TextureUnmanaged.hpp @@ -89,7 +89,7 @@ class TextureUnmanaged : public ::Texture { /** * Retrieve the width and height of the texture. */ - [[nodiscard]] Vector2 GetSize() const { return {static_cast(width), static_cast(height)}; } + RLCPP_NODISCARD Vector2 GetSize() const { return {static_cast(width), static_cast(height)}; } /** * Load texture from image data @@ -151,7 +151,7 @@ class TextureUnmanaged : public ::Texture { /** * Get pixel data from GPU texture and return an Image */ - [[nodiscard]] ::Image GetData() const { return ::LoadImageFromTexture(*this); } + RLCPP_NODISCARD ::Image GetData() const { return ::LoadImageFromTexture(*this); } /** * Get pixel data from GPU texture and return an Image @@ -319,7 +319,7 @@ class TextureUnmanaged : public ::Texture { * * @return True or false depending on whether the Texture has data. */ - [[nodiscard]] bool IsValid() const { return IsTextureValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return IsTextureValid(*this); } protected: void set(const ::Texture& texture) { id = texture.id; diff --git a/include/Touch.hpp b/include/Touch.hpp index 86326d96..54d92940 100644 --- a/include/Touch.hpp +++ b/include/Touch.hpp @@ -12,35 +12,35 @@ namespace Touch { /** * Get touch position X for touch point 0 (relative to screen size) */ -[[maybe_unused]] RLCPPAPI inline int GetX() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetX() { return ::GetTouchX(); } /** * Get touch position Y for touch point 0 (relative to screen size) */ -[[maybe_unused]] RLCPPAPI inline int GetY() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetY() { return ::GetTouchY(); } /** * Get touch position XY for a touch point index (relative to screen size) */ -[[maybe_unused]] RLCPPAPI inline Vector2 GetPosition(int index) { +RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetPosition(int index) { return ::GetTouchPosition(index); } /** * Get touch point identifier for given index */ -[[maybe_unused]] RLCPPAPI inline int GetPointId(int index) { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetPointId(int index) { return ::GetTouchPointId(index); } /** * Get number of touch points */ -[[maybe_unused]] RLCPPAPI inline int GetPointCount() { +RLCPP_MAYBEUNUSED RLCPPAPI inline int GetPointCount() { return ::GetTouchPointCount(); } } // namespace Touch diff --git a/include/Vector2.hpp b/include/Vector2.hpp index 1528f228..3cf1fbe1 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -42,7 +42,7 @@ class Vector2 : public ::Vector2 { */ constexpr bool operator!=(const ::Vector2& other) const { return !(*this == other); } - [[nodiscard]] std::string ToString() const { return TextFormat("Vector2(%f, %f)", x, y); } + RLCPP_NODISCARD std::string ToString() const { return TextFormat("Vector2(%f, %f)", x, y); } operator std::string() const { return ToString(); } @@ -92,7 +92,7 @@ class Vector2 : public ::Vector2 { /** * Subtract two vectors (v1 - v2) */ - [[nodiscard]] Vector2 Subtract(const ::Vector2& vector2) const { return Vector2Subtract(*this, vector2); } + RLCPP_NODISCARD Vector2 Subtract(const ::Vector2& vector2) const { return Vector2Subtract(*this, vector2); } /** * Subtract two vectors (v1 - v2) @@ -111,7 +111,7 @@ class Vector2 : public ::Vector2 { /** * Subtract vector by float value */ - [[nodiscard]] Vector2 Subtract(float value) const { + RLCPP_NODISCARD Vector2 Subtract(float value) const { return Vector2SubtractValue(*this, value); } @@ -134,7 +134,7 @@ class Vector2 : public ::Vector2 { /** * Negate vector */ - [[nodiscard]] Vector2 Negate() const { return Vector2Negate(*this); } + RLCPP_NODISCARD Vector2 Negate() const { return Vector2Negate(*this); } /** * Negate vector @@ -144,7 +144,7 @@ class Vector2 : public ::Vector2 { /** * Multiply vector by vector */ - [[nodiscard]] Vector2 Multiply(const ::Vector2& vector2) const { return Vector2Multiply(*this, vector2); } + RLCPP_NODISCARD Vector2 Multiply(const ::Vector2& vector2) const { return Vector2Multiply(*this, vector2); } /** * Multiply vector by vector @@ -163,7 +163,7 @@ class Vector2 : public ::Vector2 { /** * Scale vector (multiply by value) */ - [[nodiscard]] Vector2 Scale(const float scale) const { return Vector2Scale(*this, scale); } + RLCPP_NODISCARD Vector2 Scale(const float scale) const { return Vector2Scale(*this, scale); } /** * Scale vector (multiply by value) @@ -182,7 +182,7 @@ class Vector2 : public ::Vector2 { /** * Divide vector by vector */ - [[nodiscard]] Vector2 Divide(const ::Vector2& vector2) const { return Vector2Divide(*this, vector2); } + RLCPP_NODISCARD Vector2 Divide(const ::Vector2& vector2) const { return Vector2Divide(*this, vector2); } /** @@ -202,7 +202,7 @@ class Vector2 : public ::Vector2 { /** * Divide vector by value */ - [[nodiscard]] Vector2 Divide(const float div) const { return ::Vector2{x / div, y / div}; } + RLCPP_NODISCARD Vector2 Divide(const float div) const { return ::Vector2{x / div, y / div}; } /** * Divide vector by value @@ -222,84 +222,84 @@ class Vector2 : public ::Vector2 { /** * Normalize provided vector */ - [[nodiscard]] Vector2 Normalize() const { return Vector2Normalize(*this); } + RLCPP_NODISCARD Vector2 Normalize() const { return Vector2Normalize(*this); } /** * Transforms a Vector2 by a given Matrix */ - [[nodiscard]] Vector2 Transform(::Matrix mat) const { return ::Vector2Transform(*this, mat); } + RLCPP_NODISCARD Vector2 Transform(::Matrix mat) const { return ::Vector2Transform(*this, mat); } /** * Calculate linear interpolation between two vectors */ - [[nodiscard]] Vector2 Lerp(const ::Vector2& vector2, float amount) const { return Vector2Lerp(*this, vector2, amount); } + RLCPP_NODISCARD Vector2 Lerp(const ::Vector2& vector2, float amount) const { return Vector2Lerp(*this, vector2, amount); } /** * Calculate reflected vector to normal */ - [[nodiscard]] Vector2 Reflect(const ::Vector2& normal) const { return Vector2Reflect(*this, normal); } + RLCPP_NODISCARD Vector2 Reflect(const ::Vector2& normal) const { return Vector2Reflect(*this, normal); } /** * Rotate Vector by float in radians */ - [[nodiscard]] Vector2 Rotate(float angle) const { return Vector2Rotate(*this, angle); } + RLCPP_NODISCARD Vector2 Rotate(float angle) const { return Vector2Rotate(*this, angle); } /** * Move Vector towards target */ - [[nodiscard]] Vector2 MoveTowards(const ::Vector2& target, float maxDistance) const { + RLCPP_NODISCARD Vector2 MoveTowards(const ::Vector2& target, float maxDistance) const { return Vector2MoveTowards(*this, target, maxDistance); } /** * Invert the given vector */ - [[nodiscard]] Vector2 Invert() const { return ::Vector2Invert(*this); } + RLCPP_NODISCARD Vector2 Invert() const { return ::Vector2Invert(*this); } /** * Clamp the components of the vector between */ - [[nodiscard]] Vector2 Clamp(::Vector2 min, ::Vector2 max) const { return ::Vector2Clamp(*this, min, max); } + RLCPP_NODISCARD Vector2 Clamp(::Vector2 min, ::Vector2 max) const { return ::Vector2Clamp(*this, min, max); } /** * // Clamp the magnitude of the vector between two min and max values */ - [[nodiscard]] Vector2 Clamp(float min, float max) const { return ::Vector2ClampValue(*this, min, max); } + RLCPP_NODISCARD Vector2 Clamp(float min, float max) const { return ::Vector2ClampValue(*this, min, max); } /** * Check whether two given vectors are almost equal */ - [[nodiscard]] int Equals(::Vector2 q) const { return ::Vector2Equals(*this, q); } + RLCPP_NODISCARD int Equals(::Vector2 q) const { return ::Vector2Equals(*this, q); } /** * Calculate vector length */ - [[nodiscard]] float Length() const { return Vector2Length(*this); } + RLCPP_NODISCARD float Length() const { return Vector2Length(*this); } /** * Calculate vector square length */ - [[nodiscard]] float LengthSqr() const { return Vector2LengthSqr(*this); } + RLCPP_NODISCARD float LengthSqr() const { return Vector2LengthSqr(*this); } /** * Calculate two vectors dot product */ - [[nodiscard]] float DotProduct(const ::Vector2& vector2) const { return Vector2DotProduct(*this, vector2); } + RLCPP_NODISCARD float DotProduct(const ::Vector2& vector2) const { return Vector2DotProduct(*this, vector2); } /** * Calculate distance between two vectors */ - [[nodiscard]] float Distance(const ::Vector2& vector2) const { return Vector2Distance(*this, vector2); } + RLCPP_NODISCARD float Distance(const ::Vector2& vector2) const { return Vector2Distance(*this, vector2); } /** * Calculate square distance between two vectors */ - [[nodiscard]] float DistanceSqr(::Vector2 v2) const { return ::Vector2DistanceSqr(*this, v2); } + RLCPP_NODISCARD float DistanceSqr(::Vector2 v2) const { return ::Vector2DistanceSqr(*this, v2); } /** * Calculate angle from two vectors in X-axis */ - [[nodiscard]] float Angle(const ::Vector2& vector2) const { return Vector2Angle(*this, vector2); } + RLCPP_NODISCARD float Angle(const ::Vector2& vector2) const { return Vector2Angle(*this, vector2); } /** * Vector with components value 0.0f @@ -338,33 +338,33 @@ class Vector2 : public ::Vector2 { /** * Check collision between two circles */ - [[nodiscard]] bool CheckCollisionCircle(float radius1, ::Vector2 center2, float radius2) const { + RLCPP_NODISCARD bool CheckCollisionCircle(float radius1, ::Vector2 center2, float radius2) const { return ::CheckCollisionCircles(*this, radius1, center2, radius2); } /** * Check collision between circle and rectangle */ - [[nodiscard]] bool CheckCollisionCircle(float radius, ::Rectangle rec) const { + RLCPP_NODISCARD bool CheckCollisionCircle(float radius, ::Rectangle rec) const { return ::CheckCollisionCircleRec(*this, radius, rec); } /** * Check if point is inside rectangle */ - [[nodiscard]] bool CheckCollision(::Rectangle rec) const { return ::CheckCollisionPointRec(*this, rec); } + RLCPP_NODISCARD bool CheckCollision(::Rectangle rec) const { return ::CheckCollisionPointRec(*this, rec); } /** * Check if point is inside circle */ - [[nodiscard]] bool CheckCollision(::Vector2 center, float radius) const { + RLCPP_NODISCARD bool CheckCollision(::Vector2 center, float radius) const { return ::CheckCollisionPointCircle(*this, center, radius); } /** * Check if point is inside a triangle */ - [[nodiscard]] bool CheckCollision(::Vector2 p1, ::Vector2 p2, ::Vector2 p3) const { + RLCPP_NODISCARD bool CheckCollision(::Vector2 p1, ::Vector2 p2, ::Vector2 p3) const { return ::CheckCollisionPointTriangle(*this, p1, p2, p3); } @@ -379,7 +379,7 @@ class Vector2 : public ::Vector2 { /** * Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] */ - [[nodiscard]] bool CheckCollisionPointLine(::Vector2 p1, ::Vector2 p2, int threshold = 1) const { + RLCPP_NODISCARD bool CheckCollisionPointLine(::Vector2 p1, ::Vector2 p2, int threshold = 1) const { return ::CheckCollisionPointLine(*this, p1, p2, threshold); } protected: diff --git a/include/Vector3.hpp b/include/Vector3.hpp index 225fc6e9..dc338200 100644 --- a/include/Vector3.hpp +++ b/include/Vector3.hpp @@ -36,7 +36,7 @@ class Vector3 : public ::Vector3 { constexpr bool operator!=(const ::Vector3& other) const { return !(*this == other); } - [[nodiscard]] std::string ToString() const { return TextFormat("Vector3(%f, %f, %f)", x, y, z); } + RLCPP_NODISCARD std::string ToString() const { return TextFormat("Vector3(%f, %f, %f)", x, y, z); } operator std::string() const { return ToString(); } @@ -44,7 +44,7 @@ class Vector3 : public ::Vector3 { /** * Add two vectors */ - [[nodiscard]] Vector3 Add(const ::Vector3& vector3) const { return Vector3Add(*this, vector3); } + RLCPP_NODISCARD Vector3 Add(const ::Vector3& vector3) const { return Vector3Add(*this, vector3); } /** * Add two vectors @@ -60,7 +60,7 @@ class Vector3 : public ::Vector3 { /** * Add vector and float value */ - [[nodiscard]] Vector3 Add(float value) const { + RLCPP_NODISCARD Vector3 Add(float value) const { return Vector3AddValue(*this, value); } @@ -80,7 +80,7 @@ class Vector3 : public ::Vector3 { /** * Subtract two vectors. */ - [[nodiscard]] Vector3 Subtract(const ::Vector3& vector3) const { return Vector3Subtract(*this, vector3); } + RLCPP_NODISCARD Vector3 Subtract(const ::Vector3& vector3) const { return Vector3Subtract(*this, vector3); } /** * Subtract two vectors. @@ -96,7 +96,7 @@ class Vector3 : public ::Vector3 { /** * Subtract vector by float value */ - [[nodiscard]] Vector3 Subtract(float value) const { + RLCPP_NODISCARD Vector3 Subtract(float value) const { return Vector3SubtractValue(*this, value); } @@ -116,7 +116,7 @@ class Vector3 : public ::Vector3 { /** * Negate provided vector (invert direction) */ - [[nodiscard]] Vector3 Negate() const { return Vector3Negate(*this); } + RLCPP_NODISCARD Vector3 Negate() const { return Vector3Negate(*this); } /** * Negate provided vector (invert direction) @@ -126,7 +126,7 @@ class Vector3 : public ::Vector3 { /** * Multiply vector by vector */ - [[nodiscard]] Vector3 Multiply(const ::Vector3& vector3) const { return Vector3Multiply(*this, vector3); } + RLCPP_NODISCARD Vector3 Multiply(const ::Vector3& vector3) const { return Vector3Multiply(*this, vector3); } /** * Multiply vector by vector @@ -145,7 +145,7 @@ class Vector3 : public ::Vector3 { /** * Multiply vector by scalar */ - [[nodiscard]] Vector3 Scale(const float scaler) const { return Vector3Scale(*this, scaler); } + RLCPP_NODISCARD Vector3 Scale(const float scaler) const { return Vector3Scale(*this, scaler); } /** * Multiply vector by scalar @@ -164,7 +164,7 @@ class Vector3 : public ::Vector3 { /** * Divide vector by vector */ - [[nodiscard]] Vector3 Divide(const ::Vector3& vector3) const { return Vector3Divide(*this, vector3); } + RLCPP_NODISCARD Vector3 Divide(const ::Vector3& vector3) const { return Vector3Divide(*this, vector3); } /** * Divide vector by vector @@ -185,7 +185,7 @@ class Vector3 : public ::Vector3 { /** * Divide a vector by a value. */ - [[nodiscard]] Vector3 Divide(const float div) const { return ::Vector3{x / div, y / div, z / div}; } + RLCPP_NODISCARD Vector3 Divide(const float div) const { return ::Vector3{x / div, y / div, z / div}; } /** * Divide a vector by a value. @@ -206,44 +206,44 @@ class Vector3 : public ::Vector3 { /** * Calculate vector length */ - [[nodiscard]] float Length() const { return Vector3Length(*this); } + RLCPP_NODISCARD float Length() const { return Vector3Length(*this); } /** * Calculate vector square length */ - [[nodiscard]] float LengthSqr() const { return Vector3LengthSqr(*this); } + RLCPP_NODISCARD float LengthSqr() const { return Vector3LengthSqr(*this); } - [[nodiscard]] Vector3 Normalize() const { return Vector3Normalize(*this); } + RLCPP_NODISCARD Vector3 Normalize() const { return Vector3Normalize(*this); } - [[nodiscard]] float DotProduct(const ::Vector3& vector3) const { return Vector3DotProduct(*this, vector3); } + RLCPP_NODISCARD float DotProduct(const ::Vector3& vector3) const { return Vector3DotProduct(*this, vector3); } - [[nodiscard]] float Distance(const ::Vector3& vector3) const { return Vector3Distance(*this, vector3); } + RLCPP_NODISCARD float Distance(const ::Vector3& vector3) const { return Vector3Distance(*this, vector3); } - [[nodiscard]] Vector3 Lerp(const ::Vector3& vector3, const float amount) const { return Vector3Lerp(*this, vector3, amount); } + RLCPP_NODISCARD Vector3 Lerp(const ::Vector3& vector3, const float amount) const { return Vector3Lerp(*this, vector3, amount); } - [[nodiscard]] Vector3 CrossProduct(const ::Vector3& vector3) const { return Vector3CrossProduct(*this, vector3); } + RLCPP_NODISCARD Vector3 CrossProduct(const ::Vector3& vector3) const { return Vector3CrossProduct(*this, vector3); } - [[nodiscard]] Vector3 Perpendicular() const { return Vector3Perpendicular(*this); } + RLCPP_NODISCARD Vector3 Perpendicular() const { return Vector3Perpendicular(*this); } - [[nodiscard]] Vector3 Project(const ::Vector3& vector3) const { return Vector3Project(*this, vector3); } + RLCPP_NODISCARD Vector3 Project(const ::Vector3& vector3) const { return Vector3Project(*this, vector3); } - [[nodiscard]] Vector3 Reject(const ::Vector3& vector3) const { return Vector3Reject(*this, vector3); } + RLCPP_NODISCARD Vector3 Reject(const ::Vector3& vector3) const { return Vector3Reject(*this, vector3); } void OrthoNormalize(::Vector3* vector3) { Vector3OrthoNormalize(this, vector3); } - [[nodiscard]] Vector3 Transform(const ::Matrix& matrix) const { return Vector3Transform(*this, matrix); } + RLCPP_NODISCARD Vector3 Transform(const ::Matrix& matrix) const { return Vector3Transform(*this, matrix); } - [[nodiscard]] Vector3 RotateByQuaternion(const ::Quaternion& quaternion) const { + RLCPP_NODISCARD Vector3 RotateByQuaternion(const ::Quaternion& quaternion) const { return Vector3RotateByQuaternion(*this, quaternion); } - [[nodiscard]] Vector3 Reflect(const ::Vector3& normal) const { return Vector3Reflect(*this, normal); } + RLCPP_NODISCARD Vector3 Reflect(const ::Vector3& normal) const { return Vector3Reflect(*this, normal); } - [[nodiscard]] Vector3 Min(const ::Vector3& vector3) const { return Vector3Min(*this, vector3); } + RLCPP_NODISCARD Vector3 Min(const ::Vector3& vector3) const { return Vector3Min(*this, vector3); } - [[nodiscard]] Vector3 Max(const ::Vector3& vector3) const { return Vector3Max(*this, vector3); } + RLCPP_NODISCARD Vector3 Max(const ::Vector3& vector3) const { return Vector3Max(*this, vector3); } - [[nodiscard]] Vector3 Barycenter(const ::Vector3& a, const ::Vector3& b, const ::Vector3& c) const { + RLCPP_NODISCARD Vector3 Barycenter(const ::Vector3& a, const ::Vector3& b, const ::Vector3& c) const { return Vector3Barycenter(*this, a, b, c); } @@ -295,7 +295,7 @@ class Vector3 : public ::Vector3 { /** * Detect collision between two spheres */ - [[nodiscard]] bool CheckCollision(float radius1, const ::Vector3& center2, float radius2) const { + RLCPP_NODISCARD bool CheckCollision(float radius1, const ::Vector3& center2, float radius2) const { return CheckCollisionSpheres(*this, radius1, center2, radius2); } protected: diff --git a/include/Vector4.hpp b/include/Vector4.hpp index 39221531..71593717 100644 --- a/include/Vector4.hpp +++ b/include/Vector4.hpp @@ -41,39 +41,39 @@ class Vector4 : public ::Vector4 { constexpr bool operator!=(const ::Vector4& other) const { return !(*this == other); } - [[nodiscard]] constexpr ::Rectangle ToRectangle() const { return {x, y, z, w}; } + RLCPP_NODISCARD constexpr ::Rectangle ToRectangle() const { return {x, y, z, w}; } constexpr operator ::Rectangle() const { return {x, y, z, w}; } - [[nodiscard]] std::string ToString() const { return TextFormat("Vector4(%f, %f, %f, %f)", x, y, z, w); } + RLCPP_NODISCARD std::string ToString() const { return TextFormat("Vector4(%f, %f, %f, %f)", x, y, z, w); } operator std::string() const { return ToString(); } #ifndef RAYLIB_CPP_NO_MATH - [[nodiscard]] Vector4 Multiply(const ::Vector4& vector4) const { return QuaternionMultiply(*this, vector4); } + RLCPP_NODISCARD Vector4 Multiply(const ::Vector4& vector4) const { return QuaternionMultiply(*this, vector4); } Vector4 operator*(const ::Vector4& vector4) const { return QuaternionMultiply(*this, vector4); } - [[nodiscard]] Vector4 Lerp(const ::Vector4& vector4, float amount) const { return QuaternionLerp(*this, vector4, amount); } + RLCPP_NODISCARD Vector4 Lerp(const ::Vector4& vector4, float amount) const { return QuaternionLerp(*this, vector4, amount); } - [[nodiscard]] Vector4 Nlerp(const ::Vector4& vector4, float amount) const { return QuaternionNlerp(*this, vector4, amount); } + RLCPP_NODISCARD Vector4 Nlerp(const ::Vector4& vector4, float amount) const { return QuaternionNlerp(*this, vector4, amount); } - [[nodiscard]] Vector4 Slerp(const ::Vector4& vector4, float amount) const { return QuaternionSlerp(*this, vector4, amount); } + RLCPP_NODISCARD Vector4 Slerp(const ::Vector4& vector4, float amount) const { return QuaternionSlerp(*this, vector4, amount); } - [[nodiscard]] Matrix ToMatrix() const { return QuaternionToMatrix(*this); } + RLCPP_NODISCARD Matrix ToMatrix() const { return QuaternionToMatrix(*this); } - [[nodiscard]] float Length() const { return QuaternionLength(*this); } + RLCPP_NODISCARD float Length() const { return QuaternionLength(*this); } - [[nodiscard]] Vector4 Normalize() const { return QuaternionNormalize(*this); } + RLCPP_NODISCARD Vector4 Normalize() const { return QuaternionNormalize(*this); } - [[nodiscard]] Vector4 Invert() const { return QuaternionInvert(*this); } + RLCPP_NODISCARD Vector4 Invert() const { return QuaternionInvert(*this); } void ToAxisAngle(::Vector3* outAxis, float* outAngle) const { QuaternionToAxisAngle(*this, outAxis, outAngle); } /** * Get the rotation angle and axis for a given quaternion */ - [[nodiscard]] std::pair ToAxisAngle() const { + RLCPP_NODISCARD std::pair ToAxisAngle() const { Vector3 outAxis; float outAngle; QuaternionToAxisAngle(*this, &outAxis, &outAngle); @@ -81,7 +81,7 @@ class Vector4 : public ::Vector4 { return { outAxis, outAngle }; } - [[nodiscard]] Vector4 Transform(const ::Matrix& matrix) const { return ::QuaternionTransform(*this, matrix); } + RLCPP_NODISCARD Vector4 Transform(const ::Matrix& matrix) const { return ::QuaternionTransform(*this, matrix); } static Vector4 Identity() { return ::QuaternionIdentity(); } @@ -103,10 +103,10 @@ class Vector4 : public ::Vector4 { return ::QuaternionFromEuler(vector3.x, vector3.y, vector3.z); } - [[nodiscard]] Vector3 ToEuler() const { return ::QuaternionToEuler(*this); } + RLCPP_NODISCARD Vector3 ToEuler() const { return ::QuaternionToEuler(*this); } #endif - [[nodiscard]] Color ColorFromNormalized() const { return ::ColorFromNormalized(*this); } + RLCPP_NODISCARD Color ColorFromNormalized() const { return ::ColorFromNormalized(*this); } operator Color() const { return ColorFromNormalized(); } protected: diff --git a/include/WaveUnmanaged.hpp b/include/WaveUnmanaged.hpp index 711294a0..c2aa7843 100644 --- a/include/WaveUnmanaged.hpp +++ b/include/WaveUnmanaged.hpp @@ -98,7 +98,7 @@ class WaveUnmanaged : public ::Wave { /** * Copy a wave to a new wave. */ - [[nodiscard]] ::Wave Copy() const { return ::WaveCopy(*this); } + RLCPP_NODISCARD ::Wave Copy() const { return ::WaveCopy(*this); } /** * Crop a wave to defined samples range. @@ -151,7 +151,7 @@ class WaveUnmanaged : public ::Wave { * * @return True or false depending on whether the wave data has been loaded. */ - [[nodiscard]] bool IsValid() const { return ::IsWaveValid(*this); } + RLCPP_NODISCARD bool IsValid() const { return ::IsWaveValid(*this); } protected: void set(const ::Wave& wave) { diff --git a/include/raylib.hpp b/include/raylib.hpp index 94a85719..5c1c0778 100644 --- a/include/raylib.hpp +++ b/include/raylib.hpp @@ -26,6 +26,34 @@ extern "C" { #error "raylib-cpp requires raylib ~6.0. Use the `next` branch for the next version of raylib." #endif +#ifndef RLCPP_MAYBEUNUSED +# if defined(__has_cpp_attribute) +# if __has_cpp_attribute(maybe_unused) && __cplusplus >= 201703L +# define RLCPP_MAYBEUNUSED [[maybe_unused]] +# else +# define RLCPP_MAYBEUNUSED +# endif +# elif (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (__cplusplus >= 201703L) +# define RLCPP_MAYBEUNUSED [[maybe_unused]] +# else +# define RLCPP_MAYBEUNUSED +# endif +#endif + +#ifndef RLCPP_NODISCARD +# if defined(__has_cpp_attribute) +# if __has_cpp_attribute(nodiscard) && __cplusplus >= 201703L +# define RLCPP_NODISCARD [[nodiscard]] +# else +# define RLCPP_NODISCARD +# endif +# elif (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (__cplusplus >= 201703L) +# define RLCPP_NODISCARD [[nodiscard]] +# else +# define RLCPP_NODISCARD +# endif +#endif + #ifdef __cplusplus } #endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e34d5507..f200d50c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,7 +6,7 @@ set(CTEST_CUSTOM_TESTS_IGNORE pkg-config--static) # Executable add_executable(raylib_cpp_test raylib_cpp_test.cpp) if (MSVC) - target_compile_options(raylib_cpp_test PRIVATE /Wall /W4) + target_compile_options(raylib_cpp_test PRIVATE /W4) else() target_compile_options(raylib_cpp_test PRIVATE -Wall -Wextra -Wconversion -Wsign-conversion -Weffc++) endif() diff --git a/tests/raylib-assert.h b/tests/raylib-assert.h index 7745804f..4d701f6d 100644 --- a/tests/raylib-assert.h +++ b/tests/raylib-assert.h @@ -78,8 +78,9 @@ extern "C" { #endif // Variadic Arguments -#define RAYLIB_ASSERT_CAT( A, B ) A ## B -#define RAYLIB_ASSERT_SELECT( NAME, NUM ) RAYLIB_ASSERT_CAT( NAME ## _, NUM ) +#define RAYLIB_ASSERT_CAT(a, b) RAYLIB_ASSERT_CAT_I(a, b) +#define RAYLIB_ASSERT_CAT_I(a, b) a##b +#define RAYLIB_ASSERT_SELECT(name, num) RAYLIB_ASSERT_CAT(name##_, num) #define RAYLIB_ASSERT_GET_COUNT( _1, _2, _3, _4, _5, _6, _7, RAYLIB_ASSERT_COUNT, ... ) RAYLIB_ASSERT_COUNT #define RAYLIB_ASSERT_VA_SIZE( ... ) RAYLIB_ASSERT_GET_COUNT( __VA_ARGS__, 7, 6, 5, 4, 3, 2, 1 ) #define RAYLIB_ASSERT_VA_SELECT( NAME, ... ) RAYLIB_ASSERT_SELECT( NAME, RAYLIB_ASSERT_VA_SIZE(__VA_ARGS__) )(__VA_ARGS__)