diff --git a/CMakeLists.txt b/CMakeLists.txt index f637e9d5..8dfa16bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,20 @@ option(BUILD_RAYLIB_CPP_EXAMPLES "Examples" ${RAYLIB_CPP_IS_MAIN}) # Include Directory add_subdirectory(include) +# Modules +option(BUILD_RAYLIB_CPP_MODULES "Build C++ modules support" OFF) + +if(BUILD_RAYLIB_CPP_MODULES) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + message(STATUS "Building raylib-cpp C++ modules (CMake ${CMAKE_VERSION} supports modules)") + add_subdirectory(modules) + else() + message(WARNING "Skipping raylib-cpp C++ modules (requires CMake 3.28+, found ${CMAKE_VERSION})") + endif() +else() + message(STATUS "raylib-cpp C++ modules support is disabled. Enable with -BUILD_RAYLIB_CPP_MODULES=ON") +endif() + # Examples if(BUILD_RAYLIB_CPP_EXAMPLES) add_subdirectory(examples) diff --git a/README.md b/README.md index 70566007..dd5b59f3 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,27 @@ raylib::Vector2 direction(50, 50); raylib::Vector2 newDirection = direction.Rotate(30); ``` +### Modules + +If using C++20 or later, by passing `BUILD_RAYLIB_CPP_MODULES` to the build system the library may be imported as a module by using `import raylib;`. + +```cpp +import raylib; + +using raylib::Texture; +using raylib::Window; + +int main() { + int screenWidth = 800; + int screenHeight = 450; + + Window window(screenWidth, screenHeight, "raylib-cpp - basic window"); + Texture logo("raylib_logo.png"); + + // ... +} +``` + ## Getting Started *raylib-cpp* is a header-only library. This means in order to use it, you must link your project to [raylib](https://www.raylib.com/), and then include [`raylib-cpp.hpp`](raylib-cpp/include/raylib-cpp.hpp). diff --git a/examples/core/core_basic_window.cpp b/examples/core/core_basic_window.cpp index 68a17090..7df35381 100644 --- a/examples/core/core_basic_window.cpp +++ b/examples/core/core_basic_window.cpp @@ -41,12 +41,10 @@ int main() { // Draw //---------------------------------------------------------------------------------- - BeginDrawing(); - { + while (window.Drawing()) { window.ClearBackground(RAYWHITE); textColor.DrawText("Congrats! You created your first window!", 190, 200, 20); } - EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/include/Camera3D.hpp b/include/Camera3D.hpp index 74da8b9e..42b180c8 100644 --- a/include/Camera3D.hpp +++ b/include/Camera3D.hpp @@ -25,9 +25,9 @@ class Camera3D : public ::Camera3D { */ Camera3D( ::Vector3 position, - ::Vector3 target = ::Vector3{0.0f, 0.0f, 0.0f}, + ::Vector3 target = ::Vector3{0.0f, 0.0f, -1.0f}, ::Vector3 up = ::Vector3{0.0f, 1.0f, 0.0f}, - float fovy = 0, + float fovy = 45.0f, int projection = CAMERA_PERSPECTIVE) : ::Camera3D{position, target, up, fovy, projection} {} diff --git a/include/FileData.hpp b/include/FileData.hpp index 7c880106..979179fb 100644 --- a/include/FileData.hpp +++ b/include/FileData.hpp @@ -31,12 +31,16 @@ class FileData { GETTER(int, BytesRead, bytesRead) void Load(const std::string& fileName) { Load(fileName.c_str()); } - void Load(const char* fileName) { data = ::LoadFileData(fileName, &bytesRead); } + void Load(const char* fileName) { + Unload(); + data = ::LoadFileData(fileName, &bytesRead); + } void Unload() { if (data != nullptr) { ::UnloadFileData(data); data = nullptr; + bytesRead = 0; } } private: diff --git a/include/Functions.hpp b/include/Functions.hpp index 901815fa..27b083ca 100644 --- a/include/Functions.hpp +++ b/include/Functions.hpp @@ -393,7 +393,7 @@ TextReplace(const std::string& text, const std::string& replace, const std::stri */ [[maybe_unused]] RLCPPAPI std::vector TextSplit(const std::string& text, char delimiter) { int count; - const char** split = ::TextSplit(text.c_str(), delimiter, &count); + const char* const* split = ::TextSplit(text.c_str(), delimiter, &count); return std::vector(split, split + count); } diff --git a/include/Gamepad.hpp b/include/Gamepad.hpp index 83a82e9c..0362020c 100644 --- a/include/Gamepad.hpp +++ b/include/Gamepad.hpp @@ -12,7 +12,7 @@ namespace raylib { */ class Gamepad { public: - Gamepad(int gamepadNumber = 0) { set(gamepadNumber); } + Gamepad(int gamepadNumber = 0) : number(gamepadNumber) {}; int number; GETTERSETTER(int, Number, number) diff --git a/include/TextureUnmanaged.hpp b/include/TextureUnmanaged.hpp index c561e6e1..fa65431f 100644 --- a/include/TextureUnmanaged.hpp +++ b/include/TextureUnmanaged.hpp @@ -294,7 +294,7 @@ class TextureUnmanaged : public ::Texture { } TextureUnmanaged& SetMaterial(const ::Material& material, int mapType = MATERIAL_MAP_NORMAL) { - ::SetMaterialTexture((::Material*)(&material), mapType, *this); + ::SetMaterialTexture(const_cast<::Material*>(&material), mapType, *this); return *this; } diff --git a/include/Vector2.hpp b/include/Vector2.hpp index b351edd9..bcbb8387 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -68,6 +68,29 @@ class Vector2 : public ::Vector2 { return *this; } + /** + * Add vector and float value + */ + Vector2 Add(float value) const { + return Vector2AddValue(*this, value); + } + + /** + * Add vector and float value + */ + Vector2 operator+(float value) const { + return Vector2AddValue(*this, value); + } + + /** + * Add vector and float value + */ + Vector2& operator+=(float value) { + set(Vector2AddValue(*this, value)); + + return *this; + } + /** * Subtract two vectors (v1 - v2) */ @@ -87,6 +110,29 @@ class Vector2 : public ::Vector2 { return *this; } + /** + * Subtract vector by float value + */ + [[nodiscard]] Vector2 Subtract(float value) const { + return Vector2SubtractValue(*this, value); + } + + /** + * Subtract vector by float value + */ + Vector2 operator-(float value) const { + return Vector2SubtractValue(*this, value); + } + + /** + * Subtract vector by float value + */ + Vector2& operator-=(float value) { + set(Vector2SubtractValue(*this, value)); + + return *this; + } + /** * Negate vector */ diff --git a/include/Vector3.hpp b/include/Vector3.hpp index 99d54e97..c4fbb8f3 100644 --- a/include/Vector3.hpp +++ b/include/Vector3.hpp @@ -22,7 +22,7 @@ class Vector3 : public ::Vector3 { Vector3(float x, float y, float z) : ::Vector3{x, y, z} {} Vector3(float x, float y) : ::Vector3{x, y, 0} {} Vector3(float x) : ::Vector3{x, 0, 0} {} - Vector3() {} + Vector3() : ::Vector3{0, 0, 0} {} Vector3(::Color color) { set(ColorToHSV(color)); } @@ -60,6 +60,26 @@ class Vector3 : public ::Vector3 { return *this; } + /** + * Add vector and float value + */ + [[nodiscard]] Vector3 Add(float value) const { + return Vector3AddValue(*this, value); + } + + /** + * Add vector and float value + */ + Vector3 operator+(float value) const { + return Vector3AddValue(*this, value); + } + + Vector3& operator+=(float value) { + set(Vector3AddValue(*this, value)); + + return *this; + } + /** * Subtract two vectors. */ @@ -76,6 +96,26 @@ class Vector3 : public ::Vector3 { return *this; } + /** + * Subtract vector by float value + */ + [[nodiscard]] Vector3 Subtract(float value) const { + return Vector3SubtractValue(*this, value); + } + + /** + * Subtract vector by float value + */ + Vector3 operator-(float value) const { + return Vector3SubtractValue(*this, value); + } + + Vector3& operator-=(float value) { + set(Vector3SubtractValue(*this, value)); + + return *this; + } + /** * Negate provided vector (invert direction) */ diff --git a/include/Window.hpp b/include/Window.hpp index 34a42187..20c5138d 100644 --- a/include/Window.hpp +++ b/include/Window.hpp @@ -27,14 +27,15 @@ class Window { * @param height The height of the window. * @param title The desired title of the window. * @param flags The ConfigFlags to set prior to initializing the window. See SetConfigFlags for more details. + * @param logLevel The the current threshold (minimum) log level * * @see ::SetConfigFlags() * @see ConfigFlags * * @throws raylib::RaylibException Thrown if the window failed to initiate. */ - Window(int width, int height, const std::string& title = "raylib", unsigned int flags = 0) { - Init(width, height, title, flags); + Window(int width, int height, const std::string& title = "raylib", unsigned int flags = 0, TraceLogLevel logLevel = LOG_ALL) { + Init(width, height, title, flags, logLevel); } /** @@ -55,10 +56,11 @@ class Window { * * @throws raylib::RaylibException Thrown if the window failed to initiate. */ - static void Init(int width = 800, int height = 450, const std::string& title = "raylib", unsigned int flags = 0) { + static void Init(int width = 800, int height = 450, const std::string& title = "raylib", unsigned int flags = 0, TraceLogLevel logLevel = LOG_ALL) { if (flags != 0) { ::SetConfigFlags(flags); } + ::SetTraceLogLevel(logLevel); ::InitWindow(width, height, title.c_str()); if (!::IsWindowReady()) { throw RaylibException("Failed to create Window"); @@ -89,6 +91,21 @@ class Window { */ static bool IsCursorOnScreen() { return ::IsCursorOnScreen(); } + /** + * Check if cursor is not visible + */ + static bool IsCursorHidden() { return ::IsCursorHidden(); } + + /** + * Hides cursor + */ + static void HideCursor() { ::HideCursor(); } + + /** + * Shows cursor + */ + static void ShowCursor() { ::ShowCursor(); } + /** * Check if window is currently fullscreen */ @@ -349,6 +366,11 @@ class Window { */ static Vector2 GetPosition() { return ::GetWindowPosition(); } + /* + * Get current window monitor + */ + static int GetMonitor() { return ::GetCurrentMonitor(); } + /** * Get window scale DPI factor */ @@ -405,6 +427,38 @@ class Window { * @see ::SetConfigFlags */ static void SetConfigFlags(unsigned int flags) { ::SetConfigFlags(flags); } + + /** + * Alternates between calling `BeginDrawing()` and `EndDrawing()`. + * + * @code + * while (window.Drawing()) { + * DrawRectangle(); + * } + * @endcode + * + * @return True if we're within the `BeginDrawing()` scope. + */ + bool Drawing() { + if (m_drawing) { + EndDrawing(); + m_drawing = false; + } + else { + BeginDrawing(); + m_drawing = true; + } + + return m_drawing; + } + + protected: + /** + * Handles the internal drawing state for calling either `BeginDrawing()` or `EndDrawing()` from the `Drawing()` function. + * + * @see Drawing() + */ + bool m_drawing = false; }; } // namespace raylib diff --git a/include/raymath.hpp b/include/raymath.hpp index f166488e..41e37cf3 100644 --- a/include/raymath.hpp +++ b/include/raymath.hpp @@ -8,9 +8,11 @@ extern "C" { #endif #ifndef RAYLIB_CPP_NO_MATH +#ifndef BUILD_RAYLIB_CPP_MODULES #ifndef RAYMATH_STATIC_INLINE #define RAYMATH_STATIC_INLINE #endif +#endif #ifdef __GNUC__ #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" diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt new file mode 100644 index 00000000..b61a34fd --- /dev/null +++ b/modules/CMakeLists.txt @@ -0,0 +1,30 @@ +file(GLOB_RECURSE RAYLIB_CPP_MODULES raylib.cppm) + +add_library(raylib_cpp_modules) + +cmake_minimum_required(VERSION 3.28) + +if(NOT COMMAND configure_cpp_module_target) + function(configure_cpp_module_target target) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + target_sources(${target} PUBLIC FILE_SET CXX_MODULES FILES ${RAYLIB_CPP_MODULES}) + else() + message(WARNING "C++ modules require CMake 3.28+. Using standard compilation.") + target_sources(${target} PRIVATE ${RAYLIB_CPP_MODULES}) + endif() + endfunction() +endif() + +configure_cpp_module_target(raylib_cpp_modules) + +target_link_libraries(raylib_cpp_modules + PUBLIC + raylib_cpp +) + +target_include_directories(raylib_cpp_modules + PRIVATE + ${PROJECT_SOURCE_DIR}/include +) + +target_compile_features(raylib_cpp_modules PUBLIC cxx_std_20) \ No newline at end of file diff --git a/modules/raylib.cppm b/modules/raylib.cppm new file mode 100644 index 00000000..e0903f86 --- /dev/null +++ b/modules/raylib.cppm @@ -0,0 +1,294 @@ +/** + * @file raylib.cppm + * @brief Module file exporting all symbols in raylib-cpp. + */ + +module; + +#define BUILD_RAYLIB_CPP_MODULES +#define RLCPPAPI +#define RAYMATH_IMPLEMENTATION +#include "../include/raylib-cpp.hpp" + +#undef LIGHTGRAY +#undef GRAY +#undef DARKGRAY +#undef YELLOW +#undef GOLD +#undef ORANGE +#undef PINK +#undef RED +#undef MAROON +#undef GREEN +#undef LIME +#undef DARKGREEN +#undef SKYBLUE +#undef BLUE +#undef DARKBLUE +#undef PURPLE +#undef VIOLET +#undef DARKPURPLE +#undef BEIGE +#undef BROWN +#undef DARKBROWN +#undef WHITE +#undef BLACK +#undef BLANK +#undef MAGENTA +#undef RAYWHITE + +export module raylib; + +/** + * @namespace raylib + * @brief All raylib-cpp classes and functions appear in the raylib namespace. + */ +export namespace raylib { + // Classes + using raylib::AudioDevice; + using raylib::AudioStream; + using raylib::AutomationEventList; + using raylib::BoundingBox; + using raylib::Camera; // Alias for Camera3D + using raylib::Camera2D; + using raylib::Camera3D; + using raylib::Color; + using raylib::FileData; + using raylib::FileText; + using raylib::Font; + using raylib::Gamepad; + using raylib::Image; + using raylib::Material; + using raylib::Matrix; + using raylib::Mesh; + using raylib::Model; + using raylib::ModelAnimation; + using raylib::Music; + using raylib::Ray; + using raylib::RayCollision; + using raylib::RaylibException; + using raylib::Rectangle; + using raylib::RenderTexture; + using raylib::RenderTexture2D; // Alias for RenderTexture + using raylib::Shader; + using raylib::Sound; + using raylib::Text; + using raylib::Texture; + using raylib::Texture2D; // Alias for Texture + using raylib::TextureCubemap; // Alias for Texture + using raylib::TextureUnmanaged; + using raylib::Texture2DUnmanaged; // Alias for TextureUnmanaged + using raylib::TextureCubemapUnmanaged; // Alias for TextureUnmanaged + using raylib::Vector2; + using raylib::Vector3; + using raylib::Vector4; + using raylib::Quaternion; // Alias for Vector4 + using raylib::VrStereoConfig; + using raylib::Wave; + using raylib::Window; + + // Enums + using ::ConfigFlags; + using ::TraceLogLevel; + using ::KeyboardKey; + using ::MouseButton; + using ::MouseCursor; + using ::GamepadButton; + using ::GamepadAxis; + using ::MaterialMapIndex; + using ::ShaderLocationIndex; + using ::ShaderUniformDataType; + using ::ShaderAttributeDataType; + using ::PixelFormat; + using ::TextureFilter; + using ::TextureWrap; + using ::CubemapLayout; + using ::FontType; + using ::BlendMode; + using ::Gesture; + using ::CameraMode; + using ::CameraProjection; + using ::NPatchLayout; + + // From Functions.hpp + using raylib::InitWindow; + using raylib::SetWindowTitle; + using raylib::GetMonitorName; + using raylib::SetClipboardText; + using raylib::GetClipboardText; + using raylib::TakeScreenshot; + using raylib::GetGamepadName; + using raylib::LoadFileText; + using raylib::SaveFileText; + using raylib::FileExists; + using raylib::DirectoryExists; + using raylib::IsFileExtension; + using raylib::GetFileExtension; + using raylib::GetFileName; + using raylib::GetFileNameWithoutExt; + using raylib::GetDirectoryPath; + using raylib::GetPrevDirectoryPath; + using raylib::GetWorkingDirectory; + using raylib::LoadDirectoryFiles; + using raylib::ChangeDirectory; + using raylib::LoadDroppedFiles; + using raylib::GetFileModTime; + using raylib::OpenURL; + using raylib::LoadImage; + using raylib::LoadImageRaw; + using raylib::LoadImageAnim; + using raylib::LoadImageFromMemory; + using raylib::ExportImage; + using raylib::ExportImageAsCode; + using raylib::DrawText; + using raylib::DrawTextEx; + using raylib::DrawTextPro; + using raylib::LoadFont; + using raylib::LoadFontEx; + using raylib::MeasureText; + using raylib::TextIsEqual; + using raylib::TextLength; + using raylib::TextSubtext; + using raylib::TextReplace; + using raylib::TextInsert; + using raylib::TextSplit; + using raylib::TextFindIndex; + using raylib::TextToUpper; + using raylib::TextToLower; + using raylib::TextToPascal; + using raylib::TextToInteger; + + /** + * @namespace raylib::Colors + * @brief Re-exports all Color macros as inline constexpr + */ + namespace Colors { + inline constexpr ::Color LIGHTGRAY = CLITERAL(::Color){ 200, 200, 200, 255 }; + inline constexpr ::Color GRAY = CLITERAL(::Color){ 130, 130, 130, 255 }; + inline constexpr ::Color DARKGRAY = CLITERAL(::Color){ 80, 80, 80, 255 }; + inline constexpr ::Color YELLOW = CLITERAL(::Color){ 253, 249, 0, 255 }; + inline constexpr ::Color GOLD = CLITERAL(::Color){ 255, 203, 0, 255 }; + inline constexpr ::Color ORANGE = CLITERAL(::Color){ 255, 161, 0, 255 }; + inline constexpr ::Color PINK = CLITERAL(::Color){ 255, 109, 194, 255 }; + inline constexpr ::Color RED = CLITERAL(::Color){ 230, 41, 55, 255 }; + inline constexpr ::Color MAROON = CLITERAL(::Color){ 190, 33, 55, 255 }; + inline constexpr ::Color GREEN = CLITERAL(::Color){ 0, 228, 48, 255 }; + inline constexpr ::Color LIME = CLITERAL(::Color){ 0, 158, 47, 255 }; + inline constexpr ::Color DARKGREEN = CLITERAL(::Color){ 0, 117, 44, 255 }; + inline constexpr ::Color SKYBLUE = CLITERAL(::Color){ 102, 191, 255, 255 }; + inline constexpr ::Color BLUE = CLITERAL(::Color){ 0, 121, 241, 255 }; + inline constexpr ::Color DARKBLUE = CLITERAL(::Color){ 0, 82, 172, 255 }; + inline constexpr ::Color PURPLE = CLITERAL(::Color){ 200, 122, 255, 255 }; + inline constexpr ::Color VIOLET = CLITERAL(::Color){ 135, 60, 190, 255 }; + inline constexpr ::Color DARKPURPLE = CLITERAL(::Color){ 112, 31, 126, 255 }; + inline constexpr ::Color BEIGE = CLITERAL(::Color){ 211, 176, 131, 255 }; + inline constexpr ::Color BROWN = CLITERAL(::Color){ 127, 106, 79, 255 }; + inline constexpr ::Color DARKBROWN = CLITERAL(::Color){ 76, 63, 47, 255 }; + inline constexpr ::Color WHITE = CLITERAL(::Color){ 255, 255, 255, 255 }; + inline constexpr ::Color BLACK = CLITERAL(::Color){ 0, 0, 0, 255 }; + inline constexpr ::Color BLANK = CLITERAL(::Color){ 0, 0, 0, 0 }; + inline constexpr ::Color MAGENTA = CLITERAL(::Color){ 255, 0, 255, 255 }; + inline constexpr ::Color RAYWHITE = CLITERAL(::Color){ 245, 245, 245, 255 }; + } + + /** + * @namespace raylib::Keyboard + * @brief Input-related functions: keyboard + */ + namespace Keyboard { + using raylib::Keyboard::IsKeyPressed; + using raylib::Keyboard::IsKeyPressedRepeat; + using raylib::Keyboard::IsKeyDown; + using raylib::Keyboard::IsKeyReleased; + using raylib::Keyboard::IsKeyUp; + using raylib::Keyboard::GetKeyPressed; + using raylib::Keyboard::GetCharPressed; + } + + /** + * @namespace raylib::Mouse + * @brief Input-related functions: mouse + */ + namespace Mouse { + using raylib::Mouse::IsButtonPressed; + using raylib::Mouse::IsButtonDown; + using raylib::Mouse::IsButtonReleased; + using raylib::Mouse::IsButtonUp; + using raylib::Mouse::GetX; + using raylib::Mouse::GetY; + using raylib::Mouse::SetX; + using raylib::Mouse::SetY; + using raylib::Mouse::GetPosition; + using raylib::Mouse::SetPosition; + using raylib::Mouse::GetDelta; + using raylib::Mouse::SetOffset; + using raylib::Mouse::SetScale; + using raylib::Mouse::GetWheelMove; + using raylib::Mouse::GetWheelMoveV; + using raylib::Mouse::SetCursor; + using raylib::Mouse::GetTouchX; + using raylib::Mouse::GetTouchY; + using raylib::Mouse::GetTouchPosition; + using raylib::Mouse::GetRay; + } + + /** + * @namespace raylib::Touch + * @brief Input-related functions: touch + */ + namespace Touch { + using raylib::Touch::GetX; + using raylib::Touch::GetY; + using raylib::Touch::GetPosition; + using raylib::Touch::GetPointId; + using raylib::Touch::GetPointCount; + } + + +} // namespace raylib + +#ifdef RAYLIB_CPP_R_PREFIXES +export { + using RAudioDevice = raylib::AudioDevice; + using RAudioStream = raylib::AudioStream; + using RAutomationEventList = raylib::AutomationEventList; + using RBoundingBox = raylib::BoundingBox; + using RCamera = raylib::Camera; // Alias for Camera3D + using RCamera2D = raylib::Camera2D; + using RCamera3D = raylib::Camera3D; + using RColor = raylib::Color; + using RFileData = raylib::FileData; + using RFileText = raylib::FileText; + using RFont = raylib::Font; + using RGamepad = raylib::Gamepad; + using RImage = raylib::Image; + using RMaterial = raylib::Material; + using RMatrix = raylib::Matrix; + using RMesh = raylib::Mesh; + using RModel = raylib::Model; + using RModelAnimation = raylib::ModelAnimation; + using RMusic = raylib::Music; + using RRay = raylib::Ray; + using RRayCollision = raylib::RayCollision; + using RRaylibException = raylib::RaylibException; + using RRectangle = raylib::Rectangle; + using RRenderTexture = raylib::RenderTexture; + using RRenderTexture2D = raylib::RenderTexture2D; // Alias for RenderTexture + using RShader = raylib::Shader; + using RSound = raylib::Sound; + using RText = raylib::Text; + using RTexture = raylib::Texture; + using RTexture2D = raylib::Texture2D; // Alias for Texture + using RTextureCubemap = raylib::TextureCubemap; // Alias for Texture + using RTextureUnmanaged = raylib::TextureUnmanaged; + using RTexture2DUnmanaged = raylib::Texture2DUnmanaged; // Alias for TextureUnmanaged + using RTextureCubemapUnmanaged = raylib::TextureCubemapUnmanaged; // Alias for TextureUnmanaged + using RVector2 = raylib::Vector2; + using RVector3 = raylib::Vector3; + using RVector4 = raylib::Vector4; + using RQuaternion = raylib::Quaternion; // Alias for Vector4 + using RVrStereoConfig = raylib::VrStereoConfig; + using RWave = raylib::Wave; + using RWindow = raylib::Window; +} +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b97ad6e5..e34d5507 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,7 +8,7 @@ add_executable(raylib_cpp_test raylib_cpp_test.cpp) if (MSVC) target_compile_options(raylib_cpp_test PRIVATE /Wall /W4) else() - target_compile_options(raylib_cpp_test PRIVATE -Wall -Wextra -Wconversion -Wsign-conversion) + target_compile_options(raylib_cpp_test PRIVATE -Wall -Wextra -Wconversion -Wsign-conversion -Weffc++) endif() target_link_libraries(raylib_cpp_test raylib_cpp raylib) diff --git a/tests/raylib_cpp_test.cpp b/tests/raylib_cpp_test.cpp index 45524095..78f81658 100644 --- a/tests/raylib_cpp_test.cpp +++ b/tests/raylib_cpp_test.cpp @@ -38,6 +38,21 @@ int main(int argc, char* argv[]) { raylib::Vector2 doublesize = size * 2.0f; AssertEqual(size.x, 50); AssertEqual(doublesize.x, 100); + + const raylib::Vector2 zero2d; + AssertEqual(zero2d.x, 0); + AssertEqual(zero2d.y, 0); + + const raylib::Vector3 zero3d; + AssertEqual(zero3d.x, 0); + AssertEqual(zero3d.y, 0); + AssertEqual(zero3d.z, 0); + + const raylib::Vector4 zero4d; + AssertEqual(zero4d.x, 0); + AssertEqual(zero4d.y, 0); + AssertEqual(zero4d.z, 0); + AssertEqual(zero4d.w, 0); } // Color