diff --git a/.clang-format b/.clang-format index d93d5ca3..952c61be 100644 --- a/.clang-format +++ b/.clang-format @@ -160,4 +160,4 @@ Standard: c++11 --- Language: JavaScript IndentWidth: 2 -ColumnLimit: 100 \ No newline at end of file +ColumnLimit: 100 diff --git a/CPPLINT.cfg b/CPPLINT.cfg index b95edeec..1108586f 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -5,3 +5,4 @@ exclude_files=vendor exclude_files=docs filter=-runtime/explicit filter=-legal/copyright +filter=-whitespace/newline diff --git a/examples/audio/audio_music_stream.cpp b/examples/audio/audio_music_stream.cpp index c23407ee..68c7f8da 100644 --- a/examples/audio/audio_music_stream.cpp +++ b/examples/audio/audio_music_stream.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [audio] example - Music playing (streaming) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [audio] example - Music playing (streaming) + * + * This example has been created using raylib 1.3 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2015 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -19,7 +19,7 @@ int main() { raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)"); - raylib::AudioDevice audio; // Initialize audio device + raylib::AudioDevice audio; // Initialize audio device raylib::Music music("resources/target.ogg"); @@ -28,14 +28,14 @@ int main() { float timePlayed = 0.0f; bool pause = false; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- - music.Update(); // Update music buffer with new stream data + music.Update(); // Update music buffer with new stream data // Restart music playing (stop and play) if (IsKeyPressed(KEY_SPACE)) { @@ -49,7 +49,8 @@ int main() { if (pause) { music.Pause(); - } else { + } + else { music.Resume(); } } diff --git a/examples/audio/audio_sound_loading.cpp b/examples/audio/audio_sound_loading.cpp index fbc97034..7deb8ed9 100644 --- a/examples/audio/audio_sound_loading.cpp +++ b/examples/audio/audio_sound_loading.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [audio] example - Sound loading and playing -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [audio] example - Sound loading and playing + * + * This example has been created using raylib 1.0 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2014 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -19,20 +19,20 @@ int main() { raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing"); - raylib::AudioDevice audiodevice; // Initialize audio device + raylib::AudioDevice audiodevice; // Initialize audio device - raylib::Sound fxWav("resources/sound.wav"); // Load WAV audio file - raylib::Sound fxOgg("resources/target.ogg"); // Load OGG audio file + raylib::Sound fxWav("resources/sound.wav"); // Load WAV audio file + raylib::Sound fxOgg("resources/target.ogg"); // Load OGG audio file - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_SPACE)) fxWav.Play(); // Play WAV sound - if (IsKeyPressed(KEY_ENTER)) fxOgg.Play(); // Play OGG sound + if (IsKeyPressed(KEY_SPACE)) fxWav.Play(); // Play WAV sound + if (IsKeyPressed(KEY_ENTER)) fxOgg.Play(); // Play OGG sound //---------------------------------------------------------------------------------- // Draw diff --git a/examples/core/core_basic_window.cpp b/examples/core/core_basic_window.cpp index 7df35381..3874cc5e 100644 --- a/examples/core/core_basic_window.cpp +++ b/examples/core/core_basic_window.cpp @@ -1,23 +1,23 @@ /******************************************************************************************* -* -* raylib [core] example - Basic window -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [core] example - Basic window + * + * Welcome to raylib! + * + * To test examples, just press F6 and execute raylib_compile_execute script + * Note that compiled executable is placed in the same folder as .c file + * + * You can find all basic examples on C:\raylib\raylib\examples folder or + * raylib official webpage: www.raylib.com + * + * Enjoy using raylib. :) + * + * This example has been created using raylib 1.0 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2014 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -33,7 +33,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- // Update your variables here diff --git a/examples/core/core_basic_window_web.cpp b/examples/core/core_basic_window_web.cpp index 7d43df6f..296f788d 100644 --- a/examples/core/core_basic_window_web.cpp +++ b/examples/core/core_basic_window_web.cpp @@ -1,22 +1,22 @@ /******************************************************************************************* -* -* raylib-cpp [core] example - Basic window (adapted for HTML5 platform) -* -* This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI -* As you will notice, code structure is slightly diferent to the other examples... -* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib-cpp [core] example - Basic window (adapted for HTML5 platform) + * + * This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI + * As you will notice, code structure is slightly diferent to the other examples... + * To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning + * + * This example has been created using raylib 1.3 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2015 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" #if defined(PLATFORM_WEB) - #include +#include #endif //---------------------------------------------------------------------------------- @@ -28,13 +28,12 @@ int screenHeight = 450; //---------------------------------------------------------------------------------- // Module Functions Declaration //---------------------------------------------------------------------------------- -void UpdateDrawFrame(void); // Update and Draw one frame +void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- // Main Enry Point //---------------------------------------------------------------------------------- -int main() -{ +int main() { // Initialization //-------------------------------------------------------------------------------------- raylib::Window window(screenWidth, screenHeight, "raylib-cpp [core] example - basic window"); @@ -42,11 +41,11 @@ int main() #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); #else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { UpdateDrawFrame(); } @@ -58,8 +57,7 @@ int main() //---------------------------------------------------------------------------------- // Module Functions Definition //---------------------------------------------------------------------------------- -void UpdateDrawFrame(void) -{ +void UpdateDrawFrame(void) { // Update //---------------------------------------------------------------------------------- // TODO: Update your variables here @@ -69,9 +67,9 @@ void UpdateDrawFrame(void) //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(RAYWHITE); + ClearBackground(RAYWHITE); - raylib::DrawText("Congrats! You created your first raylib-cpp window!", 190, 200, 20, LIGHTGRAY); + raylib::DrawText("Congrats! You created your first raylib-cpp window!", 190, 200, 20, LIGHTGRAY); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/core/core_drop_files.cpp b/examples/core/core_drop_files.cpp index fd4806ee..860b51c7 100644 --- a/examples/core/core_drop_files.cpp +++ b/examples/core/core_drop_files.cpp @@ -1,15 +1,15 @@ /******************************************************************************************* -* -* raylib [core] example - Windows drop files -* -* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?) -* -* This example has been created using raylib-cpp (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2020 Rob Loach (@RobLoach) -* -********************************************************************************************/ + * + * raylib [core] example - Windows drop files + * + * This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?) + * + * This example has been created using raylib-cpp (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2020 Rob Loach (@RobLoach) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -23,11 +23,11 @@ int main() { std::vector droppedFiles; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- if (IsFileDropped()) { @@ -44,15 +44,16 @@ int main() { // Check if there are files to process. if (droppedFiles.empty()) { raylib::DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY); - } else { + } + else { raylib::DrawText("Dropped files:", 100, 40, 20, DARKGRAY); // Iterate through all the dropped files. for (int i = 0; i < (int)droppedFiles.size(); i++) { if (i % 2 == 0) - DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); + DrawRectangle(0, 85 + 40 * i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); else - DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f)); + DrawRectangle(0, 85 + 40 * i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f)); // Display the path to the dropped file. raylib::DrawText(droppedFiles[i].c_str(), 120, 100 + 40 * i, 10, GRAY); diff --git a/examples/core/core_input_mouse.cpp b/examples/core/core_input_mouse.cpp index 833f621d..a2fdf15a 100644 --- a/examples/core/core_input_mouse.cpp +++ b/examples/core/core_input_mouse.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [core] example - Mouse input -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [core] example - Mouse input + * + * This example has been created using raylib 1.0 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2014 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -23,18 +23,21 @@ int main() { raylib::Color ballColor = raylib::Color::DarkBlue(); raylib::Color textColor = raylib::Color::DarkGray(); - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //--------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- ballPosition = GetMousePosition(); - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON; - else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; - else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + ballColor = MAROON; + else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) + ballColor = LIME; + else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) + ballColor = DARKBLUE; //---------------------------------------------------------------------------------- // Draw diff --git a/examples/core/core_loading_thread.cpp b/examples/core/core_loading_thread.cpp index c0e7fef6..07d28ac5 100644 --- a/examples/core/core_loading_thread.cpp +++ b/examples/core/core_loading_thread.cpp @@ -1,60 +1,59 @@ /******************************************************************************* -* -* raylib example - loading thread -* -* This example has been created using raylib-cpp (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license -* (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* Copyright (c) 2021 Paul Keir (University of the West of Scotland) -* -*******************************************************************************/ - -#include // C++11 standard library threads -#include // C++ atomic data types -#include // For: chrono::steady_clock::now() -#include // May be thrown by thread c'tor + * + * raylib example - loading thread + * + * This example has been created using raylib-cpp (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license + * (View raylib.h for details) + * + * Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) + * Copyright (c) 2021 Paul Keir (University of the West of Scotland) + * + *******************************************************************************/ + +#include // C++ atomic data types +#include // For: chrono::steady_clock::now() +#include // May be thrown by thread c'tor +#include // C++11 standard library threads #include "raylib-cpp.hpp" // Using C++ std::atomic_bool (aka. std::atomic) for synchronization. // n.b. A plain built-in type can't be used for inter-thread synchronization std::atomic_bool dataLoaded{false}; -static void LoadDataThread(); // Loading data thread function declaration -static int dataProgress = 0; // Data progress accumulator +static void LoadDataThread(); // Loading data thread function declaration +static int dataProgress = 0; // Data progress accumulator -int main(void) -{ +int main(void) { // Initialization //-------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; - raylib::Window window(screenWidth, screenHeight, - "raylib [core] example - loading thread"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - loading thread"); - std::thread threadId; // Loading data thread id + std::thread threadId; // Loading data thread id - enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING; + enum { + STATE_WAITING, + STATE_LOADING, + STATE_FINISHED + } state = STATE_WAITING; int framesCounter = 0; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------- - switch (state) - { + switch (state) { case STATE_WAITING: - if (IsKeyPressed(KEY_ENTER)) - { + if (IsKeyPressed(KEY_ENTER)) { try { threadId = std::thread(LoadDataThread); - TraceLog(LOG_INFO, - "Loading thread initialized successfully"); + TraceLog(LOG_INFO, "Loading thread initialized successfully"); } catch (std::system_error& e) { TraceLog(LOG_ERROR, "Error: %s", e.what()); } @@ -65,16 +64,14 @@ int main(void) case STATE_LOADING: framesCounter++; - if (dataLoaded.load()) - { + if (dataLoaded.load()) { framesCounter = 0; state = STATE_FINISHED; } break; case STATE_FINISHED: - if (IsKeyPressed(KEY_ENTER)) - { + if (IsKeyPressed(KEY_ENTER)) { // Reset everything to launch again dataLoaded = false; dataProgress = 0; @@ -82,8 +79,7 @@ int main(void) } break; - default: - break; + default: break; } //---------------------------------------------------------------------- @@ -91,20 +87,16 @@ int main(void) //---------------------------------------------------------------------- BeginDrawing(); { - window.ClearBackground(RAYWHITE); - switch (state) - { + switch (state) { case STATE_WAITING: - raylib::DrawText("PRESS ENTER to START LOADING DATA", - 150, 170, 20, DARKGRAY); + raylib::DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break; case STATE_LOADING: DrawRectangle(150, 200, dataProgress, 60, SKYBLUE); - if ((framesCounter/15)%2) - raylib::DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE); + if ((framesCounter / 15) % 2) raylib::DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE); break; case STATE_FINISHED: @@ -120,29 +112,27 @@ int main(void) //---------------------------------------------------------------------- } - if (threadId.joinable()) // The user might quit without creating a thread. - threadId.join(); // Good etiquette, but may take a second. + if (threadId.joinable()) // The user might quit without creating a thread. + threadId.join(); // Good etiquette, but may take a second. return 0; } // Loading data thread function definition -static void LoadDataThread() -{ +static void LoadDataThread() { using namespace std::chrono; - int timeCounter = 0; // Time counted in ms + int timeCounter = 0; // Time counted in ms auto prevTime = steady_clock::now(); // We simulate data loading with a time counter for 5 seconds - while (timeCounter < 5000) - { + while (timeCounter < 5000) { auto currentTime = steady_clock::now() - prevTime; timeCounter = duration_cast(currentTime).count(); // We accumulate time over a global variable to be used in // main thread as a progress bar - dataProgress = timeCounter/10; + dataProgress = timeCounter / 10; } // When data has finished loading, we set global variable diff --git a/examples/core/core_random_values.cpp b/examples/core/core_random_values.cpp index 1522b847..9449843f 100644 --- a/examples/core/core_random_values.cpp +++ b/examples/core/core_random_values.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [core] example - Generate random values -* -* This example has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [core] example - Generate random values + * + * This example has been created using raylib 1.1 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2014 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -19,15 +19,15 @@ int main() { raylib::Window window(screenWidth, screenHeight, "raylib [core] example - generate random values"); - int framesCounter = 0; // Variable used to count frames + int framesCounter = 0; // Variable used to count frames - int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included) + int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included) - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- framesCounter++; diff --git a/examples/core/core_window_letterbox.cpp b/examples/core/core_window_letterbox.cpp index d5a15bc8..2d3f9e6f 100644 --- a/examples/core/core_window_letterbox.cpp +++ b/examples/core/core_window_letterbox.cpp @@ -1,35 +1,36 @@ /******************************************************************************************* -* -* raylib [core] example - window scale letterbox (and virtual mouse) -* -* Example originally created with raylib 2.5, last time updated with raylib 4.0 -* -* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) -* -* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, -* BSD-like license that allows static linking with closed source software -* -* Copyright (c) 2019-2023 Anata (@anatagawa) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [core] example - window scale letterbox (and virtual mouse) + * + * Example originally created with raylib 2.5, last time updated with raylib 4.0 + * + * Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) + * + * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, + * BSD-like license that allows static linking with closed source software + * + * Copyright (c) 2019-2023 Anata (@anatagawa) and Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" -#include "raymath.hpp" // Required for: Vector2Clamp() +#include "raymath.hpp" // Required for: Vector2Clamp() -#define MAX(a, b) ((a)>(b)? (a) : (b)) -#define MIN(a, b) ((a)<(b)? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ -int main(void) -{ +int main(void) { const int windowWidth = 800; const int windowHeight = 450; // Enable config flags for resizable window and vertical synchro - raylib::Window window(windowWidth, windowHeight, + raylib::Window window( + windowWidth, + windowHeight, "raylib [core] example - window scale letterbox", FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT); window.SetMinSize(320, 240); @@ -39,42 +40,49 @@ int main(void) // Render texture initialization, used to hold the rendering result so we can easily resize it raylib::RenderTexture2D target(gameScreenWidth, gameScreenHeight); - target.GetTexture().SetFilter(TEXTURE_FILTER_BILINEAR); // Texture scale filter to use + target.GetTexture().SetFilter(TEXTURE_FILTER_BILINEAR); // Texture scale filter to use raylib::Color colors[10]; for (int i = 0; i < 10; i++) { - colors[i] = raylib::Color((unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255); + colors[i] = raylib::Color( + (unsigned char)GetRandomValue(100, 250), + (unsigned char)GetRandomValue(50, 150), + (unsigned char)GetRandomValue(10, 100), + 255); } - window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second + window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- // Compute required framebuffer scaling - float scale = MIN((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight); + float scale = MIN((float)GetScreenWidth() / gameScreenWidth, (float)GetScreenHeight() / gameScreenHeight); - if (IsKeyPressed(KEY_SPACE)) - { + if (IsKeyPressed(KEY_SPACE)) { // Recalculate random colors for the bars for (int i = 0; i < 10; i++) { - colors[i] = raylib::Color((unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255); + colors[i] = raylib::Color( + (unsigned char)GetRandomValue(100, 250), + (unsigned char)GetRandomValue(50, 150), + (unsigned char)GetRandomValue(10, 100), + 255); } } // Update virtual mouse (clamped mouse value behind game screen) raylib::Vector2 mouse = raylib::Mouse::GetPosition(); raylib::Vector2 virtualMouse( - (mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale, - (mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale - ); + (mouse.x - (GetScreenWidth() - (gameScreenWidth * scale)) * 0.5f) / scale, + (mouse.y - (GetScreenHeight() - (gameScreenHeight * scale)) * 0.5f) / scale); virtualMouse = virtualMouse.Clamp(raylib::Vector2::Zero(), raylib::Vector2(gameScreenWidth, gameScreenHeight)); // Apply the same transformation as the virtual mouse to the real mouse (i.e. to work with raygui) - //SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - (gameScreenHeight*scale))*0.5f); + // SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - + // (gameScreenHeight*scale))*0.5f); //SetMouseScale(1/scale, 1/scale); //---------------------------------------------------------------------------------- @@ -82,26 +90,35 @@ int main(void) //---------------------------------------------------------------------------------- // Draw everything in the render texture, note this will not be rendered on screen, yet target.BeginMode(); - ClearBackground(RAYWHITE); // Clear render texture background color - - for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]); - - DrawText("If executed inside a window,\nyou can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE); - DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN); - DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW); + ClearBackground(RAYWHITE); // Clear render texture background color + + for (int i = 0; i < 10; i++) + DrawRectangle(0, (gameScreenHeight / 10) * i, gameScreenWidth, gameScreenHeight / 10, colors[i]); + + DrawText( + "If executed inside a window,\nyou can resize the window,\nand see the screen scaling!", + 10, + 25, + 20, + WHITE); + DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN); + DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW); target.EndMode(); BeginDrawing(); - ClearBackground(BLACK); // Clear screen background - - // Draw render texture to screen, properly scaled - target.GetTexture().Draw(raylib::Rectangle(0.0f, 0.0f, target.texture.width, -target.texture.height), - raylib::Rectangle( - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f, - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f, - gameScreenWidth*scale, gameScreenHeight*scale - ), - raylib::Vector2::Zero(), 0.0f, WHITE); + ClearBackground(BLACK); // Clear screen background + + // Draw render texture to screen, properly scaled + target.GetTexture().Draw( + raylib::Rectangle(0.0f, 0.0f, target.texture.width, -target.texture.height), + raylib::Rectangle( + (GetScreenWidth() - (gameScreenWidth * scale)) * 0.5f, + (GetScreenHeight() - (gameScreenHeight * scale)) * 0.5f, + gameScreenWidth * scale, + gameScreenHeight * scale), + raylib::Vector2::Zero(), + 0.0f, + WHITE); EndDrawing(); //-------------------------------------------------------------------------------------- } diff --git a/examples/core/core_world_screen.cpp b/examples/core/core_world_screen.cpp index 2b91a5ca..a7994a13 100644 --- a/examples/core/core_world_screen.cpp +++ b/examples/core/core_world_screen.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [core] example - World to screen -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [core] example - World to screen + * + * This example has been created using raylib 1.3 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2015 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -30,14 +30,14 @@ int main() { Vector3 cubePosition; Vector2 cubeScreenPosition; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- - camera.Update(CAMERA_THIRD_PERSON); // Update camera + camera.Update(CAMERA_THIRD_PERSON); // Update camera // Calculate cube screen space position (with a little offset to be in top) cubeScreenPosition = GetWorldToScreen(Vector3{cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera); @@ -58,13 +58,18 @@ int main() { } camera.EndMode(); - raylib::DrawText("Enemy: 100 / 100", + raylib::DrawText( + "Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20) / 2, - cubeScreenPosition.y, 20, + cubeScreenPosition.y, + 20, BLACK); - raylib::DrawText("Text is always on top of the cube", + raylib::DrawText( + "Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2, - 25, 20, GRAY); + 25, + 20, + GRAY); } EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/models/models_billboard.cpp b/examples/models/models_billboard.cpp index 111d9af4..f42a651a 100644 --- a/examples/models/models_billboard.cpp +++ b/examples/models/models_billboard.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [models] example - Drawing billboards -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [models] example - Drawing billboards + * + * This example has been created using raylib 1.3 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2015 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -27,17 +27,17 @@ int main() { 45.0f, CAMERA_PERSPECTIVE); - raylib::Texture2D bill("resources/billboard.png"); // Our texture billboard - raylib::Vector3 billPosition(0.0f, 2.0f, 0.0f); // Position where draw billboard + raylib::Texture2D bill("resources/billboard.png"); // Our texture billboard + raylib::Vector3 billPosition(0.0f, 2.0f, 0.0f); // Position where draw billboard - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- - camera.Update(CAMERA_ORBITAL); // Update camera + camera.Update(CAMERA_ORBITAL); // Update camera //---------------------------------------------------------------------------------- // Draw @@ -48,7 +48,7 @@ int main() { camera.BeginMode(); { - DrawGrid(10, 1.0f); // Draw a grid + DrawGrid(10, 1.0f); // Draw a grid bill.DrawBillboard(camera, billPosition, 2.0f); } camera.EndMode(); diff --git a/examples/models/models_first_person_maze.cpp b/examples/models/models_first_person_maze.cpp index 4910aa79..01bceccd 100644 --- a/examples/models/models_first_person_maze.cpp +++ b/examples/models/models_first_person_maze.cpp @@ -1,18 +1,17 @@ /******************************************************************************************* -* -* raylib [models] example - first person maze -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [models] example - first person maze + * + * This example has been created using raylib 2.5 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2019 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" -int main(void) -{ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -21,35 +20,37 @@ int main(void) raylib::Window window(screenWidth, screenHeight, "raylib [models] example - first person maze"); // Define the camera to look into our 3d world - raylib::Camera camera({ 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f); + raylib::Camera camera({0.2f, 0.4f, 0.2f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, 45.0f); - raylib::Image imMap("resources/cubicmap.png"); // Load cubicmap image (RAM) - raylib::Texture cubicmap(imMap); // Convert image to texture to display (VRAM) - raylib::MeshUnmanaged mesh = raylib::MeshUnmanaged::Cubicmap(imMap, Vector3{ 1.0f, 1.0f, 1.0f }); // Use MeshUnmanaged, Mesh will be handled by Model + raylib::Image imMap("resources/cubicmap.png"); // Load cubicmap image (RAM) + raylib::Texture cubicmap(imMap); // Convert image to texture to display (VRAM) + raylib::MeshUnmanaged mesh = raylib::MeshUnmanaged::Cubicmap( + imMap, + Vector3{1.0f, 1.0f, 1.0f}); // Use MeshUnmanaged, Mesh will be handled by Model raylib::Model model(mesh); // NOTE: By default each cube is mapped to one part of texture atlas - raylib::Texture texture("resources/cubicmap_atlas.png"); // Load map texture - model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture + raylib::Texture texture("resources/cubicmap_atlas.png"); // Load map texture + model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture // Get map image data to be used for collision detection - Color *mapPixels = imMap.LoadColors(); + Color* mapPixels = imMap.LoadColors(); - imMap.Unload(); // Unload image from RAM + imMap.Unload(); // Unload image from RAM - raylib::Vector3 mapPosition(-16.0f, 0.0f, -8.0f); // Set model position - raylib::Vector3 playerPosition(camera.position); // Set player position + raylib::Vector3 mapPosition(-16.0f, 0.0f, -8.0f); // Set model position + raylib::Vector3 playerPosition(camera.position); // Set player position - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- - raylib::Vector3 oldCamPos(camera.position); // Store old camera position + raylib::Vector3 oldCamPos(camera.position); // Store old camera position - camera.Update(CAMERA_FIRST_PERSON); // Update camera + camera.Update(CAMERA_FIRST_PERSON); // Update camera // Check player collision (we simplify to 2D collision detection) raylib::Vector2 playerPos(camera.position.x, camera.position.z); @@ -59,22 +60,24 @@ int main(void) int playerCellY = static_cast(playerPos.y - mapPosition.z + 0.5f); // Out-of-limits security check - if (playerCellX < 0) playerCellX = 0; - else if (playerCellX >= cubicmap.width) playerCellX = cubicmap.width - 1; + if (playerCellX < 0) + playerCellX = 0; + else if (playerCellX >= cubicmap.width) + playerCellX = cubicmap.width - 1; - if (playerCellY < 0) playerCellY = 0; - else if (playerCellY >= cubicmap.height) playerCellY = cubicmap.height - 1; + if (playerCellY < 0) + playerCellY = 0; + else if (playerCellY >= cubicmap.height) + playerCellY = cubicmap.height - 1; // Check map collisions using image data and player position // TODO: Improvement: Just check player surrounding cells for collision - for (int y = 0; y < cubicmap.height; y++) - { - for (int x = 0; x < cubicmap.width; x++) - { - if ((mapPixels[y*cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel - (playerPos.CheckCollisionCircle(playerRadius, - Rectangle{ mapPosition.x - 0.5f + x*1.0f, mapPosition.z - 0.5f + y*1.0f, 1.0f, 1.0f }))) - { + for (int y = 0; y < cubicmap.height; y++) { + for (int x = 0; x < cubicmap.width; x++) { + if ((mapPixels[y * cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel + (playerPos.CheckCollisionCircle( + playerRadius, + Rectangle{mapPosition.x - 0.5f + x * 1.0f, mapPosition.z - 0.5f + y * 1.0f, 1.0f, 1.0f}))) { // Collision detected, reset camera position camera.position = oldCamPos; } @@ -90,16 +93,27 @@ int main(void) camera.BeginMode(); { - model.Draw(mapPosition); // Draw maze map + model.Draw(mapPosition); // Draw maze map // playerPosition.DrawCube((Vector3){ 0.2f, 0.4f, 0.2f }, RED); // Draw player } camera.EndMode(); - cubicmap.Draw(Vector2{ static_cast(GetScreenWidth() - cubicmap.width*4 - 20), 20 }, 0.0f, 4.0f, WHITE); - DrawRectangleLines(GetScreenWidth() - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); + cubicmap + .Draw(Vector2{static_cast(GetScreenWidth() - cubicmap.width * 4 - 20), 20}, 0.0f, 4.0f, WHITE); + DrawRectangleLines( + GetScreenWidth() - cubicmap.width * 4 - 20, + 20, + cubicmap.width * 4, + cubicmap.height * 4, + GREEN); // Draw player position radar - DrawRectangle(GetScreenWidth() - cubicmap.width*4 - 20 + playerCellX*4, 20 + playerCellY*4, 4, 4, RED); + DrawRectangle( + GetScreenWidth() - cubicmap.width * 4 - 20 + playerCellX * 4, + 20 + playerCellY * 4, + 4, + 4, + RED); DrawFPS(10, 10); } @@ -110,7 +124,7 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- - UnloadImageColors(mapPixels); // Unload color array + UnloadImageColors(mapPixels); // Unload color array //---------------------------------------------------------------------------------- diff --git a/examples/multiple_files/Player.cpp b/examples/multiple_files/Player.cpp index f923d3a5..b2eb7d81 100644 --- a/examples/multiple_files/Player.cpp +++ b/examples/multiple_files/Player.cpp @@ -2,12 +2,7 @@ #include "raylib-cpp.hpp" Player::Player() { - position = Rectangle{ - GetScreenWidth() / 2.0f - 50, - GetScreenHeight() / 2.0f - 50, - 100, - 100 - }; + position = Rectangle{GetScreenWidth() / 2.0f - 50, GetScreenHeight() / 2.0f - 50, 100, 100}; speed = 3; } diff --git a/examples/multiple_files/Player.hpp b/examples/multiple_files/Player.hpp index af8c3c47..d5a44675 100644 --- a/examples/multiple_files/Player.hpp +++ b/examples/multiple_files/Player.hpp @@ -1,7 +1,7 @@ #include "raylib-cpp.hpp" class Player { - public: + public: Player(); raylib::Rectangle position; int speed; diff --git a/examples/multiple_files/main.cpp b/examples/multiple_files/main.cpp index cc3fb44a..2ec9438f 100644 --- a/examples/multiple_files/main.cpp +++ b/examples/multiple_files/main.cpp @@ -1,23 +1,23 @@ /******************************************************************************************* -* -* raylib-cpp [multiple_files] example - Includes raylib-cpp.hpp from multiple sources. -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This example has been created using raylib-cpp -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2021 Rob Loach (https://robloach.net) -* -********************************************************************************************/ + * + * raylib-cpp [multiple_files] example - Includes raylib-cpp.hpp from multiple sources. + * + * Welcome to raylib! + * + * To test examples, just press F6 and execute raylib_compile_execute script + * Note that compiled executable is placed in the same folder as .c file + * + * You can find all basic examples on C:\raylib\raylib\examples folder or + * raylib official webpage: www.raylib.com + * + * Enjoy using raylib. :) + * + * This example has been created using raylib-cpp + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2021 Rob Loach (https://robloach.net) + * + ********************************************************************************************/ #include "Player.hpp" #include "raylib-cpp.hpp" diff --git a/examples/shaders/rlights.h b/examples/shaders/rlights.h index 0ebc43af..f54e061a 100644 --- a/examples/shaders/rlights.h +++ b/examples/shaders/rlights.h @@ -1,34 +1,34 @@ /********************************************************************************************** -* -* raylib.lights - Some useful functions to deal with lights data -* -* CONFIGURATION: -* -* #define RLIGHTS_IMPLEMENTATION -* Generates the implementation of the library into the included file. -* If not defined, the library is in header only mode and can be included in other headers -* or source files without problems. But only ONE file should hold the implementation. -* -* LICENSE: zlib/libpng -* -* Copyright (c) 2017-2024 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ + * + * raylib.lights - Some useful functions to deal with lights data + * + * CONFIGURATION: + * + * #define RLIGHTS_IMPLEMENTATION + * Generates the implementation of the library into the included file. + * If not defined, the library is in header only mode and can be included in other headers + * or source files without problems. But only ONE file should hold the implementation. + * + * LICENSE: zlib/libpng + * + * Copyright (c) 2017-2024 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) + * + * This software is provided "as-is", without any express or implied warranty. In no event + * will the authors be held liable for any damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, including commercial + * applications, and to alter it and redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not claim that you + * wrote the original software. If you use this software in a product, an acknowledgment + * in the product documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be misrepresented + * as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + **********************************************************************************************/ #ifndef RLIGHTS_H #define RLIGHTS_H @@ -36,7 +36,7 @@ //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- -#define MAX_LIGHTS 4 // Max dynamic lights supported by shader +#define MAX_LIGHTS 4 // Max dynamic lights supported by shader //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -67,27 +67,28 @@ typedef enum { } LightType; #ifdef __cplusplus -extern "C" { // Prevents name mangling of functions +extern "C" { // Prevents name mangling of functions #endif //---------------------------------------------------------------------------------- // Module Functions Declaration //---------------------------------------------------------------------------------- -Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shader shader); // Create a light and get shader locations -void UpdateLightValues(Shader shader, Light light); // Send light properties to shader +Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shader shader); // Create a light and get + // shader locations +void UpdateLightValues(Shader shader, Light light); // Send light properties to shader #ifdef __cplusplus } #endif -#endif // RLIGHTS_H +#endif // RLIGHTS_H /*********************************************************************************** -* -* RLIGHTS IMPLEMENTATION -* -************************************************************************************/ + * + * RLIGHTS IMPLEMENTATION + * + ************************************************************************************/ #if defined(RLIGHTS_IMPLEMENTATION) @@ -106,7 +107,7 @@ void UpdateLightValues(Shader shader, Light light); // Send light proper //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -static int lightsCount = 0; // Current amount of created lights +static int lightsCount = 0; // Current amount of created lights //---------------------------------------------------------------------------------- // Module specific Functions Declaration @@ -118,12 +119,10 @@ static int lightsCount = 0; // Current amount of created lights //---------------------------------------------------------------------------------- // Create a light and get shader locations -Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shader shader) -{ - Light light = { 0 }; +Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shader shader) { + Light light = {0}; - if (lightsCount < MAX_LIGHTS) - { + if (lightsCount < MAX_LIGHTS) { light.enabled = true; light.type = type; light.position = position; @@ -147,24 +146,26 @@ Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shade // Send light properties to shader // NOTE: Light shader locations should be available -void UpdateLightValues(Shader shader, Light light) -{ +void UpdateLightValues(Shader shader, Light light) { // Send to shader light enabled state and type SetShaderValue(shader, light.enabledLoc, &light.enabled, SHADER_UNIFORM_INT); SetShaderValue(shader, light.typeLoc, &light.type, SHADER_UNIFORM_INT); // Send to shader light position values - float position[3] = { light.position.x, light.position.y, light.position.z }; + float position[3] = {light.position.x, light.position.y, light.position.z}; SetShaderValue(shader, light.positionLoc, position, SHADER_UNIFORM_VEC3); // Send to shader light target position values - float target[3] = { light.target.x, light.target.y, light.target.z }; + float target[3] = {light.target.x, light.target.y, light.target.z}; SetShaderValue(shader, light.targetLoc, target, SHADER_UNIFORM_VEC3); // Send to shader light color values - float color[4] = { (float)light.color.r/(float)255, (float)light.color.g/(float)255, - (float)light.color.b/(float)255, (float)light.color.a/(float)255 }; + float color[4] = { + (float)light.color.r / (float)255, + (float)light.color.g / (float)255, + (float)light.color.b / (float)255, + (float)light.color.a / (float)255}; SetShaderValue(shader, light.colorLoc, color, SHADER_UNIFORM_VEC4); } -#endif // RLIGHTS_IMPLEMENTATION \ No newline at end of file +#endif // RLIGHTS_IMPLEMENTATION \ No newline at end of file diff --git a/examples/shaders/shaders_basic_lighting.cpp b/examples/shaders/shaders_basic_lighting.cpp index aa4f7e7e..3b906869 100644 --- a/examples/shaders/shaders_basic_lighting.cpp +++ b/examples/shaders/shaders_basic_lighting.cpp @@ -1,22 +1,22 @@ /******************************************************************************************* -* -* raylib [shaders] example - basic lighting -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3). -* -* Example originally created with raylib 3.0, last time updated with raylib 4.2 -* -* Example contributed by Chris Camacho (@codifies) and reviewed by Ramon Santamaria (@raysan5) -* -* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, -* BSD-like license that allows static linking with closed source software -* -* Copyright (c) 2019-2024 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [shaders] example - basic lighting + * + * NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, + * OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. + * + * NOTE: Shaders used in this example are #version 330 (OpenGL 3.3). + * + * Example originally created with raylib 3.0, last time updated with raylib 4.2 + * + * Example contributed by Chris Camacho (@codifies) and reviewed by Ramon Santamaria (@raysan5) + * + * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, + * BSD-like license that allows static linking with closed source software + * + * Copyright (c) 2019-2024 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -26,9 +26,9 @@ #include "rlights.h" #if defined(PLATFORM_DESKTOP) -#define GLSL_VERSION 330 -#else // PLATFORM_ANDROID, PLATFORM_WEB -#define GLSL_VERSION 100 +#define GLSL_VERSION 330 +#else // PLATFORM_ANDROID, PLATFORM_WEB +#define GLSL_VERSION 100 #endif #include @@ -36,8 +36,7 @@ //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ -int main(void) -{ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -48,20 +47,21 @@ 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.fovy = 45.0f; // Camera field-of-view Y - camera.projection = CAMERA_PERSPECTIVE; // Camera projection type + 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 // Load basic lighting shader - raylib::Shader shader (TextFormat("resources/shaders/glsl%i/lighting.vs", GLSL_VERSION), - TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION)); + raylib::Shader shader( + TextFormat("resources/shaders/glsl%i/lighting.vs", GLSL_VERSION), + TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION)); // Get some required shader locations shader.locs[SHADER_LOC_VECTOR_VIEW] = shader.GetLocation("viewPos"); // NOTE: "matModel" location name is automatically assigned on shader loading, // no need to get the location again if using that uniform name - //shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel"); + // shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel"); // Ambient light level (some basic lighting) int ambientLoc = shader.GetLocation("ambient"); @@ -70,31 +70,39 @@ 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 + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- camera.Update(CAMERA_ORBITAL); // Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f }) - std::array cameraPos = { camera.position.x, camera.position.y, camera.position.z }; + std::array cameraPos = {camera.position.x, camera.position.y, camera.position.z}; SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos.data(), SHADER_UNIFORM_VEC3); // Check key inputs to enable/disable lights - if (IsKeyPressed(KEY_Y)) { lights[0].enabled = !lights[0].enabled; } - if (IsKeyPressed(KEY_R)) { lights[1].enabled = !lights[1].enabled; } - if (IsKeyPressed(KEY_G)) { lights[2].enabled = !lights[2].enabled; } - if (IsKeyPressed(KEY_B)) { lights[3].enabled = !lights[3].enabled; } + if (IsKeyPressed(KEY_Y)) { + lights[0].enabled = !lights[0].enabled; + } + if (IsKeyPressed(KEY_R)) { + lights[1].enabled = !lights[1].enabled; + } + if (IsKeyPressed(KEY_G)) { + lights[2].enabled = !lights[2].enabled; + } + if (IsKeyPressed(KEY_B)) { + lights[3].enabled = !lights[3].enabled; + } // Update light values (actually, only enable/disable them) for (const auto& light : lights) UpdateLightValues(shader, light); @@ -110,16 +118,17 @@ 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(); // Draw spheres to show where the lights are - for (const auto& light : lights) - { - if (light.enabled) DrawSphereEx(light.position, 0.2f, 8, 8, light.color); - else DrawSphereWires(light.position, 0.2f, 8, 8, ColorAlpha(light.color, 0.3f)); + for (const auto& light : lights) { + if (light.enabled) + DrawSphereEx(light.position, 0.2f, 8, 8, light.color); + else + DrawSphereWires(light.position, 0.2f, 8, 8, ColorAlpha(light.color, 0.3f)); } DrawGrid(10, 1.0f); @@ -138,7 +147,7 @@ int main(void) //-------------------------------------------------------------------------------------- //UnloadShader(shader); // Unload shader - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; diff --git a/examples/shaders/shaders_basic_pbr.cpp b/examples/shaders/shaders_basic_pbr.cpp index 04c2deac..a3ef5259 100644 --- a/examples/shaders/shaders_basic_pbr.cpp +++ b/examples/shaders/shaders_basic_pbr.cpp @@ -1,33 +1,33 @@ /******************************************************************************************* -* -* raylib [shaders] example - Basic PBR -* -* Example originally created with raylib 5.0, last time updated with raylib 5.1-dev -* -* Example contributed by Afan OLOVCIC (@_DevDad) and reviewed by Ramon Santamaria (@raysan5) -* -* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, -* BSD-like license that allows static linking with closed source software -* -* Copyright (c) 2023-2024 Afan OLOVCIC (@_DevDad) -* -* Model: "Old Rusty Car" (https://skfb.ly/LxRy) by Renafox, -* licensed under Creative Commons Attribution-NonCommercial -* (http://creativecommons.org/licenses/by-nc/4.0/) -* -********************************************************************************************/ + * + * raylib [shaders] example - Basic PBR + * + * Example originally created with raylib 5.0, last time updated with raylib 5.1-dev + * + * Example contributed by Afan OLOVCIC (@_DevDad) and reviewed by Ramon Santamaria (@raysan5) + * + * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, + * BSD-like license that allows static linking with closed source software + * + * Copyright (c) 2023-2024 Afan OLOVCIC (@_DevDad) + * + * Model: "Old Rusty Car" (https://skfb.ly/LxRy) by Renafox, + * licensed under Creative Commons Attribution-NonCommercial + * (http://creativecommons.org/licenses/by-nc/4.0/) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" #if defined(PLATFORM_DESKTOP) -#define GLSL_VERSION 330 -#else // PLATFORM_ANDROID, PLATFORM_WEB -#define GLSL_VERSION 120 +#define GLSL_VERSION 330 +#else // PLATFORM_ANDROID, PLATFORM_WEB +#define GLSL_VERSION 120 #endif #include -static const int MAX_LIGHTS = 4; // Max dynamic lights supported by shader +static const int MAX_LIGHTS = 4; // Max dynamic lights supported by shader //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -61,13 +61,20 @@ struct Light { //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -static int lightCount = 0; // Current number of dynamic lights that have been created +static int lightCount = 0; // Current number of dynamic lights that have been created //---------------------------------------------------------------------------------- // Module specific Functions Declaration //---------------------------------------------------------------------------------- // Create a light and get shader locations -static Light CreateLight(size_t index, LightType type, Vector3 position, Vector3 target, Color color, float intensity, Shader shader); +static Light CreateLight( + size_t index, + LightType type, + Vector3 position, + Vector3 target, + Color color, + float intensity, + Shader shader); // Update light properties on shader // NOTE: Light shader locations should be available @@ -76,8 +83,7 @@ static void UpdateLight(Shader shader, const Light& light); //---------------------------------------------------------------------------------- // Main Entry Point //---------------------------------------------------------------------------------- -int main() -{ +int main() { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -88,15 +94,16 @@ 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.fovy = 45.0f; // Camera field-of-view Y - camera.projection = CAMERA_PERSPECTIVE; // Camera projection type + 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 // Load PBR shader and setup all required locations - raylib::Shader shader (TextFormat("resources/shaders/glsl%i/pbr.vs", GLSL_VERSION), - TextFormat("resources/shaders/glsl%i/pbr.fs", GLSL_VERSION)); + raylib::Shader shader( + TextFormat("resources/shaders/glsl%i/pbr.vs", GLSL_VERSION), + TextFormat("resources/shaders/glsl%i/pbr.fs", GLSL_VERSION)); shader.locs[SHADER_LOC_MAP_ALBEDO] = GetShaderLocation(shader, "albedoMap"); // WARNING: Metalness, roughness, and ambient occlusion are all packed into a MRA texture // They are passed as to the SHADER_LOC_MAP_METALNESS location for convenience, @@ -117,8 +124,9 @@ 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); @@ -132,7 +140,7 @@ int main() // that model.materials[0] is by default assigned to that mesh // There could be more complex models consisting of multiple meshes and // multiple materials defined for those meshes... but always 1 mesh = 1 material - raylib::Model car ("resources/models/old_car_new.glb"); + raylib::Model car("resources/models/old_car_new.glb"); // Assign already setup PBR shader to model.materials[0], used by models.meshes[0] car.materials[0].shader = shader; @@ -142,7 +150,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"); @@ -152,10 +160,10 @@ int main() // Load floor model mesh and assign material parameters // NOTE: A basic plane shape can be generated instead of being loaded from a model file - raylib::Model floor ("resources/models/plane.glb"); - //Mesh floorMesh = GenMeshPlane(10, 10, 10, 10); + raylib::Model floor("resources/models/plane.glb"); + // Mesh floorMesh = GenMeshPlane(10, 10, 10, 10); //GenMeshTangents(&floorMesh); // TODO: Review tangents generation - //Model floor = LoadModelFromMesh(floorMesh); + // Model floor = LoadModelFromMesh(floorMesh); // Assign material shader for our floor model, same PBR shader floor.materials[0].shader = shader; @@ -172,15 +180,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 @@ -191,11 +199,11 @@ int main() SetShaderValue(shader, GetShaderLocation(shader, "useTexMRA"), &usage, SHADER_UNIFORM_INT); SetShaderValue(shader, GetShaderLocation(shader, "useTexEmissive"), &usage, SHADER_UNIFORM_INT); - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //--------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -206,10 +214,18 @@ int main() SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos.data(), SHADER_UNIFORM_VEC3); // Check key inputs to enable/disable lights - if (IsKeyPressed(KEY_ONE)) { lights[2].enabled = !lights[2].enabled; } - if (IsKeyPressed(KEY_TWO)) { lights[1].enabled = !lights[1].enabled; } - if (IsKeyPressed(KEY_THREE)) { lights[3].enabled = !lights[3].enabled; } - if (IsKeyPressed(KEY_FOUR)) { lights[0].enabled = !lights[0].enabled; } + if (IsKeyPressed(KEY_ONE)) { + lights[2].enabled = !lights[2].enabled; + } + if (IsKeyPressed(KEY_TWO)) { + lights[1].enabled = !lights[1].enabled; + } + if (IsKeyPressed(KEY_THREE)) { + lights[3].enabled = !lights[3].enabled; + } + if (IsKeyPressed(KEY_FOUR)) { + lights[0].enabled = !lights[0].enabled; + } // Update light values on shader (actually, only enable/disable them) for (int i = 0; i < MAX_LIGHTS; i++) UpdateLight(shader, lights[i]); @@ -228,7 +244,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,25 +253,32 @@ 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) }; - - if (light.enabled) DrawSphereEx(light.position, 0.2f, 8, 8, lightColor); - else DrawSphereWires(light.position, 0.2f, 8, 8, ColorAlpha(lightColor, 0.3f)); + 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)}; + + if (light.enabled) + DrawSphereEx(light.position, 0.2f, 8, 8, lightColor); + else + DrawSphereWires(light.position, 0.2f, 8, 8, ColorAlpha(lightColor, 0.3f)); } EndMode3D(); DrawText("Toggle lights: [1][2][3][4]", 10, 40, 20, LIGHTGRAY); - DrawText("(c) Old Rusty Car model by Renafox (https://skfb.ly/LxRy)", screenWidth - 320, screenHeight - 20, 10, LIGHTGRAY); + DrawText( + "(c) Old Rusty Car model by Renafox (https://skfb.ly/LxRy)", + screenWidth - 320, + screenHeight - 20, + 10, + LIGHTGRAY); DrawFPS(10, 10); @@ -267,19 +290,19 @@ 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); + // 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); + // UnloadModel(floor); //UnloadShader(shader); // Unload Shader - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; @@ -287,18 +310,24 @@ int main() // Create light with provided data // NOTE: It updated the global lightCount and it's limited to MAX_LIGHTS -static Light CreateLight(size_t index, LightType type, Vector3 position, Vector3 target, Color color, float intensity, Shader shader) -{ +static Light CreateLight( + size_t index, + LightType type, + Vector3 position, + Vector3 target, + Color color, + float intensity, + Shader shader) { Light light; light.enabled = 1; light.type = type; light.position = position; light.target = target; - light.color[0] = (float)color.r/255.0f; - light.color[1] = (float)color.g/255.0f; - light.color[2] = (float)color.b/255.0f; - light.color[3] = (float)color.a/255.0f; + light.color[0] = (float)color.r / 255.0f; + light.color[1] = (float)color.g / 255.0f; + light.color[2] = (float)color.b / 255.0f; + light.color[3] = (float)color.a / 255.0f; light.intensity = intensity; // NOTE: Shader parameters names for lights must match the requested ones @@ -316,17 +345,16 @@ static Light CreateLight(size_t index, LightType type, Vector3 position, Vector3 // Send light properties to shader // NOTE: Light shader locations should be available -static void UpdateLight(Shader shader, const Light& light) -{ +static void UpdateLight(Shader shader, const Light& light) { SetShaderValue(shader, light.enabledLoc, &light.enabled, SHADER_UNIFORM_INT); SetShaderValue(shader, light.typeLoc, &light.type, SHADER_UNIFORM_INT); // Send to shader light position values - std::array position = { light.position.x, light.position.y, light.position.z }; + std::array position = {light.position.x, light.position.y, light.position.z}; SetShaderValue(shader, light.positionLoc, position.data(), SHADER_UNIFORM_VEC3); // Send to shader light target position values - std::array target = { light.target.x, light.target.y, light.target.z }; + std::array target = {light.target.x, light.target.y, light.target.z}; SetShaderValue(shader, light.targetLoc, target.data(), SHADER_UNIFORM_VEC3); SetShaderValue(shader, light.colorLoc, light.color.data(), SHADER_UNIFORM_VEC4); SetShaderValue(shader, light.intensityLoc, &light.intensity, SHADER_UNIFORM_FLOAT); diff --git a/examples/shaders/shaders_texture_waves.cpp b/examples/shaders/shaders_texture_waves.cpp index 48778067..f3e41f94 100644 --- a/examples/shaders/shaders_texture_waves.cpp +++ b/examples/shaders/shaders_texture_waves.cpp @@ -1,33 +1,32 @@ /******************************************************************************************* -* -* raylib [shaders] example - Texture Waves -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [shaders] example - Texture Waves + * + * NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, + * OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. + * + * NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example + * on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders + * raylib comes with shaders ready for both versions, check raylib/shaders install folder + * + * This example has been created using raylib 2.5 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) + * + * Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" #if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 +#define GLSL_VERSION 330 +#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB +#define GLSL_VERSION 100 #endif -int main(void) -{ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -57,7 +56,7 @@ int main(void) float speedX = 8.0f; float speedY = 8.0f; - float screenSize[2] = { (float)window.GetWidth(), (float)window.GetHeight() }; + float screenSize[2] = {(float)window.GetWidth(), (float)window.GetHeight()}; shader.SetValue(shader.GetLocation("size"), &screenSize, SHADER_UNIFORM_VEC2); shader.SetValue(freqXLoc, &freqX, SHADER_UNIFORM_FLOAT); shader.SetValue(freqYLoc, &freqY, SHADER_UNIFORM_FLOAT); @@ -68,11 +67,11 @@ int main(void) float seconds = 0.0f; - window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second + window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second // ------------------------------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -85,14 +84,14 @@ int main(void) //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(RAYWHITE); + ClearBackground(RAYWHITE); - shader.BeginMode(); + shader.BeginMode(); - texture.Draw(0, 0, WHITE); - texture.Draw(texture.GetWidth(), 0, WHITE); + texture.Draw(0, 0, WHITE); + texture.Draw(texture.GetWidth(), 0, WHITE); - EndShaderMode(); + EndShaderMode(); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/shapes/shapes_collision_area.cpp b/examples/shapes/shapes_collision_area.cpp index 8c758bf5..c37f03fa 100644 --- a/examples/shapes/shapes_collision_area.cpp +++ b/examples/shapes/shapes_collision_area.cpp @@ -1,20 +1,19 @@ /******************************************************************************************* -* -* raylib [shapes] example - collision area -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [shapes] example - collision area + * + * This example has been created using raylib 2.5 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" -#include // NOLINT +#include // NOLINT -int main(void) -{ +int main(void) { // Initialization //--------------------------------------------------------- const int screenWidth = 800; @@ -23,24 +22,24 @@ int main(void) raylib::Window window(screenWidth, screenHeight, "raylib [shapes] example - collision area"); // Box A: Moving box - raylib::Rectangle boxA(10, GetScreenHeight()/2 - 50, 200, 100); + raylib::Rectangle boxA(10, GetScreenHeight() / 2 - 50, 200, 100); int boxASpeedX = 4; // Box B: Mouse moved box - raylib::Rectangle boxB(GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60); + raylib::Rectangle boxB(GetScreenWidth() / 2 - 30, GetScreenHeight() / 2 - 30, 60, 60); - raylib::Rectangle boxCollision(0); // Collision rectangle + raylib::Rectangle boxCollision(0); // Collision rectangle - int screenUpperLimit = 40; // Top menu limits + int screenUpperLimit = 40; // Top menu limits - bool pause = false; // Movement pause - bool collision = false; // Collision detection + bool pause = false; // Movement pause + bool collision = false; // Collision detection - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //---------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //----------------------------------------------------- // Move box if not paused @@ -50,15 +49,19 @@ int main(void) if (((boxA.x + boxA.width) >= GetScreenWidth()) || (boxA.x <= 0)) boxASpeedX *= -1; // Update player-controlled-box (box02) - boxB.x = GetMouseX() - boxB.width/2; - boxB.y = GetMouseY() - boxB.height/2; + boxB.x = GetMouseX() - boxB.width / 2; + boxB.y = GetMouseY() - boxB.height / 2; // Make sure Box B does not go out of move area limits - if ((boxB.x + boxB.width) >= GetScreenWidth()) boxB.x = GetScreenWidth() - boxB.width; - else if (boxB.x <= 0) boxB.x = 0; + if ((boxB.x + boxB.width) >= GetScreenWidth()) + boxB.x = GetScreenWidth() - boxB.width; + else if (boxB.x <= 0) + boxB.x = 0; - if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height; - else if (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit; + if ((boxB.y + boxB.height) >= GetScreenHeight()) + boxB.y = GetScreenHeight() - boxB.height; + else if (boxB.y <= screenUpperLimit) + boxB.y = screenUpperLimit; // Check boxes collision collision = boxA.CheckCollision(boxB); @@ -74,25 +77,35 @@ int main(void) //----------------------------------------------------- BeginDrawing(); - window.ClearBackground(RAYWHITE); + window.ClearBackground(RAYWHITE); - DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision? RED : BLACK); + DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision ? RED : BLACK); - boxA.Draw(GOLD); - boxB.Draw(BLUE); + boxA.Draw(GOLD); + boxB.Draw(BLUE); - if (collision) { - // Draw collision area - boxCollision.Draw(LIME); + if (collision) { + // Draw collision area + boxCollision.Draw(LIME); - // Draw collision message - raylib::DrawText("COLLISION!", GetScreenWidth()/2 - MeasureText("COLLISION!", 20)/2, screenUpperLimit/2 - 10, 20, BLACK); + // Draw collision message + raylib::DrawText( + "COLLISION!", + GetScreenWidth() / 2 - MeasureText("COLLISION!", 20) / 2, + screenUpperLimit / 2 - 10, + 20, + BLACK); - // Draw collision area - raylib::DrawText(TextFormat("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK); - } + // Draw collision area + raylib::DrawText( + TextFormat("Collision Area: %i", (int)boxCollision.width * (int)boxCollision.height), + GetScreenWidth() / 2 - 100, + screenUpperLimit + 10, + 20, + BLACK); + } - DrawFPS(10, 10); + DrawFPS(10, 10); EndDrawing(); //----------------------------------------------------- diff --git a/examples/shapes/shapes_logo_raylib.cpp b/examples/shapes/shapes_logo_raylib.cpp index 82bd59a3..75ead67a 100644 --- a/examples/shapes/shapes_logo_raylib.cpp +++ b/examples/shapes/shapes_logo_raylib.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [shapes] example - Draw raylib logo using basic shapes -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [shapes] example - Draw raylib logo using basic shapes + * + * This example has been created using raylib 1.0 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2014 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -21,11 +21,11 @@ int main() { raylib::Color foreground(0, 68, 130); raylib::Color background = RAYWHITE; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- // Update your variables here @@ -37,10 +37,10 @@ int main() { { window.ClearBackground(background); - foreground.DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256); - background.DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224); - foreground.DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 24, 50); - foreground.DrawText("cpp", screenWidth/2 - 74, screenHeight/2 + 54, 50); + foreground.DrawRectangle(screenWidth / 2 - 128, screenHeight / 2 - 128, 256, 256); + background.DrawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224); + foreground.DrawText("raylib", screenWidth / 2 - 44, screenHeight / 2 + 24, 50); + foreground.DrawText("cpp", screenWidth / 2 - 74, screenHeight / 2 + 54, 50); DrawText("this is NOT a texture!", 350, 370, 10, GRAY); } diff --git a/examples/text/text_font_filters.cpp b/examples/text/text_font_filters.cpp index ce5679c4..dcff0ce4 100644 --- a/examples/text/text_font_filters.cpp +++ b/examples/text/text_font_filters.cpp @@ -1,22 +1,21 @@ /******************************************************************************************* -* -* raylib [text] example - Font filters -* -* After font loading, font texture atlas filter could be configured for a softer -* display of the font when scaling it to different sizes, that way, it's not required -* to generate multiple fonts at multiple sizes (as long as the scaling is not very different) -* -* This example has been created using raylib 1.3.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [text] example - Font filters + * + * After font loading, font texture atlas filter could be configured for a softer + * display of the font when scaling it to different sizes, that way, it's not required + * to generate multiple fonts at multiple sizes (as long as the scaling is not very different) + * + * This example has been created using raylib 1.3.0 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2015 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" -int main(void) -{ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -33,36 +32,33 @@ int main(void) raylib::Text msg("Loaded Font", font.GetBaseSize(), BLACK, font); - Vector2 fontPosition = { 40.0f, screenHeight/2.0f - 80.0f }; - Vector2 textSize = { 0.0f, 0.0f }; + Vector2 fontPosition = {40.0f, screenHeight / 2.0f - 80.0f}; + Vector2 textSize = {0.0f, 0.0f}; // Setup texture scaling filter font.GetTexture().SetFilter(TEXTURE_FILTER_POINT); - int currentFontFilter = 0; // TEXTURE_FILTER_POINT + int currentFontFilter = 0; // TEXTURE_FILTER_POINT - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- msg.fontSize += GetMouseWheelMove() * 4.0f; // Choose font texture filter method - if (IsKeyPressed(KEY_ONE)) - { + if (IsKeyPressed(KEY_ONE)) { font.GetTexture().SetFilter(TEXTURE_FILTER_POINT); currentFontFilter = 0; } - else if (IsKeyPressed(KEY_TWO)) - { + else if (IsKeyPressed(KEY_TWO)) { font.GetTexture().SetFilter(TEXTURE_FILTER_BILINEAR); currentFontFilter = 1; } - else if (IsKeyPressed(KEY_THREE)) - { + else if (IsKeyPressed(KEY_THREE)) { // NOTE: Trilinear filter won't be noticed on 2D drawing font.GetTexture().SetFilter(TEXTURE_FILTER_TRILINEAR); currentFontFilter = 2; @@ -70,8 +66,10 @@ int main(void) textSize = msg.MeasureEx(); - if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10; - else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10; + if (IsKeyDown(KEY_LEFT)) + fontPosition.x -= 10; + else if (IsKeyDown(KEY_RIGHT)) + fontPosition.x += 10; // Load a dropped TTF file dynamically (at current fontSize) for (const auto& file : raylib::LoadDroppedFiles()) { @@ -85,26 +83,34 @@ int main(void) //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(RAYWHITE); - - DrawText("Use mouse wheel to change font size", 20, 20, 10, GRAY); - DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, GRAY); - DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY); - DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY); - - msg.Draw(fontPosition); - - // TODO: It seems texSize measurement is not accurate due to chars offsets... - //DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED); - - DrawRectangle(0, screenHeight - 80, screenWidth, 80, LIGHTGRAY); - DrawText(TextFormat("Font size: %02.02f", msg.GetFontSize()), 20, screenHeight - 50, 10, DARKGRAY); - DrawText(TextFormat("Text size: [%02.02f, %02.02f]", textSize.x, textSize.y), 20, screenHeight - 30, 10, DARKGRAY); - DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY); - - if (currentFontFilter == 0) DrawText("POINT", 570, 400, 20, BLACK); - else if (currentFontFilter == 1) DrawText("BILINEAR", 570, 400, 20, BLACK); - else if (currentFontFilter == 2) DrawText("TRILINEAR", 570, 400, 20, BLACK); + ClearBackground(RAYWHITE); + + DrawText("Use mouse wheel to change font size", 20, 20, 10, GRAY); + DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, GRAY); + DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY); + DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY); + + msg.Draw(fontPosition); + + // TODO: It seems texSize measurement is not accurate due to chars offsets... + // DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED); + + DrawRectangle(0, screenHeight - 80, screenWidth, 80, LIGHTGRAY); + DrawText(TextFormat("Font size: %02.02f", msg.GetFontSize()), 20, screenHeight - 50, 10, DARKGRAY); + DrawText( + TextFormat("Text size: [%02.02f, %02.02f]", textSize.x, textSize.y), + 20, + screenHeight - 30, + 10, + DARKGRAY); + DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY); + + if (currentFontFilter == 0) + DrawText("POINT", 570, 400, 20, BLACK); + else if (currentFontFilter == 1) + DrawText("BILINEAR", 570, 400, 20, BLACK); + else if (currentFontFilter == 2) + DrawText("TRILINEAR", 570, 400, 20, BLACK); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/text/text_font_loading.cpp b/examples/text/text_font_loading.cpp index 31f0dfdb..18384931 100644 --- a/examples/text/text_font_loading.cpp +++ b/examples/text/text_font_loading.cpp @@ -1,25 +1,25 @@ /******************************************************************************************* -* -* raylib [text] example - Font loading -* -* raylib can load fonts from multiple file formats: -* -* - TTF/OTF > Sprite font atlas is generated on loading, user can configure -* some of the generation parameters (size, characters to include) -* - BMFonts > Angel code font fileformat, sprite font image must be provided -* together with the .fnt file, font generation cna not be configured -* - XNA Spritefont > Sprite font image, following XNA Spritefont conventions, -* Characters in image must follow some spacing and order rules -* -* This example has been created using raylib 2.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [text] example - Font loading + * + * raylib can load fonts from multiple file formats: + * + * - TTF/OTF > Sprite font atlas is generated on loading, user can configure + * some of the generation parameters (size, characters to include) + * - BMFonts > Angel code font fileformat, sprite font image must be provided + * together with the .fnt file, font generation cna not be configured + * - XNA Spritefont > Sprite font image, following XNA Spritefont conventions, + * Characters in image must follow some spacing and order rules + * + * This example has been created using raylib 2.6 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2016-2019 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ -#include #include "raylib-cpp.hpp" +#include int main() { // Initialization @@ -31,7 +31,9 @@ int main() { // Define characters to draw // NOTE: raylib supports UTF-8 encoding, following list is actually codified as UTF8 internally - std::string msg = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ\nÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ"; + std::string msg = "!\"#$%&'()*+,-./" + "0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~" + "¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ\nÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ"; // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) @@ -44,34 +46,33 @@ int main() { bool useTtf = false; - window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second + window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_SPACE)) useTtf = true; - else useTtf = false; + if (IsKeyDown(KEY_SPACE)) + useTtf = true; + else + useTtf = false; //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- window.BeginDrawing(); { - window.ClearBackground(RAYWHITE); raylib::DrawText("Hold SPACE to use TTF generated font", 20, 20, 20, LIGHTGRAY); - if (!useTtf) - { - fontBm.DrawText(msg, Vector2{ 20.0f, 100.0f }, fontBm.baseSize, 2, MAROON); + if (!useTtf) { + fontBm.DrawText(msg, Vector2{20.0f, 100.0f}, fontBm.baseSize, 2, MAROON); raylib::DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, GRAY); } - else - { - fontTtf.DrawText(msg, Vector2{ 20.0f, 100.0f }, fontTtf.baseSize, 2, LIME); + else { + fontTtf.DrawText(msg, Vector2{20.0f, 100.0f}, fontTtf.baseSize, 2, LIME); raylib::DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY); } } diff --git a/examples/text/text_font_spritefont.cpp b/examples/text/text_font_spritefont.cpp index f7e2c33d..b02964ed 100644 --- a/examples/text/text_font_spritefont.cpp +++ b/examples/text/text_font_spritefont.cpp @@ -1,20 +1,19 @@ /******************************************************************************************* -* -* raylib [text] example - Font loading and usage -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [text] example - Font loading and usage + * + * This example has been created using raylib 1.0 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2014 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include #include "raylib-cpp.hpp" -int main(void) -{ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -27,24 +26,27 @@ int main(void) std::string msg3 = "...and a THIRD one! GREAT! :D"; // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - raylib::Font font1("resources/custom_mecha.png"); // Font loading - raylib::Font font2("resources/custom_alagard.png"); // Font loading + raylib::Font font1("resources/custom_mecha.png"); // Font loading + raylib::Font font2("resources/custom_alagard.png"); // Font loading raylib::Font font3("resources/custom_jupiter_crash.png"); // Font loading - raylib::Vector2 fontPosition1(screenWidth/2 - MeasureTextEx(font1, msg1.c_str(), font1.baseSize, -3).x/2, - screenHeight/2 - font1.baseSize/2 - 80); + raylib::Vector2 fontPosition1( + screenWidth / 2 - MeasureTextEx(font1, msg1.c_str(), font1.baseSize, -3).x / 2, + screenHeight / 2 - font1.baseSize / 2 - 80); - raylib::Vector2 fontPosition2(screenWidth/2 - MeasureTextEx(font2, msg2.c_str(), font2.baseSize, -2).x/2, - screenHeight/2 - font2.baseSize/2 - 10); + raylib::Vector2 fontPosition2( + screenWidth / 2 - MeasureTextEx(font2, msg2.c_str(), font2.baseSize, -2).x / 2, + screenHeight / 2 - font2.baseSize / 2 - 10); - raylib::Vector2 fontPosition3(screenWidth/2 - MeasureTextEx(font3, msg3.c_str(), font3.baseSize, 2).x/2, - screenHeight/2 - font3.baseSize/2 + 50); + raylib::Vector2 fontPosition3( + screenWidth / 2 - MeasureTextEx(font3, msg3.c_str(), font3.baseSize, 2).x / 2, + screenHeight / 2 - font3.baseSize / 2 + 50); - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- // TODO: Update variables here... diff --git a/examples/text/text_raylib_fonts.cpp b/examples/text/text_raylib_fonts.cpp index be354aa6..c7a3c884 100644 --- a/examples/text/text_raylib_fonts.cpp +++ b/examples/text/text_raylib_fonts.cpp @@ -1,23 +1,23 @@ /******************************************************************************************* -* -* raylib [text] example - raylib font loading and usage -* -* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!) -* To view details and credits for those fonts, check raylib license file -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [text] example - raylib font loading and usage + * + * NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!) + * To view details and credits for those fonts, check raylib license file + * + * This example has been created using raylib 1.7 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2017 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ -#include #include +#include #include "raylib-cpp.hpp" -#define MAX_FONTS 8 +#define MAX_FONTS 8 int main() { // Initialization @@ -37,8 +37,7 @@ int main() { raylib::Font("resources/fonts/romulus.png"), raylib::Font("resources/fonts/pixantiqua.png"), raylib::Font("resources/fonts/alpha_beta.png"), - raylib::Font("resources/fonts/jupiter_crash.png") - }; + raylib::Font("resources/fonts/jupiter_crash.png")}; std::array messages = { "ALAGARD FONT designed by Hewett Tsoi", @@ -48,18 +47,16 @@ int main() { "ROMULUS FONT designed by Hewett Tsoi", "PIXANTIQUA FONT designed by Gerhard Grossmann", "ALPHA_BETA FONT designed by Brian Kent (AEnigma)", - "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" - }; + "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)"}; - std::array spacings = { 2, 4, 8, 4, 3, 4, 4, 1 }; + std::array spacings = {2, 4, 8, 4, 3, 4, 4, 1}; std::array positions; - for (int i = 0; i < fonts.size(); i++) - { + for (int i = 0; i < fonts.size(); i++) { auto size = fonts[i].MeasureText(messages[i], fonts[i].baseSize * 2, spacings[i]); - positions[i].x = screenWidth/2 - size.x/2; - positions[i].y = 60 + fonts[i].baseSize + 45*i; + positions[i].x = screenWidth / 2 - size.x / 2; + positions[i].y = 60 + fonts[i].baseSize + 45 * i; } // Small Y position corrections @@ -67,11 +64,11 @@ int main() { positions[4].y += 2; positions[7].y -= 8; - std::array colors = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; + std::array colors = {MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED}; //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- // Update your variables here @@ -86,9 +83,8 @@ int main() { textColor.DrawText("free fonts included with raylib", 250, 20, 20); textColor.DrawLine(220, 50, 590, 50); - for (int i = 0; i < fonts.size(); i++) - { - fonts[i].DrawText(messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]); + for (int i = 0; i < fonts.size(); i++) { + fonts[i].DrawText(messages[i], positions[i], fonts[i].baseSize * 2, spacings[i], colors[i]); } } EndDrawing(); diff --git a/examples/textures/textures_bunnymark.cpp b/examples/textures/textures_bunnymark.cpp index 34975d62..d93a2da2 100644 --- a/examples/textures/textures_bunnymark.cpp +++ b/examples/textures/textures_bunnymark.cpp @@ -1,13 +1,13 @@ /******************************************************************************************* -* -* raylib [textures] example - Bunnymark -* -* This example has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [textures] example - Bunnymark + * + * This example has been created using raylib 1.6 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include @@ -15,7 +15,7 @@ // This is the maximum amount of elements (quads) per batch // NOTE: This value is defined in [rlgl] module and can be changed there -#define MAX_BATCH_ELEMENTS 8192 +#define MAX_BATCH_ELEMENTS 8192 class Bunny { public: @@ -23,20 +23,17 @@ class Bunny { position = GetMousePosition(); speed.x = static_cast(GetRandomValue(-250, 250)) / 60.0f; speed.y = static_cast(GetRandomValue(-250, 250)) / 60.0f; - color = raylib::Color( - GetRandomValue(50, 240), - GetRandomValue(80, 240), - GetRandomValue(100, 240)); + color = raylib::Color(GetRandomValue(50, 240), GetRandomValue(80, 240), GetRandomValue(100, 240)); } void Update(const raylib::Texture2D& texBunny) { position.x += speed.x; position.y += speed.y; - if (((position.x + texBunny.width/2) > GetScreenWidth()) || - ((position.x + texBunny.width/2) < 0)) speed.x *= -1; - if (((position.y + texBunny.height/2) > GetScreenHeight()) || - ((position.y + texBunny.height/2 - 40) < 0)) speed.y *= -1; + if (((position.x + texBunny.width / 2) > GetScreenWidth()) || ((position.x + texBunny.width / 2) < 0)) + speed.x *= -1; + if (((position.y + texBunny.height / 2) > GetScreenHeight()) || ((position.y + texBunny.height / 2 - 40) < 0)) + speed.y *= -1; } Vector2 position; @@ -44,8 +41,7 @@ class Bunny { Color color; }; -int main(void) -{ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -58,11 +54,11 @@ int main(void) std::list bunnies; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { @@ -74,7 +70,7 @@ int main(void) // Update bunnies - for (Bunny& bunny: bunnies) { + for (Bunny& bunny : bunnies) { bunny.Update(texBunny); } //---------------------------------------------------------------------------------- @@ -97,7 +93,12 @@ int main(void) DrawRectangle(0, 0, screenWidth, 40, BLACK); raylib::DrawText(TextFormat("bunnies: %i", bunnies.size()), 120, 10, 20, GREEN); - raylib::DrawText(TextFormat("batched draw calls: %i", 1 + bunnies.size()/MAX_BATCH_ELEMENTS), 320, 10, 20, MAROON); + raylib::DrawText( + TextFormat("batched draw calls: %i", 1 + bunnies.size() / MAX_BATCH_ELEMENTS), + 320, + 10, + 20, + MAROON); DrawFPS(10, 10); } diff --git a/examples/textures/textures_image_drawing.cpp b/examples/textures/textures_image_drawing.cpp index b4538337..4f02b151 100644 --- a/examples/textures/textures_image_drawing.cpp +++ b/examples/textures/textures_image_drawing.cpp @@ -1,15 +1,15 @@ /******************************************************************************************* -* -* raylib [textures] example - Image loading and drawing on it -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [textures] example - Image loading and drawing on it + * + * NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) + * + * This example has been created using raylib 1.4 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2016 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -23,18 +23,18 @@ int main(void) { raylib::Color darkGray = DARKGRAY; // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - raylib::Image cat("resources/cat.png"); // Load image in CPU memory (RAM) - cat.Crop(raylib::Rectangle(100, 10, 280, 380)) // Crop an image piece - .FlipHorizontal() // Flip cropped image horizontally - .Resize(150, 200); // Resize flipped-cropped image + raylib::Image cat("resources/cat.png"); // Load image in CPU memory (RAM) + cat.Crop(raylib::Rectangle(100, 10, 280, 380)) // Crop an image piece + .FlipHorizontal() // Flip cropped image horizontally + .Resize(150, 200); // Resize flipped-cropped image - raylib::Image parrots("resources/parrots.png"); // Load image in CPU memory (RAM) + raylib::Image parrots("resources/parrots.png"); // Load image in CPU memory (RAM) // Draw one image over the other with a scaling of 1.5f - parrots - .Draw(cat, - raylib::Rectangle(0, 0, cat.GetWidth(), cat.GetHeight()), - raylib::Rectangle(30, 40, cat.GetWidth() * 1.5f, cat.GetHeight() * 1.5f)); + parrots.Draw( + cat, + raylib::Rectangle(0, 0, cat.GetWidth(), cat.GetHeight()), + raylib::Rectangle(30, 40, cat.GetWidth() * 1.5f, cat.GetHeight() * 1.5f)); parrots.Crop(raylib::Rectangle(0, 50, parrots.GetWidth(), parrots.GetHeight() - 100)); // Crop resulting image // Load custom font for frawing on image @@ -43,13 +43,13 @@ int main(void) { // Draw over image using custom font parrots.DrawText(font, "PARROTS & CAT", raylib::Vector2(300, 230), font.baseSize, -2); - raylib::Texture2D texture(parrots); // Image converted to texture, uploaded to GPU memory (VRAM) + raylib::Texture2D texture(parrots); // Image converted to texture, uploaded to GPU memory (VRAM) SetTargetFPS(60); //--------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- // Update your variables here @@ -61,16 +61,19 @@ int main(void) { { window.ClearBackground(RAYWHITE); - texture.Draw(screenWidth / 2 - texture.width / 2, - screenHeight / 2 - texture.height / 2 - 40); - darkGray.DrawRectangleLines(screenWidth / 2 - texture.width / 2, + texture.Draw(screenWidth / 2 - texture.width / 2, screenHeight / 2 - texture.height / 2 - 40); + darkGray.DrawRectangleLines( + screenWidth / 2 - texture.width / 2, screenHeight / 2 - texture.height / 2 - 40, - texture.width, texture.height); + texture.width, + texture.height); - darkGray.DrawText("We are drawing only one texture from various images composed!", - 240, 350, 10); - darkGray.DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", - 190, 370, 10); + darkGray.DrawText("We are drawing only one texture from various images composed!", 240, 350, 10); + darkGray.DrawText( + "Source images have been cropped, scaled, flipped and copied one over the other.", + 190, + 370, + 10); } EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/textures/textures_image_loading.cpp b/examples/textures/textures_image_loading.cpp index 68b019ea..df762bed 100644 --- a/examples/textures/textures_image_loading.cpp +++ b/examples/textures/textures_image_loading.cpp @@ -1,15 +1,15 @@ /******************************************************************************************* -* -* raylib [textures] example - Image loading and texture creation -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ + * + * raylib [textures] example - Image loading and texture creation + * + * NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) + * + * This example has been created using raylib 1.3 (www.raylib.com) + * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + * + * Copyright (c) 2015 Ramon Santamaria (@raysan5) + * + ********************************************************************************************/ #include "raylib-cpp.hpp" @@ -24,7 +24,7 @@ int main() { raylib::Color textColor = raylib::Color::LightGray(); // Main game loop - while (!window.ShouldClose()) { // Detect window close button or ESC key + while (!window.ShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- // Update your variables here diff --git a/include/AudioDevice.hpp b/include/AudioDevice.hpp index 6a1d49a4..eeebde64 100644 --- a/include/AudioDevice.hpp +++ b/include/AudioDevice.hpp @@ -37,7 +37,7 @@ class AudioDevice { * * @throws raylib::RaylibException Throws if the AudioDevice failed to initialize. */ - static void Init() { + static void Init() { ::InitAudioDevice(); if (!IsReady()) { throw RaylibException("Failed to initialize AudioDevice"); @@ -52,7 +52,7 @@ class AudioDevice { /** * Check if audio device has been initialized successfully. */ - static bool IsReady() { return ::IsAudioDeviceReady(); } + static bool IsReady() { return ::IsAudioDeviceReady(); } /** * Set master volume (listener). diff --git a/include/AudioStream.hpp b/include/AudioStream.hpp index 96a6dcec..ecb4f864 100644 --- a/include/AudioStream.hpp +++ b/include/AudioStream.hpp @@ -7,7 +7,8 @@ namespace raylib { /** * AudioStream management functions. * - * The audio stream will be unloaded on object destruction. Use raylib::AudioStreamUnmanaged if you're looking to not unload. + * The audio stream will be unloaded on object destruction. Use raylib::AudioStreamUnmanaged if you're looking to not + * unload. * * @see raylib::AudioStreamUnmanaged */ diff --git a/include/AutomationEventList.hpp b/include/AutomationEventList.hpp index 2bd9a5db..0f9b9d62 100644 --- a/include/AutomationEventList.hpp +++ b/include/AutomationEventList.hpp @@ -11,8 +11,7 @@ namespace raylib { */ class AutomationEventList : public ::AutomationEventList { public: - AutomationEventList(const ::AutomationEventList& automationEventList) - : ::AutomationEventList(automationEventList) { + AutomationEventList(const ::AutomationEventList& automationEventList) : ::AutomationEventList(automationEventList) { // Nothing. } diff --git a/include/BoundingBox.hpp b/include/BoundingBox.hpp index febe8295..e2f0c90e 100644 --- a/include/BoundingBox.hpp +++ b/include/BoundingBox.hpp @@ -42,8 +42,14 @@ class BoundingBox : public ::BoundingBox { } [[nodiscard]] std::string ToString() const { - return ::TextFormat("BoundingBox(min=(%f, %f, %f), max=(%f, %f, %f))", - min.x, min.y, min.z, max.x, max.y, max.z); + return ::TextFormat( + "BoundingBox(min=(%f, %f, %f), max=(%f, %f, %f))", + min.x, + min.y, + min.z, + max.x, + max.y, + max.z); } operator std::string() const { return ToString(); } diff --git a/include/Camera2D.hpp b/include/Camera2D.hpp index c43fd4cc..001778a4 100644 --- a/include/Camera2D.hpp +++ b/include/Camera2D.hpp @@ -11,8 +11,7 @@ namespace raylib { */ class Camera2D : public ::Camera2D { public: - Camera2D(const ::Camera2D& camera) - : ::Camera2D(camera) { + Camera2D(const ::Camera2D& camera) : ::Camera2D(camera) { // Nothing. } diff --git a/include/Camera3D.hpp b/include/Camera3D.hpp index ac882aff..c3147bf8 100644 --- a/include/Camera3D.hpp +++ b/include/Camera3D.hpp @@ -13,7 +13,7 @@ namespace raylib { */ class Camera3D : public ::Camera3D { public: - Camera3D(const ::Camera3D& camera) : ::Camera3D(camera) { } + Camera3D(const ::Camera3D& camera) : ::Camera3D(camera) {} /** * Create a new Camera3D. @@ -47,8 +47,13 @@ class Camera3D : public ::Camera3D { [[nodiscard]] std::string ToString() const { return ::TextFormat( "Camera3D(position=(%f, %f, %f), target=(%f, %f, %f), fovy=%f)", - position.x, position.y, position.z, - target.x, target.y, target.z, fovy); + position.x, + position.y, + position.z, + target.x, + target.y, + target.z, + fovy); } operator std::string() const { return ToString(); } diff --git a/include/Color.hpp b/include/Color.hpp index 99d87090..fd80c144 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -36,9 +36,9 @@ class Color : public ::Color { /** * Get Color structure from hexadecimal value */ - explicit Color(unsigned int hexValue) : ::Color(::GetColor(hexValue)) { } + explicit Color(unsigned int hexValue) : ::Color(::GetColor(hexValue)) {} - Color(void* srcPtr, int format) : ::Color(::GetPixelColor(srcPtr, format)) { } + Color(void* srcPtr, int format) : ::Color(::GetPixelColor(srcPtr, format)) {} /** * Returns hexadecimal value for a Color @@ -67,7 +67,7 @@ class Color : public ::Color { /** * Returns Color from normalized values [0..1] */ - explicit Color(::Vector4 normalized) : Color(::ColorFromNormalized(normalized)) { } + explicit Color(::Vector4 normalized) : Color(::ColorFromNormalized(normalized)) {} /** * Returns HSV values for a Color @@ -181,9 +181,7 @@ class Color : public ::Color { void DrawRectangleLines(::Rectangle rec, float lineThick) const { ::DrawRectangleLinesEx(rec, lineThick, *this); } - bool IsEqual(::Color color) { - return ::ColorIsEqual(*this, color); - } + bool IsEqual(::Color color) { return ::ColorIsEqual(*this, color); } bool operator==(const ::Color& other) const { return ::ColorIsEqual(*this, other); } bool operator!=(const ::Color& other) const { return !::ColorIsEqual(*this, other); } @@ -208,9 +206,7 @@ class Color : public ::Color { */ RLCPP_NODISCARD Color Alpha(float alpha) const { return ::ColorAlpha(*this, alpha); } - Color Lerp(::Color color2, float factor) { - return ::ColorLerp(*this, color2, factor); - } + Color Lerp(::Color color2, float factor) { return ::ColorLerp(*this, color2, factor); } /** * Returns src alpha-blended into dst color with tint diff --git a/include/Font.hpp b/include/Font.hpp index 32989df1..f527d7d7 100644 --- a/include/Font.hpp +++ b/include/Font.hpp @@ -2,6 +2,7 @@ #define RAYLIB_CPP_INCLUDE_FONT_HPP_ #include +#include #include "./FontUnmanaged.hpp" diff --git a/include/FontUnmanaged.hpp b/include/FontUnmanaged.hpp index aa720236..176c34e1 100644 --- a/include/FontUnmanaged.hpp +++ b/include/FontUnmanaged.hpp @@ -206,12 +206,8 @@ class FontUnmanaged : public ::Font { /** * Draw text using font and additional parameters. */ - void DrawText( - const std::string& text, - ::Vector2 position, - float fontSize, - float spacing, - ::Color tint = WHITE) const { + void + DrawText(const std::string& text, ::Vector2 position, float fontSize, float spacing, ::Color tint = WHITE) const { ::DrawTextEx(*this, text.c_str(), position, fontSize, spacing, tint); } @@ -225,13 +221,8 @@ class FontUnmanaged : public ::Font { /** * Draw text using font and additional parameters. */ - void DrawText( - const std::string& text, - int posX, - int posY, - float fontSize, - float spacing, - ::Color tint = WHITE) const { + void + DrawText(const std::string& text, int posX, int posY, float fontSize, float spacing, ::Color tint = WHITE) const { ::DrawTextEx( *this, text.c_str(), diff --git a/include/Functions.hpp b/include/Functions.hpp index 87776284..85148bc2 100644 --- a/include/Functions.hpp +++ b/include/Functions.hpp @@ -191,7 +191,7 @@ RLCPP_MAYBEUNUSED RLCPPAPI std::vector LoadDroppedFiles() { /** * Get file modification time (last write time) */ -RLCPP_MAYBEUNUSED 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()); } diff --git a/include/Image.hpp b/include/Image.hpp index c93584be..865521a3 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -26,7 +26,7 @@ class Image : public ::Image { // Nothing. } - Image(const ::Image& image) : ::Image(image) { } + Image(const ::Image& image) : ::Image(image) {} /** * Load an image from the given file. @@ -795,9 +795,7 @@ class Image : public ::Image { /** * Apply custom square convolution kernel to image */ - void KernelConvolution(const float* kernel, int kernelSize) { - ::ImageKernelConvolution(this, kernel, kernelSize); - } + void KernelConvolution(const float* kernel, int kernelSize) { ::ImageKernelConvolution(this, kernel, kernelSize); } protected: void set(const ::Image& image) { diff --git a/include/Matrix.hpp b/include/Matrix.hpp index 3328ec6a..8f4a3f16 100644 --- a/include/Matrix.hpp +++ b/include/Matrix.hpp @@ -13,8 +13,7 @@ namespace raylib { */ class Matrix : public ::Matrix { public: - constexpr Matrix(const ::Matrix& mat) - : ::Matrix(mat) { + constexpr Matrix(const ::Matrix& mat) : ::Matrix(mat) { // Nothing. } @@ -87,10 +86,22 @@ class Matrix : public ::Matrix { " %f, %f, %f, %f\n" " %f, %f, %f, %f\n" ")", - m0, m4, m8, m12, - m1, m5, m9, m13, - m2, m6, m10, m14, - m3, m7, m11, m15); + m0, + m4, + m8, + m12, + m1, + m5, + m9, + m13, + m2, + m6, + m10, + m14, + m3, + m7, + m11, + m15); } operator std::string() const { return ToString(); } diff --git a/include/MeshUnmanaged.hpp b/include/MeshUnmanaged.hpp index d2354b0f..47ee2824 100644 --- a/include/MeshUnmanaged.hpp +++ b/include/MeshUnmanaged.hpp @@ -126,7 +126,7 @@ class MeshUnmanaged : public ::Mesh { GETTERSETTER(float*, Normals, normals) GETTERSETTER(float*, Tangents, tangents) GETTERSETTER(unsigned char*, Colors, colors) - GETTERSETTER(unsigned short*, Indices, indices) // NOLINT + GETTERSETTER(unsigned short*, Indices, indices) // NOLINT GETTERSETTER(float*, AnimVertices, animVertices) GETTERSETTER(float*, AnimNormals, animNormals) GETTERSETTER(unsigned char*, BoneIndices, boneIndices) @@ -142,7 +142,10 @@ class MeshUnmanaged : public ::Mesh { [[nodiscard]] std::string ToString() const { return ::TextFormat( - "Mesh(vertexCount=%d, triangleCount=%d, boneCount=%d)", vertexCount, triangleCount, boneCount); + "Mesh(vertexCount=%d, triangleCount=%d, boneCount=%d)", + vertexCount, + triangleCount, + boneCount); } operator std::string() const { return ToString(); } diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index 3a488880..a6597181 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -108,9 +108,7 @@ class ModelAnimation : public ::ModelAnimation { } } - static void Unload(ModelAnimation *modelAnimation, int count) { - ::UnloadModelAnimations(modelAnimation, count); - } + static void Unload(ModelAnimation* modelAnimation, int count) { ::UnloadModelAnimations(modelAnimation, count); } /** * Update model animation pose @@ -123,8 +121,8 @@ class ModelAnimation : public ::ModelAnimation { /** * Blend two animation poses */ - ModelAnimation& Blend( - const ::Model& model, float frameA, const ::ModelAnimation& animB, float frameB, float blend) { + ModelAnimation& + Blend(const ::Model& model, float frameA, const ::ModelAnimation& animB, float frameB, float blend) { ::UpdateModelAnimationEx(model, *this, frameA, animB, frameB, blend); return *this; } diff --git a/include/MusicUnmanaged.hpp b/include/MusicUnmanaged.hpp index 1053b36a..7c8c13f4 100644 --- a/include/MusicUnmanaged.hpp +++ b/include/MusicUnmanaged.hpp @@ -45,9 +45,7 @@ class MusicUnmanaged : public ::Music { * * @throws raylib::RaylibException Throws if the music failed to load. */ - MusicUnmanaged(const std::string& fileType, unsigned char* data, int dataSize) { - Load(fileType, data, dataSize); - } + MusicUnmanaged(const std::string& fileType, unsigned char* data, int dataSize) { Load(fileType, data, dataSize); } GETTER(::AudioStream, Stream, stream) GETTER(unsigned int, FrameCount, frameCount) diff --git a/include/Quaternion.hpp b/include/Quaternion.hpp index 6b28c673..8cc60ad9 100644 --- a/include/Quaternion.hpp +++ b/include/Quaternion.hpp @@ -1,4 +1,4 @@ -#ifndef RAYLIB_CPP_INCLUDE_QUATERNION_HPP_ +#ifndef RAYLIB_CPP_INCLUDE_QUATERNION_HPP_ #define RAYLIB_CPP_INCLUDE_QUATERNION_HPP_ #ifndef RAYLIB_CPP_NO_MATH @@ -73,16 +73,12 @@ class Quaternion : public ::Quaternion { /** * Add quaternion and float value */ - RLCPP_NODISCARD Quaternion Add(const float value) const { - return ::QuaternionAddValue(*this, value); - } + RLCPP_NODISCARD Quaternion Add(const float value) const { return ::QuaternionAddValue(*this, value); } /** * Add quaternion and float value */ - Quaternion operator+(const float value) const { - return ::QuaternionAddValue(*this, value); - } + Quaternion operator+(const float value) const { return ::QuaternionAddValue(*this, value); } /** * Add quaternion and float value @@ -119,16 +115,12 @@ class Quaternion : public ::Quaternion { /** * Subtract quaternion by float value */ - RLCPP_NODISCARD Quaternion Subtract(const float value) const { - return ::QuaternionSubtractValue(*this, value); - } + RLCPP_NODISCARD Quaternion Subtract(const float value) const { return ::QuaternionSubtractValue(*this, value); } /** * Get identity quaternion */ - static RLCPP_NODISCARD Quaternion Identity() { - return ::QuaternionIdentity(); - } + static RLCPP_NODISCARD Quaternion Identity() { return ::QuaternionIdentity(); } RLCPP_NODISCARD float Length() const { return ::QuaternionLength(*this); } @@ -213,7 +205,9 @@ class Quaternion : public ::Quaternion { const ::Quaternion& outTangent1, const ::Quaternion& q2, const ::Quaternion& inTangent2, - const float t) const { return ::QuaternionCubicHermiteSpline(*this, outTangent1, q2, inTangent2, t); } + const float t) const { + return ::QuaternionCubicHermiteSpline(*this, outTangent1, q2, inTangent2, t); + } /** * Calculate quaternion based on the rotation from one vector to another @@ -225,16 +219,12 @@ class Quaternion : public ::Quaternion { /** * Get a quaternion for a given rotation matrix */ - static RLCPP_NODISCARD Quaternion FromMatrix(const ::Matrix& mat) { - return ::QuaternionFromMatrix(mat); - } + static RLCPP_NODISCARD Quaternion FromMatrix(const ::Matrix& mat) { return ::QuaternionFromMatrix(mat); } /** * Get a matrix for this quaternion */ - RLCPP_NODISCARD ::Matrix ToMatrix() const { - return ::QuaternionToMatrix(*this); - } + RLCPP_NODISCARD ::Matrix ToMatrix() const { return ::QuaternionToMatrix(*this); } /** * Get rotation quaternion for an angle and axis @@ -247,9 +237,7 @@ class Quaternion : public ::Quaternion { /** * Get the rotation angle and axis for this quaternion */ - void ToAxisAngle(::Vector3* outAxis, float* outAngle) const { - ::QuaternionToAxisAngle(*this, outAxis, outAngle); - } + void ToAxisAngle(::Vector3* outAxis, float* outAngle) const { ::QuaternionToAxisAngle(*this, outAxis, outAngle); } /** * Get the quaternion equivalent to Euler angles @@ -263,16 +251,12 @@ class Quaternion : public ::Quaternion { * Get the Euler angles equivalent to quaternion * NOTE: Angles are returned in radians */ - RLCPP_NODISCARD ::Vector3 ToEuler() const { - return ::QuaternionToEuler(*this); - } + RLCPP_NODISCARD ::Vector3 ToEuler() const { return ::QuaternionToEuler(*this); } /** * Transform quaternion given transformation matrix */ - RLCPP_NODISCARD Quaternion Transform(const ::Matrix& mat) const { - return ::QuaternionTransform(*this, mat); - } + RLCPP_NODISCARD Quaternion Transform(const ::Matrix& mat) const { return ::QuaternionTransform(*this, mat); } /* * Check whether two given quaternions are almost equal diff --git a/include/RayCollision.hpp b/include/RayCollision.hpp index 316a0d5f..82d6b6f6 100644 --- a/include/RayCollision.hpp +++ b/include/RayCollision.hpp @@ -12,7 +12,7 @@ namespace raylib { */ class RayCollision : public ::RayCollision { public: - RayCollision(const ::RayCollision& ray) : ::RayCollision(ray) { } + RayCollision(const ::RayCollision& ray) : ::RayCollision(ray) {} constexpr RayCollision(bool hit, float distance, ::Vector3 point, ::Vector3 normal) : ::RayCollision{hit, distance, point, normal} { @@ -22,8 +22,7 @@ class RayCollision : public ::RayCollision { /** * Get collision info between ray and bounding box */ - RayCollision(const ::Ray& ray, const ::BoundingBox& box) - : ::RayCollision(::GetRayCollisionBox(ray, box)) { + RayCollision(const ::Ray& ray, const ::BoundingBox& box) : ::RayCollision(::GetRayCollisionBox(ray, box)) { // Nothing. } @@ -69,8 +68,12 @@ class RayCollision : public ::RayCollision { "RayCollision(hit=%s, distance=%f, point=(%f, %f, %f), normal=(%f, %f, %f))", hit ? "true" : "false", distance, - point.x, point.y, point.z, - normal.x, normal.y, normal.z); + point.x, + point.y, + point.z, + normal.x, + normal.y, + normal.z); } operator std::string() const { return ToString(); } diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 59063fb9..565bc55b 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -47,9 +47,7 @@ class Rectangle : public ::Rectangle { ::DrawRectangle(posX, posY, width, height, color); } - static void Draw(::Vector2 position, ::Vector2 size, ::Color color) { - ::DrawRectangleV(position, size, color); - } + static void Draw(::Vector2 position, ::Vector2 size, ::Color color) { ::DrawRectangleV(position, size, color); } void Draw(::Color color) const { ::DrawRectangleRec(*this, color); } diff --git a/include/ShaderUnmanaged.hpp b/include/ShaderUnmanaged.hpp index 9a761a58..bc38f4eb 100644 --- a/include/ShaderUnmanaged.hpp +++ b/include/ShaderUnmanaged.hpp @@ -16,7 +16,7 @@ class ShaderUnmanaged : public ::Shader { public: ShaderUnmanaged() : ::Shader{rlGetShaderIdDefault(), rlGetShaderLocsDefault()} {} - ShaderUnmanaged(const ::Shader& shader) : ::Shader(shader) { } + ShaderUnmanaged(const ::Shader& shader) : ::Shader(shader) {} ShaderUnmanaged(unsigned int id, int* locs = nullptr) : ::Shader{id, locs} {} diff --git a/include/Texture.hpp b/include/Texture.hpp index ecf1baf6..39c14008 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -30,7 +30,7 @@ class Texture : public TextureUnmanaged { /** * Move constructor. */ - Texture(Texture&& other) noexcept { + Texture(Texture&& other) noexcept { set(other); other.id = 0; @@ -66,28 +66,28 @@ class Texture : public TextureUnmanaged { } /** - * Unload previous texture, then load texture from image data - */ + * Unload previous texture, then load texture from image data + */ void Load(const ::Image& image) { Unload(); TextureUnmanaged::Load(image); } /** - * Unload previous texture, then load cubemap from image. - * Multiple image cubemap layouts supported - */ + * Unload previous texture, then load cubemap from image. + * Multiple image cubemap layouts supported + */ void Load(const ::Image& image, int layoutType) { - Unload(); - TextureUnmanaged::Load(image, layoutType); + Unload(); + TextureUnmanaged::Load(image, layoutType); } /** - * Unload previous texture, then load texture from file into GPU memory (VRAM) - */ + * Unload previous texture, then load texture from file into GPU memory (VRAM) + */ void Load(const std::string& fileName) { - Unload(); - TextureUnmanaged::Load(fileName); + Unload(); + TextureUnmanaged::Load(fileName); } }; diff --git a/include/TextureUnmanaged.hpp b/include/TextureUnmanaged.hpp index 87f58b56..8945da33 100644 --- a/include/TextureUnmanaged.hpp +++ b/include/TextureUnmanaged.hpp @@ -323,9 +323,7 @@ class TextureUnmanaged : public ::Texture { * * @return True or false depending on whether the Texture has data. */ - RLCPP_NODISCARD bool IsValid() const { - return ::IsTextureValid(*this); - } + RLCPP_NODISCARD bool IsValid() const { return ::IsTextureValid(*this); } protected: void set(const ::Texture& texture) { diff --git a/include/WaveUnmanaged.hpp b/include/WaveUnmanaged.hpp index 6c0ca98d..f8699fb2 100644 --- a/include/WaveUnmanaged.hpp +++ b/include/WaveUnmanaged.hpp @@ -63,7 +63,11 @@ class WaveUnmanaged : public ::Wave { [[nodiscard]] std::string ToString() const { return ::TextFormat( "Wave(frameCount=%u, sampleRate=%u, sampleSize=%u, channels=%u, data=%p)", - frameCount, sampleRate, sampleSize, channels, data); + frameCount, + sampleRate, + sampleSize, + channels, + data); } operator std::string() const { return ToString(); } diff --git a/include/Window.hpp b/include/Window.hpp index 6ca85f46..1eec86bb 100644 --- a/include/Window.hpp +++ b/include/Window.hpp @@ -87,7 +87,7 @@ class Window { /** * Check if KEY_ESCAPE pressed or Close icon pressed */ - static bool ShouldClose() { return ::WindowShouldClose(); } + static bool ShouldClose() { return ::WindowShouldClose(); } /** * Set a custom key to exit program (default is ESC) @@ -106,71 +106,67 @@ class Window { /** * Check if cursor is on the current screen */ - static bool IsCursorOnScreen() { return ::IsCursorOnScreen(); } + static bool IsCursorOnScreen() { return ::IsCursorOnScreen(); } /** * Check if cursor is not visible */ - static bool IsCursorHidden() { return ::IsCursorHidden(); } + static bool IsCursorHidden() { return ::IsCursorHidden(); } /** * Hides cursor */ - static void HideCursor() { ::HideCursor(); } + static void HideCursor() { ::HideCursor(); } /** * Shows cursor */ - static void ShowCursor() { ::ShowCursor(); } + static void ShowCursor() { ::ShowCursor(); } /** * Enables cursor (unlock cursor) */ - RLCPP_MAYBEUNUSED RLCPPAPI inline void EnableCursor() { - ::EnableCursor(); - } + RLCPP_MAYBEUNUSED RLCPPAPI inline void EnableCursor() { ::EnableCursor(); } /** * Disables cursor (lock cursor) */ - RLCPP_MAYBEUNUSED RLCPPAPI inline void DisableCursor() { - ::DisableCursor(); - } + RLCPP_MAYBEUNUSED RLCPPAPI inline void DisableCursor() { ::DisableCursor(); } /** * Check if window is currently fullscreen */ - static bool IsFullscreen() { return ::IsWindowFullscreen(); } + static bool IsFullscreen() { return ::IsWindowFullscreen(); } /** * Check if window is currently hidden */ - static bool IsHidden() { return ::IsWindowHidden(); } + static bool IsHidden() { return ::IsWindowHidden(); } /** * Check if window is currently minimized */ - static bool IsMinimized() { return ::IsWindowMinimized(); } + static bool IsMinimized() { return ::IsWindowMinimized(); } /** * Check if window is currently minimized */ - static bool IsMaximized() { return ::IsWindowMaximized(); } + static bool IsMaximized() { return ::IsWindowMaximized(); } /** * Check if window is currently focused */ - static bool IsFocused() { return ::IsWindowFocused(); } + static bool IsFocused() { return ::IsWindowFocused(); } /** * Check if window has been resized last frame */ - static bool IsResized() { return ::IsWindowResized(); } + static bool IsResized() { return ::IsWindowResized(); } /** * Check if one specific window flag is enabled */ - static bool IsState(unsigned int flag) { return ::IsWindowState(flag); } + static bool IsState(unsigned int flag) { return ::IsWindowState(flag); } /** * Set window configuration state using flags @@ -212,7 +208,8 @@ class Window { if (!IsFullscreen()) { ToggleFullscreen(); } - } else { + } + else { if (IsFullscreen()) { ToggleFullscreen(); } @@ -427,22 +424,22 @@ class Window { /** * Returns current FPS */ - static int GetFPS() { return ::GetFPS(); } + static int GetFPS() { return ::GetFPS(); } /** * Draw current FPS */ - static void DrawFPS(int posX = 10, int posY = 10) { ::DrawFPS(posX, posY); } + static void DrawFPS(int posX = 10, int posY = 10) { ::DrawFPS(posX, posY); } /** * Returns time in seconds for last frame drawn */ - static float GetFrameTime() { return ::GetFrameTime(); } + static float GetFrameTime() { return ::GetFrameTime(); } /** * Returns elapsed time in seconds since InitWindow() */ - static double GetTime() { return ::GetTime(); } + static double GetTime() { return ::GetTime(); } /** * Check if window has been initialized successfully @@ -473,7 +470,8 @@ class Window { if (m_drawing) { EndDrawing(); m_drawing = false; - } else { + } + else { BeginDrawing(); m_drawing = true; } @@ -482,12 +480,13 @@ class Window { } protected: - /** - * Handles the internal drawing state for calling either `BeginDrawing()` or `EndDrawing()` from the `Drawing()` function. - * - * @see Drawing() - */ - bool m_drawing = false; + /** + * 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/raylib-cpp-utils.hpp b/include/raylib-cpp-utils.hpp index 521d8d21..a769c270 100644 --- a/include/raylib-cpp-utils.hpp +++ b/include/raylib-cpp-utils.hpp @@ -42,8 +42,8 @@ * @param method The human-readable name for the method. * @param name The machine-readable name of the property. */ -#define GETTERSETTER(type, method, name) \ - GETTER(type, method, name) \ +#define GETTERSETTER(type, method, name) \ + GETTER(type, method, name) \ SETTER(type, method, name) #endif diff --git a/include/raylib-cpp.hpp b/include/raylib-cpp.hpp index 587b8e2f..5c25be64 100644 --- a/include/raylib-cpp.hpp +++ b/include/raylib-cpp.hpp @@ -52,8 +52,8 @@ #include "./Matrix.hpp" #include "./Mesh.hpp" #include "./Model.hpp" -#include "./ModelUnmanaged.hpp" #include "./ModelAnimation.hpp" +#include "./ModelUnmanaged.hpp" #include "./Mouse.hpp" #include "./Music.hpp" #include "./MusicUnmanaged.hpp" diff --git a/include/raylib.hpp b/include/raylib.hpp index 8e1ff0cc..7012efff 100644 --- a/include/raylib.hpp +++ b/include/raylib.hpp @@ -12,7 +12,7 @@ extern "C" { #define RAYLIB_H_FILE "raylib.h" #endif -#include RAYLIB_H_FILE // NOLINT +#include RAYLIB_H_FILE // NOLINT #if !defined(RAYLIB_VERSION_MAJOR) || !defined(RAYLIB_VERSION_MINOR) #error "raylib-cpp requires raylib >= 5" @@ -27,31 +27,31 @@ extern "C" { #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 +#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 +#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 diff --git a/include/raymath.hpp b/include/raymath.hpp index c981b3ca..cb47ebc7 100644 --- a/include/raymath.hpp +++ b/include/raymath.hpp @@ -16,7 +16,7 @@ extern "C" { #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif #define RAYMATH_DISABLE_CPP_OPERATORS -#include "raymath.h" // NOLINT +#include "raymath.h" // NOLINT #ifdef __GNUC__ #pragma GCC diagnostic pop #endif diff --git a/modules/raylib.cppm b/modules/raylib.cppm index ba3cabac..5b9e78ad 100644 --- a/modules/raylib.cppm +++ b/modules/raylib.cppm @@ -65,6 +65,7 @@ using raylib::Mesh; using raylib::Model; using raylib::ModelAnimation; using raylib::Music; +using raylib::Quaternion; // Alias for Vector4 using raylib::Ray; using raylib::RayCollision; using raylib::RaylibException; @@ -76,126 +77,125 @@ 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::TextureCubemap; // Alias for Texture using raylib::TextureCubemapUnmanaged; // Alias for TextureUnmanaged +using raylib::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 ::BlendMode; +using ::CameraMode; +using ::CameraProjection; using ::ConfigFlags; -using ::TraceLogLevel; +using ::CubemapLayout; +using ::FontType; +using ::GamepadAxis; +using ::GamepadButton; +using ::Gesture; using ::KeyboardKey; +using ::MaterialMapIndex; using ::MouseButton; using ::MouseCursor; -using ::GamepadButton; -using ::GamepadAxis; -using ::MaterialMapIndex; +using ::NPatchLayout; +using ::PixelFormat; +using ::ShaderAttributeDataType; 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; +using ::TraceLogLevel; // 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::ChangeDirectory; using raylib::DirectoryExists; -using raylib::IsFileExtension; +using raylib::DrawText; +using raylib::DrawTextEx; +using raylib::DrawTextPro; +using raylib::ExportImage; +using raylib::ExportImageAsCode; +using raylib::FileExists; +using raylib::GetClipboardText; +using raylib::GetCodepointCount; +using raylib::GetDirectoryPath; using raylib::GetFileExtension; +using raylib::GetFileModTime; using raylib::GetFileName; using raylib::GetFileNameWithoutExt; -using raylib::GetDirectoryPath; +using raylib::GetGamepadName; +using raylib::GetMonitorName; using raylib::GetPrevDirectoryPath; using raylib::GetWorkingDirectory; +using raylib::InitWindow; +using raylib::IsFileExtension; +using raylib::LoadCodepoints; using raylib::LoadDirectoryFiles; using raylib::LoadDirectoryFilesEx; -using raylib::ChangeDirectory; using raylib::LoadDroppedFiles; -using raylib::GetFileModTime; -using raylib::OpenURL; +using raylib::LoadFileText; +using raylib::LoadFont; +using raylib::LoadFontEx; 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::LoadImageRaw; using raylib::MeasureText; +using raylib::OpenURL; +using raylib::SaveFileText; +using raylib::SetClipboardText; +using raylib::SetWindowTitle; +using raylib::TakeScreenshot; +using raylib::TextFindIndex; +using raylib::TextInsert; 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::TextSubtext; +using raylib::TextToCamel; +using raylib::TextToFloat; +using raylib::TextToInteger; using raylib::TextToLower; using raylib::TextToPascal; using raylib::TextToSnake; -using raylib::TextToCamel; -using raylib::LoadCodepoints; -using raylib::GetCodepointCount; -using raylib::TextToInteger; -using raylib::TextToFloat; +using raylib::TextToUpper; /** * @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 }; +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 Colors /** @@ -203,14 +203,14 @@ inline constexpr ::Color RAYWHITE = CLITERAL(::Color){ 245, 245, 245, 255 }; * @brief Input-related functions: keyboard */ namespace Keyboard { +using raylib::Keyboard::GetCharPressed; +using raylib::Keyboard::GetKeyName; +using raylib::Keyboard::GetKeyPressed; +using raylib::Keyboard::IsKeyDown; 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; -using raylib::Keyboard::GetKeyName; } // namespace Keyboard /** @@ -218,26 +218,26 @@ using raylib::Keyboard::GetKeyName; * @brief Input-related functions: mouse */ namespace Mouse { -using raylib::Mouse::IsButtonPressed; +using raylib::Mouse::GetDelta; +using raylib::Mouse::GetPosition; +using raylib::Mouse::GetScreenToWorldRay; +using raylib::Mouse::GetTouchPosition; +using raylib::Mouse::GetTouchX; +using raylib::Mouse::GetTouchY; +using raylib::Mouse::GetWheelMove; +using raylib::Mouse::GetWheelMoveV; +using raylib::Mouse::GetX; +using raylib::Mouse::GetY; using raylib::Mouse::IsButtonDown; +using raylib::Mouse::IsButtonPressed; 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::SetCursor; using raylib::Mouse::SetOffset; +using raylib::Mouse::SetPosition; 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::GetScreenToWorldRay; +using raylib::Mouse::SetX; +using raylib::Mouse::SetY; } // namespace Mouse /** @@ -245,56 +245,56 @@ using raylib::Mouse::GetScreenToWorldRay; * @brief Input-related functions: touch */ namespace Touch { +using raylib::Touch::GetPointCount; +using raylib::Touch::GetPointId; +using raylib::Touch::GetPosition; using raylib::Touch::GetX; using raylib::Touch::GetY; -using raylib::Touch::GetPosition; -using raylib::Touch::GetPointId; -using raylib::Touch::GetPointCount; } // namespace Touch } // 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; + 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/raylib-assert.h b/tests/raylib-assert.h index 1e7f70ce..94e157ac 100644 --- a/tests/raylib-assert.h +++ b/tests/raylib-assert.h @@ -1,41 +1,41 @@ /********************************************************************************************** -* -* raylib-assert - Assertion library for raylib. -* https://github.com/robloach/raylib-assert -* -* Version: v3.3.1 -* -* Copyright 2026 Rob Loach (@RobLoach) -* -* DEPENDENCIES: -* raylib 6.0+ https://www.raylib.com -* -* LICENSE: zlib/libpng -* -* raylib-assert is licensed under an unmodified zlib/libpng license, which is an OSI-certified, -* BSD-like license that allows static linking with closed source software: -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ + * + * raylib-assert - Assertion library for raylib. + * https://github.com/robloach/raylib-assert + * + * Version: v3.3.1 + * + * Copyright 2026 Rob Loach (@RobLoach) + * + * DEPENDENCIES: + * raylib 6.0+ https://www.raylib.com + * + * LICENSE: zlib/libpng + * + * raylib-assert is licensed under an unmodified zlib/libpng license, which is an OSI-certified, + * BSD-like license that allows static linking with closed source software: + * + * This software is provided "as-is", without any express or implied warranty. In no event + * will the authors be held liable for any damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, including commercial + * applications, and to alter it and redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not claim that you + * wrote the original software. If you use this software in a product, an acknowledgment + * in the product documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be misrepresented + * as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + **********************************************************************************************/ #ifndef RAYLIB_ASSERT_H #define RAYLIB_ASSERT_H -#include // NULL +#include // NULL #ifndef RAYLIB_H #error "raylib-assert.h requires raylib.h to be included before raylib-assert.h" @@ -96,24 +96,21 @@ extern "C" { #endif // Internal helper: true when two floats are within RAYLIB_ASSERT_EPSILON of each other. -static inline bool RaylibAssertFloatEq(float a, float b) -{ +static inline bool RaylibAssertFloatEq(float a, float b) { float delta = a - b; if (delta < 0.0f) delta = -delta; return delta <= RAYLIB_ASSERT_EPSILON; } // Internal helper: true when two color channels differ by no more than the given tolerance. -static inline bool RaylibAssertChannelWithin(int a, int b, int tolerance) -{ +static inline bool RaylibAssertChannelWithin(int a, int b, int tolerance) { int delta = a - b; if (delta < 0) delta = -delta; return delta <= tolerance; } // Internal helper: true when a mesh contains basic CPU-side geometry data. -static inline bool RaylibAssertMeshValid(Mesh mesh) -{ +static inline bool RaylibAssertMeshValid(Mesh mesh) { return mesh.vertexCount > 0 && mesh.triangleCount > 0 && mesh.vertices != NULL; } @@ -125,9 +122,9 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #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__) +#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__) /** * Assert whether the given condition is true. @@ -610,33 +607,45 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #else #define Assert_0() AssertFail_1("No condition provided for Assert()") #define Assert_1(condition) Assert_2(condition, #condition) -#define Assert_2(condition, message) do { if (!((bool)(condition))) { RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: %s (%s:%i)", message, __FILE__, __LINE__); } } while(0) +#define Assert_2(condition, message) \ + do { \ + if (!((bool)(condition))) { \ + RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: %s (%s:%i)", message, __FILE__, __LINE__); \ + } \ + } \ + while (0) #define Assert_3(condition, message, p1) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) #define Assert_4(condition, message, p1, p2) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) #define Assert_5(condition, message, p1, p2, p3) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) -#define Assert_6(condition, message, p1, p2, p3, p4) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) -#define Assert_7(condition, message, p1, p2, p3, p4, p5) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5)) +#define Assert_6(condition, message, p1, p2, p3, p4) \ + Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) +#define Assert_7(condition, message, p1, p2, p3, p4, p5) \ + Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5)) #endif // AssertEqual() #define AssertEqual_0() AssertFail_1("No condition provided for AssertEqual()") #define AssertEqual_1(condition) AssertFail_1("AssertEqual() requires at least two parameters.") -#define AssertEqual_2(actual, expected) Assert_4((actual) == (expected), "AssertEqual(%s, %s) - Provided arguments are not equal", #actual, #expected) +#define AssertEqual_2(actual, expected) \ + Assert_4((actual) == (expected), "AssertEqual(%s, %s) - Provided arguments are not equal", #actual, #expected) #define AssertEqual_3(actual, expected, message) Assert_2((actual) == (expected), message) #define AssertEqual_4(actual, expected, message, p1) Assert_3((actual) == (expected), message, p1) #define AssertEqual_5(actual, expected, message, p1, p2) Assert_4((actual) == (expected), message, p1, p2) #define AssertEqual_6(actual, expected, message, p1, p2, p3) Assert_5((actual) == (expected), message, p1, p2, p3) -#define AssertEqual_7(actual, expected, message, p1, p2, p3, p4) Assert_6((actual) == (expected), message, p1, p2, p3, p4) +#define AssertEqual_7(actual, expected, message, p1, p2, p3, p4) \ + Assert_6((actual) == (expected), message, p1, p2, p3, p4) // AssertNotEqual() #define AssertNotEqual_0() AssertFail_1("No condition provided for AssertNotEqual()") #define AssertNotEqual_1(condition) AssertFail_1("AssertNotEqual() requires at least two parameters.") -#define AssertNotEqual_2(actual, expected) Assert_4((actual) != (expected), "AssertNotEqual(%s, %s) - Provided arguments are equal", #actual, #expected) +#define AssertNotEqual_2(actual, expected) \ + Assert_4((actual) != (expected), "AssertNotEqual(%s, %s) - Provided arguments are equal", #actual, #expected) #define AssertNotEqual_3(actual, expected, message) Assert_2((actual) != (expected), message) #define AssertNotEqual_4(actual, expected, message, p1) Assert_3((actual) != (expected), message, p1) #define AssertNotEqual_5(actual, expected, message, p1, p2) Assert_4((actual) != (expected), message, p1, p2) #define AssertNotEqual_6(actual, expected, message, p1, p2, p3) Assert_5((actual) != (expected), message, p1, p2, p3) -#define AssertNotEqual_7(actual, expected, message, p1, p2, p3, p4) Assert_6((actual) != (expected), message, p1, p2, p3, p4) +#define AssertNotEqual_7(actual, expected, message, p1, p2, p3, p4) \ + Assert_6((actual) != (expected), message, p1, p2, p3, p4) // AssertNot() #define AssertNot_0() AssertFail_1("No condition provided for AssertNot()") @@ -660,13 +669,15 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #define AssertFail_7(message, p1, p2, p3, p4, p5, p6) #else #define AssertFail_0() RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: AssertFail() (%s:%i)", __FILE__, __LINE__) -#define AssertFail_1(message) RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: %s (%s:%i)", message, __FILE__, __LINE__) +#define AssertFail_1(message) \ + RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: %s (%s:%i)", message, __FILE__, __LINE__) #define AssertFail_2(message, p1) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1)) #define AssertFail_3(message, p1, p2) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) #define AssertFail_4(message, p1, p2, p3) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) #define AssertFail_5(message, p1, p2, p3, p4) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) #define AssertFail_6(message, p1, p2, p3, p4, p5) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5)) -#define AssertFail_7(message, p1, p2, p3, p4, p5, p6) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5, p6)) +#define AssertFail_7(message, p1, p2, p3, p4, p5, p6) \ + AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5, p6)) #endif // AssertImage() @@ -683,11 +694,23 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #define AssertImageSize_0() AssertFail_1("No image provided for AssertImageSize()") #define AssertImageSize_1(image) AssertFail_1("Expected image, width, and height for AssertImageSize()") #define AssertImageSize_2(image, expectedWidth) AssertFail_1("Expected image, width, and height for AssertImageSize()") -#define AssertImageSize_3(image, expectedWidth, expectedHeight) AssertImageSize_7(image, expectedWidth, expectedHeight, "AssertImageSize(%s, %s, %s) - Image size does not match", #image, #expectedWidth, #expectedHeight) -#define AssertImageSize_4(image, expectedWidth, expectedHeight, message) Assert_2((image).width == (expectedWidth) && (image).height == (expectedHeight), message) -#define AssertImageSize_5(image, expectedWidth, expectedHeight, message, p1) Assert_3((image).width == (expectedWidth) && (image).height == (expectedHeight), message, p1) -#define AssertImageSize_6(image, expectedWidth, expectedHeight, message, p1, p2) Assert_4((image).width == (expectedWidth) && (image).height == (expectedHeight), message, p1, p2) -#define AssertImageSize_7(image, expectedWidth, expectedHeight, message, p1, p2, p3) Assert_5((image).width == (expectedWidth) && (image).height == (expectedHeight), message, p1, p2, p3) +#define AssertImageSize_3(image, expectedWidth, expectedHeight) \ + AssertImageSize_7( \ + image, \ + expectedWidth, \ + expectedHeight, \ + "AssertImageSize(%s, %s, %s) - Image size does not match", \ + #image, \ + #expectedWidth, \ + #expectedHeight) +#define AssertImageSize_4(image, expectedWidth, expectedHeight, message) \ + Assert_2((image).width == (expectedWidth) && (image).height == (expectedHeight), message) +#define AssertImageSize_5(image, expectedWidth, expectedHeight, message, p1) \ + Assert_3((image).width == (expectedWidth) && (image).height == (expectedHeight), message, p1) +#define AssertImageSize_6(image, expectedWidth, expectedHeight, message, p1, p2) \ + Assert_4((image).width == (expectedWidth) && (image).height == (expectedHeight), message, p1, p2) +#define AssertImageSize_7(image, expectedWidth, expectedHeight, message, p1, p2, p3) \ + Assert_5((image).width == (expectedWidth) && (image).height == (expectedHeight), message, p1, p2, p3) // AssertTexture() #define AssertTexture_0() AssertFail_1("No texture provided for AssertTexture()") @@ -697,7 +720,8 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #define AssertTexture_4(texture, message, p1, p2) Assert_4(IsTextureValid(texture), message, p1, p2) #define AssertTexture_5(texture, message, p1, p2, p3) Assert_5(IsTextureValid(texture), message, p1, p2, p3) #define AssertTexture_6(texture, message, p1, p2, p3, p4) Assert_6(IsTextureValid(texture), message, p1, p2, p3, p4) -#define AssertTexture_7(texture, message, p1, p2, p3, p4, p5) Assert_7(IsTextureValid(texture), message, p1, p2, p3, p4, p5) +#define AssertTexture_7(texture, message, p1, p2, p3, p4, p5) \ + Assert_7(IsTextureValid(texture), message, p1, p2, p3, p4, p5) // AssertMesh() #define AssertMesh_0() AssertFail_1("No mesh provided for AssertMesh()") @@ -707,17 +731,20 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #define AssertMesh_4(mesh, message, p1, p2) Assert_4(RAYLIB_ASSERT_MESH_VALID(mesh), message, p1, p2) #define AssertMesh_5(mesh, message, p1, p2, p3) Assert_5(RAYLIB_ASSERT_MESH_VALID(mesh), message, p1, p2, p3) #define AssertMesh_6(mesh, message, p1, p2, p3, p4) Assert_6(RAYLIB_ASSERT_MESH_VALID(mesh), message, p1, p2, p3, p4) -#define AssertMesh_7(mesh, message, p1, p2, p3, p4, p5) Assert_7(RAYLIB_ASSERT_MESH_VALID(mesh), message, p1, p2, p3, p4, p5) +#define AssertMesh_7(mesh, message, p1, p2, p3, p4, p5) \ + Assert_7(RAYLIB_ASSERT_MESH_VALID(mesh), message, p1, p2, p3, p4, p5) // AssertMaterial() #define AssertMaterial_0() AssertFail_1("No material provided for AssertMaterial()") -#define AssertMaterial_1(material) Assert_3(IsMaterialValid(material), "AssertMaterial(%s) - Material not loaded", #material) +#define AssertMaterial_1(material) \ + Assert_3(IsMaterialValid(material), "AssertMaterial(%s) - Material not loaded", #material) #define AssertMaterial_2(material, message) Assert_2(IsMaterialValid(material), message) #define AssertMaterial_3(material, message, p1) Assert_3(IsMaterialValid(material), message, p1) #define AssertMaterial_4(material, message, p1, p2) Assert_4(IsMaterialValid(material), message, p1, p2) #define AssertMaterial_5(material, message, p1, p2, p3) Assert_5(IsMaterialValid(material), message, p1, p2, p3) #define AssertMaterial_6(material, message, p1, p2, p3, p4) Assert_6(IsMaterialValid(material), message, p1, p2, p3, p4) -#define AssertMaterial_7(material, message, p1, p2, p3, p4, p5) Assert_7(IsMaterialValid(material), message, p1, p2, p3, p4, p5) +#define AssertMaterial_7(material, message, p1, p2, p3, p4, p5) \ + Assert_7(IsMaterialValid(material), message, p1, p2, p3, p4, p5) // AssertImageSame() #ifdef RAYLIB_ASSERT_NDEBUG @@ -732,35 +759,44 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #else #define AssertImageSame_0() AssertFail_1("AssertImageSame(): No images provided to AssertImageSame(), expected 2") #define AssertImageSame_1(image) AssertFail_1("Only one image provided for AssertImageSame()") -#define AssertImageSame_2(image1, image2) AssertImageSame_5(image1, image2, "AssertImageSame(%s, %s) - Images do not match", #image1, #image2) -#define AssertImageSame_3(image1, image2, message) do { \ - Image raylibAssertImage1 = (image1); \ - Image raylibAssertImage2 = (image2); \ - if (raylibAssertImage1.width != raylibAssertImage2.width || raylibAssertImage1.height != raylibAssertImage2.height || raylibAssertImage1.format != raylibAssertImage2.format) { \ - AssertFail_1(message); \ - break; \ - } \ - Color* colors1 = LoadImageColors(raylibAssertImage1); \ - Color* colors2 = LoadImageColors(raylibAssertImage2); \ - bool failure = false; \ - for (int i = 0; i < raylibAssertImage1.width * raylibAssertImage1.height; i++) { \ - Color color1 = colors1[i]; \ - Color color2 = colors2[i]; \ - if (color1.r != color2.r || color1.g != color2.g || color1.b != color2.b || color1.a != color2.a) { \ - failure = true; \ - break; \ - } \ - } \ - UnloadImageColors(colors1); \ - UnloadImageColors(colors2); \ - if (failure) { \ - AssertFail_1(message); \ - } \ -} while(0) -#define AssertImageSame_4(image1, image2, message, p1) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) -#define AssertImageSame_5(image1, image2, message, p1, p2) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) -#define AssertImageSame_6(image1, image2, message, p1, p2, p3) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) -#define AssertImageSame_7(image1, image2, message, p1, p2, p3, p4) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) +#define AssertImageSame_2(image1, image2) \ + AssertImageSame_5(image1, image2, "AssertImageSame(%s, %s) - Images do not match", #image1, #image2) +#define AssertImageSame_3(image1, image2, message) \ + do { \ + Image raylibAssertImage1 = (image1); \ + Image raylibAssertImage2 = (image2); \ + if (raylibAssertImage1.width != raylibAssertImage2.width || \ + raylibAssertImage1.height != raylibAssertImage2.height || \ + raylibAssertImage1.format != raylibAssertImage2.format) { \ + AssertFail_1(message); \ + break; \ + } \ + Color* colors1 = LoadImageColors(raylibAssertImage1); \ + Color* colors2 = LoadImageColors(raylibAssertImage2); \ + bool failure = false; \ + for (int i = 0; i < raylibAssertImage1.width * raylibAssertImage1.height; i++) { \ + Color color1 = colors1[i]; \ + Color color2 = colors2[i]; \ + if (color1.r != color2.r || color1.g != color2.g || color1.b != color2.b || color1.a != color2.a) { \ + failure = true; \ + break; \ + } \ + } \ + UnloadImageColors(colors1); \ + UnloadImageColors(colors2); \ + if (failure) { \ + AssertFail_1(message); \ + } \ + } \ + while (0) +#define AssertImageSame_4(image1, image2, message, p1) \ + AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) +#define AssertImageSame_5(image1, image2, message, p1, p2) \ + AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) +#define AssertImageSame_6(image1, image2, message, p1, p2, p3) \ + AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) +#define AssertImageSame_7(image1, image2, message, p1, p2, p3, p4) \ + AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) #endif // AssertColorSame() @@ -776,18 +812,26 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #else #define AssertColorSame_0() AssertFail_1("Colors not provided to AssertColorSame()") #define AssertColorSame_1(color) AssertFail_1("Expected two colors for AssertColorSame()") -#define AssertColorSame_2(color1, color2) AssertColorSame_5(color1, color2, "AssertColorSame(%s, %s) - Colors do not match", #color1, #color2) -#define AssertColorSame_3(color1, color2, message) do { \ - Color raylibAssertColor1 = (color1); \ - Color raylibAssertColor2 = (color2); \ - if (raylibAssertColor1.r != raylibAssertColor2.r || raylibAssertColor1.g != raylibAssertColor2.g || raylibAssertColor1.b != raylibAssertColor2.b || raylibAssertColor1.a != raylibAssertColor2.a) { \ - AssertFail_1(message); \ - }\ -} while (0) -#define AssertColorSame_4(color1, color2, message, p1) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) -#define AssertColorSame_5(color1, color2, message, p1, p2) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) -#define AssertColorSame_6(color1, color2, message, p1, p2, p3) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) -#define AssertColorSame_7(color1, color2, message, p1, p2, p3, p4) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) +#define AssertColorSame_2(color1, color2) \ + AssertColorSame_5(color1, color2, "AssertColorSame(%s, %s) - Colors do not match", #color1, #color2) +#define AssertColorSame_3(color1, color2, message) \ + do { \ + Color raylibAssertColor1 = (color1); \ + Color raylibAssertColor2 = (color2); \ + if (raylibAssertColor1.r != raylibAssertColor2.r || raylibAssertColor1.g != raylibAssertColor2.g || \ + raylibAssertColor1.b != raylibAssertColor2.b || raylibAssertColor1.a != raylibAssertColor2.a) { \ + AssertFail_1(message); \ + } \ + } \ + while (0) +#define AssertColorSame_4(color1, color2, message, p1) \ + AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) +#define AssertColorSame_5(color1, color2, message, p1, p2) \ + AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) +#define AssertColorSame_6(color1, color2, message, p1, p2, p3) \ + AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) +#define AssertColorSame_7(color1, color2, message, p1, p2, p3, p4) \ + AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) #endif // AssertColorApprox() @@ -804,18 +848,34 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #define AssertColorApprox_0() AssertFail_1("Colors not provided to AssertColorApprox()") #define AssertColorApprox_1(color) AssertFail_1("Expected two colors and a tolerance for AssertColorApprox()") #define AssertColorApprox_2(color1, color2) AssertFail_1("Expected two colors and a tolerance for AssertColorApprox()") -#define AssertColorApprox_3(color1, color2, tolerance) AssertColorApprox_7(color1, color2, tolerance, "AssertColorApprox(%s, %s, %s) - Colors differ beyond tolerance", #color1, #color2, #tolerance) -#define AssertColorApprox_4(color1, color2, tolerance, message) do { \ - Color raylibAssertColor1 = (color1); \ - Color raylibAssertColor2 = (color2); \ - int raylibAssertTolerance = (int)(tolerance); \ - if (!RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.r, raylibAssertColor2.r, raylibAssertTolerance) || !RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.g, raylibAssertColor2.g, raylibAssertTolerance) || !RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.b, raylibAssertColor2.b, raylibAssertTolerance) || !RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.a, raylibAssertColor2.a, raylibAssertTolerance)) { \ - AssertFail_1(message); \ - }\ -} while (0) -#define AssertColorApprox_5(color1, color2, tolerance, message, p1) AssertColorApprox_4(color1, color2, tolerance, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) -#define AssertColorApprox_6(color1, color2, tolerance, message, p1, p2) AssertColorApprox_4(color1, color2, tolerance, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) -#define AssertColorApprox_7(color1, color2, tolerance, message, p1, p2, p3) AssertColorApprox_4(color1, color2, tolerance, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) +#define AssertColorApprox_3(color1, color2, tolerance) \ + AssertColorApprox_7( \ + color1, \ + color2, \ + tolerance, \ + "AssertColorApprox(%s, %s, %s) - Colors differ beyond tolerance", \ + #color1, \ + #color2, \ + #tolerance) +#define AssertColorApprox_4(color1, color2, tolerance, message) \ + do { \ + Color raylibAssertColor1 = (color1); \ + Color raylibAssertColor2 = (color2); \ + int raylibAssertTolerance = (int)(tolerance); \ + if (!RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.r, raylibAssertColor2.r, raylibAssertTolerance) || \ + !RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.g, raylibAssertColor2.g, raylibAssertTolerance) || \ + !RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.b, raylibAssertColor2.b, raylibAssertTolerance) || \ + !RAYLIB_ASSERT_CHANNEL_WITHIN(raylibAssertColor1.a, raylibAssertColor2.a, raylibAssertTolerance)) { \ + AssertFail_1(message); \ + } \ + } \ + while (0) +#define AssertColorApprox_5(color1, color2, tolerance, message, p1) \ + AssertColorApprox_4(color1, color2, tolerance, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) +#define AssertColorApprox_6(color1, color2, tolerance, message, p1, p2) \ + AssertColorApprox_4(color1, color2, tolerance, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) +#define AssertColorApprox_7(color1, color2, tolerance, message, p1, p2, p3) \ + AssertColorApprox_4(color1, color2, tolerance, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) #endif // AssertVector2Same() @@ -831,18 +891,26 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #else #define AssertVector2Same_0() AssertFail_1("Vectors not provided to AssertVector2Same()") #define AssertVector2Same_1(vector) AssertFail_1("Expected two vectors for AssertVector2Same()") -#define AssertVector2Same_2(vector1, vector2) AssertVector2Same_5(vector1, vector2, "AssertVector2Same(%s, %s) - vectors do not match", #vector1, #vector2) -#define AssertVector2Same_3(vector1, vector2, message) do { \ - Vector2 raylibAssertVector1 = (vector1); \ - Vector2 raylibAssertVector2 = (vector2); \ - if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.x, raylibAssertVector2.x) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.y, raylibAssertVector2.y)) { \ - AssertFail_1(message); \ - }\ -} while (0) -#define AssertVector2Same_4(vector1, vector2, message, p1) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) -#define AssertVector2Same_5(vector1, vector2, message, p1, p2) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) -#define AssertVector2Same_6(vector1, vector2, message, p1, p2, p3) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) -#define AssertVector2Same_7(vector1, vector2, message, p1, p2, p3, p4) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) +#define AssertVector2Same_2(vector1, vector2) \ + AssertVector2Same_5(vector1, vector2, "AssertVector2Same(%s, %s) - vectors do not match", #vector1, #vector2) +#define AssertVector2Same_3(vector1, vector2, message) \ + do { \ + Vector2 raylibAssertVector1 = (vector1); \ + Vector2 raylibAssertVector2 = (vector2); \ + if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.x, raylibAssertVector2.x) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.y, raylibAssertVector2.y)) { \ + AssertFail_1(message); \ + } \ + } \ + while (0) +#define AssertVector2Same_4(vector1, vector2, message, p1) \ + AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) +#define AssertVector2Same_5(vector1, vector2, message, p1, p2) \ + AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) +#define AssertVector2Same_6(vector1, vector2, message, p1, p2, p3) \ + AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) +#define AssertVector2Same_7(vector1, vector2, message, p1, p2, p3, p4) \ + AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) #endif // AssertVector3Same() @@ -858,18 +926,27 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #else #define AssertVector3Same_0() AssertFail_1("Vectors not provided to AssertVector3Same()") #define AssertVector3Same_1(vector) AssertFail_1("Expected two vectors for AssertVector3Same()") -#define AssertVector3Same_2(vector1, vector2) AssertVector3Same_5(vector1, vector2, "AssertVector3Same(%s, %s) - vectors do not match", #vector1, #vector2) -#define AssertVector3Same_3(vector1, vector2, message) do { \ - Vector3 raylibAssertVector1 = (vector1); \ - Vector3 raylibAssertVector2 = (vector2); \ - if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.x, raylibAssertVector2.x) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.y, raylibAssertVector2.y) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.z, raylibAssertVector2.z)) { \ - AssertFail_1(message); \ - }\ -} while (0) -#define AssertVector3Same_4(vector1, vector2, message, p1) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) -#define AssertVector3Same_5(vector1, vector2, message, p1, p2) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) -#define AssertVector3Same_6(vector1, vector2, message, p1, p2, p3) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) -#define AssertVector3Same_7(vector1, vector2, message, p1, p2, p3, p4) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) +#define AssertVector3Same_2(vector1, vector2) \ + AssertVector3Same_5(vector1, vector2, "AssertVector3Same(%s, %s) - vectors do not match", #vector1, #vector2) +#define AssertVector3Same_3(vector1, vector2, message) \ + do { \ + Vector3 raylibAssertVector1 = (vector1); \ + Vector3 raylibAssertVector2 = (vector2); \ + if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.x, raylibAssertVector2.x) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.y, raylibAssertVector2.y) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.z, raylibAssertVector2.z)) { \ + AssertFail_1(message); \ + } \ + } \ + while (0) +#define AssertVector3Same_4(vector1, vector2, message, p1) \ + AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) +#define AssertVector3Same_5(vector1, vector2, message, p1, p2) \ + AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) +#define AssertVector3Same_6(vector1, vector2, message, p1, p2, p3) \ + AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) +#define AssertVector3Same_7(vector1, vector2, message, p1, p2, p3, p4) \ + AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) #endif // AssertVector4Same() @@ -885,18 +962,28 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #else #define AssertVector4Same_0() AssertFail_1("Vectors not provided to AssertVector4Same()") #define AssertVector4Same_1(vector) AssertFail_1("Expected two vectors for AssertVector4Same()") -#define AssertVector4Same_2(vector1, vector2) AssertVector4Same_5(vector1, vector2, "AssertVector4Same(%s, %s) - vectors do not match", #vector1, #vector2) -#define AssertVector4Same_3(vector1, vector2, message) do { \ - Vector4 raylibAssertVector1 = (vector1); \ - Vector4 raylibAssertVector2 = (vector2); \ - if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.x, raylibAssertVector2.x) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.y, raylibAssertVector2.y) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.z, raylibAssertVector2.z) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.w, raylibAssertVector2.w)) { \ - AssertFail_1(message); \ - }\ -} while (0) -#define AssertVector4Same_4(vector1, vector2, message, p1) AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) -#define AssertVector4Same_5(vector1, vector2, message, p1, p2) AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) -#define AssertVector4Same_6(vector1, vector2, message, p1, p2, p3) AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) -#define AssertVector4Same_7(vector1, vector2, message, p1, p2, p3, p4) AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) +#define AssertVector4Same_2(vector1, vector2) \ + AssertVector4Same_5(vector1, vector2, "AssertVector4Same(%s, %s) - vectors do not match", #vector1, #vector2) +#define AssertVector4Same_3(vector1, vector2, message) \ + do { \ + Vector4 raylibAssertVector1 = (vector1); \ + Vector4 raylibAssertVector2 = (vector2); \ + if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.x, raylibAssertVector2.x) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.y, raylibAssertVector2.y) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.z, raylibAssertVector2.z) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertVector1.w, raylibAssertVector2.w)) { \ + AssertFail_1(message); \ + } \ + } \ + while (0) +#define AssertVector4Same_4(vector1, vector2, message, p1) \ + AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) +#define AssertVector4Same_5(vector1, vector2, message, p1, p2) \ + AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) +#define AssertVector4Same_6(vector1, vector2, message, p1, p2, p3) \ + AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) +#define AssertVector4Same_7(vector1, vector2, message, p1, p2, p3, p4) \ + AssertVector4Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) #endif // AssertRectangleSame() @@ -912,18 +999,28 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) #else #define AssertRectangleSame_0() AssertFail_1("Rectangles not provided to AssertRectangleSame()") #define AssertRectangleSame_1(rect) AssertFail_1("Expected two rectangles for AssertRectangleSame()") -#define AssertRectangleSame_2(rect1, rect2) AssertRectangleSame_5(rect1, rect2, "AssertRectangleSame(%s, %s) - rectangles do not match", #rect1, #rect2) -#define AssertRectangleSame_3(rect1, rect2, message) do { \ - Rectangle raylibAssertRect1 = (rect1); \ - Rectangle raylibAssertRect2 = (rect2); \ - if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.x, raylibAssertRect2.x) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.y, raylibAssertRect2.y) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.width, raylibAssertRect2.width) || !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.height, raylibAssertRect2.height)) { \ - AssertFail_1(message); \ - }\ -} while (0) -#define AssertRectangleSame_4(rect1, rect2, message, p1) AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) -#define AssertRectangleSame_5(rect1, rect2, message, p1, p2) AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) -#define AssertRectangleSame_6(rect1, rect2, message, p1, p2, p3) AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) -#define AssertRectangleSame_7(rect1, rect2, message, p1, p2, p3, p4) AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) +#define AssertRectangleSame_2(rect1, rect2) \ + AssertRectangleSame_5(rect1, rect2, "AssertRectangleSame(%s, %s) - rectangles do not match", #rect1, #rect2) +#define AssertRectangleSame_3(rect1, rect2, message) \ + do { \ + Rectangle raylibAssertRect1 = (rect1); \ + Rectangle raylibAssertRect2 = (rect2); \ + if (!RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.x, raylibAssertRect2.x) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.y, raylibAssertRect2.y) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.width, raylibAssertRect2.width) || \ + !RAYLIB_ASSERT_FLOAT_EQ(raylibAssertRect1.height, raylibAssertRect2.height)) { \ + AssertFail_1(message); \ + } \ + } \ + while (0) +#define AssertRectangleSame_4(rect1, rect2, message, p1) \ + AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1)) +#define AssertRectangleSame_5(rect1, rect2, message, p1, p2) \ + AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2)) +#define AssertRectangleSame_6(rect1, rect2, message, p1, p2, p3) \ + AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3)) +#define AssertRectangleSame_7(rect1, rect2, message, p1, p2, p3, p4) \ + AssertRectangleSame_3(rect1, rect2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4)) #endif // AssertNull() @@ -949,27 +1046,32 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) // AssertStringEqual() #define AssertStringEqual_0() AssertFail_1("No strings provided for AssertStringEqual()") #define AssertStringEqual_1(str) AssertFail_1("Expected two strings for AssertStringEqual()") -#define AssertStringEqual_2(str1, str2) Assert_4(TextIsEqual(str1, str2), "AssertStringEqual(%s, %s) - Strings are not equal", #str1, #str2) +#define AssertStringEqual_2(str1, str2) \ + Assert_4(TextIsEqual(str1, str2), "AssertStringEqual(%s, %s) - Strings are not equal", #str1, #str2) #define AssertStringEqual_3(str1, str2, message) Assert_2(TextIsEqual(str1, str2), message) #define AssertStringEqual_4(str1, str2, message, p1) Assert_3(TextIsEqual(str1, str2), message, p1) #define AssertStringEqual_5(str1, str2, message, p1, p2) Assert_4(TextIsEqual(str1, str2), message, p1, p2) #define AssertStringEqual_6(str1, str2, message, p1, p2, p3) Assert_5(TextIsEqual(str1, str2), message, p1, p2, p3) -#define AssertStringEqual_7(str1, str2, message, p1, p2, p3, p4) Assert_6(TextIsEqual(str1, str2), message, p1, p2, p3, p4) +#define AssertStringEqual_7(str1, str2, message, p1, p2, p3, p4) \ + Assert_6(TextIsEqual(str1, str2), message, p1, p2, p3, p4) // AssertGreater() #define AssertGreater_0() AssertFail_1("No values provided for AssertGreater()") #define AssertGreater_1(value) AssertFail_1("Expected two values for AssertGreater()") -#define AssertGreater_2(actual, expected) Assert_4((actual) > (expected), "AssertGreater(%s, %s) - Value is not greater than expected", #actual, #expected) +#define AssertGreater_2(actual, expected) \ + Assert_4((actual) > (expected), "AssertGreater(%s, %s) - Value is not greater than expected", #actual, #expected) #define AssertGreater_3(actual, expected, message) Assert_2((actual) > (expected), message) #define AssertGreater_4(actual, expected, message, p1) Assert_3((actual) > (expected), message, p1) #define AssertGreater_5(actual, expected, message, p1, p2) Assert_4((actual) > (expected), message, p1, p2) #define AssertGreater_6(actual, expected, message, p1, p2, p3) Assert_5((actual) > (expected), message, p1, p2, p3) -#define AssertGreater_7(actual, expected, message, p1, p2, p3, p4) Assert_6((actual) > (expected), message, p1, p2, p3, p4) +#define AssertGreater_7(actual, expected, message, p1, p2, p3, p4) \ + Assert_6((actual) > (expected), message, p1, p2, p3, p4) // AssertLess() #define AssertLess_0() AssertFail_1("No values provided for AssertLess()") #define AssertLess_1(value) AssertFail_1("Expected two values for AssertLess()") -#define AssertLess_2(actual, expected) Assert_4((actual) < (expected), "AssertLess(%s, %s) - Value is not less than expected", #actual, #expected) +#define AssertLess_2(actual, expected) \ + Assert_4((actual) < (expected), "AssertLess(%s, %s) - Value is not less than expected", #actual, #expected) #define AssertLess_3(actual, expected, message) Assert_2((actual) < (expected), message) #define AssertLess_4(actual, expected, message, p1) Assert_3((actual) < (expected), message, p1) #define AssertLess_5(actual, expected, message, p1, p2) Assert_4((actual) < (expected), message, p1, p2) @@ -979,62 +1081,97 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) // AssertGreaterEqual() #define AssertGreaterEqual_0() AssertFail_1("No values provided for AssertGreaterEqual()") #define AssertGreaterEqual_1(value) AssertFail_1("Expected two values for AssertGreaterEqual()") -#define AssertGreaterEqual_2(actual, expected) Assert_4((actual) >= (expected), "AssertGreaterEqual(%s, %s) - Value is not greater than or equal to expected", #actual, #expected) +#define AssertGreaterEqual_2(actual, expected) \ + Assert_4( \ + (actual) >= (expected), \ + "AssertGreaterEqual(%s, %s) - Value is not greater than or equal to expected", \ + #actual, \ + #expected) #define AssertGreaterEqual_3(actual, expected, message) Assert_2((actual) >= (expected), message) #define AssertGreaterEqual_4(actual, expected, message, p1) Assert_3((actual) >= (expected), message, p1) #define AssertGreaterEqual_5(actual, expected, message, p1, p2) Assert_4((actual) >= (expected), message, p1, p2) -#define AssertGreaterEqual_6(actual, expected, message, p1, p2, p3) Assert_5((actual) >= (expected), message, p1, p2, p3) -#define AssertGreaterEqual_7(actual, expected, message, p1, p2, p3, p4) Assert_6((actual) >= (expected), message, p1, p2, p3, p4) +#define AssertGreaterEqual_6(actual, expected, message, p1, p2, p3) \ + Assert_5((actual) >= (expected), message, p1, p2, p3) +#define AssertGreaterEqual_7(actual, expected, message, p1, p2, p3, p4) \ + Assert_6((actual) >= (expected), message, p1, p2, p3, p4) // AssertLessEqual() #define AssertLessEqual_0() AssertFail_1("No values provided for AssertLessEqual()") #define AssertLessEqual_1(value) AssertFail_1("Expected two values for AssertLessEqual()") -#define AssertLessEqual_2(actual, expected) Assert_4((actual) <= (expected), "AssertLessEqual(%s, %s) - Value is not less than or equal to expected", #actual, #expected) +#define AssertLessEqual_2(actual, expected) \ + Assert_4( \ + (actual) <= (expected), \ + "AssertLessEqual(%s, %s) - Value is not less than or equal to expected", \ + #actual, \ + #expected) #define AssertLessEqual_3(actual, expected, message) Assert_2((actual) <= (expected), message) #define AssertLessEqual_4(actual, expected, message, p1) Assert_3((actual) <= (expected), message, p1) #define AssertLessEqual_5(actual, expected, message, p1, p2) Assert_4((actual) <= (expected), message, p1, p2) #define AssertLessEqual_6(actual, expected, message, p1, p2, p3) Assert_5((actual) <= (expected), message, p1, p2, p3) -#define AssertLessEqual_7(actual, expected, message, p1, p2, p3, p4) Assert_6((actual) <= (expected), message, p1, p2, p3, p4) +#define AssertLessEqual_7(actual, expected, message, p1, p2, p3, p4) \ + Assert_6((actual) <= (expected), message, p1, p2, p3, p4) // AssertFloatEqual() #define AssertFloatEqual_0() AssertFail_1("No values provided for AssertFloatEqual()") #define AssertFloatEqual_1(value) AssertFail_1("Expected two values for AssertFloatEqual()") -#define AssertFloatEqual_2(actual, expected) Assert_4(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), "AssertFloatEqual(%s, %s) - Floats are not equal within epsilon", #actual, #expected) +#define AssertFloatEqual_2(actual, expected) \ + Assert_4( \ + RAYLIB_ASSERT_FLOAT_EQ(actual, expected), \ + "AssertFloatEqual(%s, %s) - Floats are not equal within epsilon", \ + #actual, \ + #expected) #define AssertFloatEqual_3(actual, expected, message) Assert_2(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message) -#define AssertFloatEqual_4(actual, expected, message, p1) Assert_3(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1) -#define AssertFloatEqual_5(actual, expected, message, p1, p2) Assert_4(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1, p2) -#define AssertFloatEqual_6(actual, expected, message, p1, p2, p3) Assert_5(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1, p2, p3) -#define AssertFloatEqual_7(actual, expected, message, p1, p2, p3, p4) Assert_6(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1, p2, p3, p4) +#define AssertFloatEqual_4(actual, expected, message, p1) \ + Assert_3(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1) +#define AssertFloatEqual_5(actual, expected, message, p1, p2) \ + Assert_4(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1, p2) +#define AssertFloatEqual_6(actual, expected, message, p1, p2, p3) \ + Assert_5(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1, p2, p3) +#define AssertFloatEqual_7(actual, expected, message, p1, p2, p3, p4) \ + Assert_6(RAYLIB_ASSERT_FLOAT_EQ(actual, expected), message, p1, p2, p3, p4) // AssertInRange() #define AssertInRange_0() AssertFail_1("No values provided for AssertInRange()") #define AssertInRange_1(value) AssertFail_1("Expected three values for AssertInRange()") #define AssertInRange_2(value, min) AssertFail_1("Expected three values for AssertInRange()") -#define AssertInRange_3(value, min, max) Assert_5((value) >= (min) && (value) <= (max), "AssertInRange(%s, %s, %s) - Value is not within range", #value, #min, #max) +#define AssertInRange_3(value, min, max) \ + Assert_5( \ + (value) >= (min) && (value) <= (max), \ + "AssertInRange(%s, %s, %s) - Value is not within range", \ + #value, \ + #min, \ + #max) #define AssertInRange_4(value, min, max, message) Assert_2((value) >= (min) && (value) <= (max), message) #define AssertInRange_5(value, min, max, message, p1) Assert_3((value) >= (min) && (value) <= (max), message, p1) -#define AssertInRange_6(value, min, max, message, p1, p2) Assert_4((value) >= (min) && (value) <= (max), message, p1, p2) -#define AssertInRange_7(value, min, max, message, p1, p2, p3) Assert_5((value) >= (min) && (value) <= (max), message, p1, p2, p3) +#define AssertInRange_6(value, min, max, message, p1, p2) \ + Assert_4((value) >= (min) && (value) <= (max), message, p1, p2) +#define AssertInRange_7(value, min, max, message, p1, p2, p3) \ + Assert_5((value) >= (min) && (value) <= (max), message, p1, p2, p3) // AssertStringNotEqual() #define AssertStringNotEqual_0() AssertFail_1("No strings provided for AssertStringNotEqual()") #define AssertStringNotEqual_1(str) AssertFail_1("Expected two strings for AssertStringNotEqual()") -#define AssertStringNotEqual_2(str1, str2) Assert_4(!TextIsEqual(str1, str2), "AssertStringNotEqual(%s, %s) - Strings are equal", #str1, #str2) +#define AssertStringNotEqual_2(str1, str2) \ + Assert_4(!TextIsEqual(str1, str2), "AssertStringNotEqual(%s, %s) - Strings are equal", #str1, #str2) #define AssertStringNotEqual_3(str1, str2, message) Assert_2(!TextIsEqual(str1, str2), message) #define AssertStringNotEqual_4(str1, str2, message, p1) Assert_3(!TextIsEqual(str1, str2), message, p1) #define AssertStringNotEqual_5(str1, str2, message, p1, p2) Assert_4(!TextIsEqual(str1, str2), message, p1, p2) #define AssertStringNotEqual_6(str1, str2, message, p1, p2, p3) Assert_5(!TextIsEqual(str1, str2), message, p1, p2, p3) -#define AssertStringNotEqual_7(str1, str2, message, p1, p2, p3, p4) Assert_6(!TextIsEqual(str1, str2), message, p1, p2, p3, p4) +#define AssertStringNotEqual_7(str1, str2, message, p1, p2, p3, p4) \ + Assert_6(!TextIsEqual(str1, str2), message, p1, p2, p3, p4) // AssertRenderTexture() #define AssertRenderTexture_0() AssertFail_1("No render texture provided for AssertRenderTexture()") -#define AssertRenderTexture_1(target) Assert_3(IsRenderTextureValid(target), "AssertRenderTexture(%s) - Render texture not loaded", #target) +#define AssertRenderTexture_1(target) \ + Assert_3(IsRenderTextureValid(target), "AssertRenderTexture(%s) - Render texture not loaded", #target) #define AssertRenderTexture_2(target, message) Assert_2(IsRenderTextureValid(target), message) #define AssertRenderTexture_3(target, message, p1) Assert_3(IsRenderTextureValid(target), message, p1) #define AssertRenderTexture_4(target, message, p1, p2) Assert_4(IsRenderTextureValid(target), message, p1, p2) #define AssertRenderTexture_5(target, message, p1, p2, p3) Assert_5(IsRenderTextureValid(target), message, p1, p2, p3) -#define AssertRenderTexture_6(target, message, p1, p2, p3, p4) Assert_6(IsRenderTextureValid(target), message, p1, p2, p3, p4) -#define AssertRenderTexture_7(target, message, p1, p2, p3, p4, p5) Assert_7(IsRenderTextureValid(target), message, p1, p2, p3, p4, p5) +#define AssertRenderTexture_6(target, message, p1, p2, p3, p4) \ + Assert_6(IsRenderTextureValid(target), message, p1, p2, p3, p4) +#define AssertRenderTexture_7(target, message, p1, p2, p3, p4, p5) \ + Assert_7(IsRenderTextureValid(target), message, p1, p2, p3, p4, p5) // AssertFont() #define AssertFont_0() AssertFail_1("No font provided for AssertFont()") @@ -1069,12 +1206,21 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) // AssertModelAnimation() #define AssertModelAnimation_0() AssertFail_1("No model or animation provided for AssertModelAnimation()") #define AssertModelAnimation_1(model) AssertFail_1("Expected model and animation for AssertModelAnimation()") -#define AssertModelAnimation_2(model, animation) Assert_4(IsModelAnimationValid(model, animation), "AssertModelAnimation(%s, %s) - Animation is not valid for model", #model, #animation) +#define AssertModelAnimation_2(model, animation) \ + Assert_4( \ + IsModelAnimationValid(model, animation), \ + "AssertModelAnimation(%s, %s) - Animation is not valid for model", \ + #model, \ + #animation) #define AssertModelAnimation_3(model, animation, message) Assert_2(IsModelAnimationValid(model, animation), message) -#define AssertModelAnimation_4(model, animation, message, p1) Assert_3(IsModelAnimationValid(model, animation), message, p1) -#define AssertModelAnimation_5(model, animation, message, p1, p2) Assert_4(IsModelAnimationValid(model, animation), message, p1, p2) -#define AssertModelAnimation_6(model, animation, message, p1, p2, p3) Assert_5(IsModelAnimationValid(model, animation), message, p1, p2, p3) -#define AssertModelAnimation_7(model, animation, message, p1, p2, p3, p4) Assert_6(IsModelAnimationValid(model, animation), message, p1, p2, p3, p4) +#define AssertModelAnimation_4(model, animation, message, p1) \ + Assert_3(IsModelAnimationValid(model, animation), message, p1) +#define AssertModelAnimation_5(model, animation, message, p1, p2) \ + Assert_4(IsModelAnimationValid(model, animation), message, p1, p2) +#define AssertModelAnimation_6(model, animation, message, p1, p2, p3) \ + Assert_5(IsModelAnimationValid(model, animation), message, p1, p2, p3) +#define AssertModelAnimation_7(model, animation, message, p1, p2, p3, p4) \ + Assert_6(IsModelAnimationValid(model, animation), message, p1, p2, p3, p4) // AssertWave() #define AssertWave_0() AssertFail_1("No wave provided for AssertWave()") @@ -1108,13 +1254,16 @@ static inline bool RaylibAssertMeshValid(Mesh mesh) // AssertAudioStream() #define AssertAudioStream_0() AssertFail_1("No audio stream provided for AssertAudioStream()") -#define AssertAudioStream_1(stream) Assert_3(IsAudioStreamValid(stream), "AssertAudioStream(%s) - Audio stream not loaded", #stream) +#define AssertAudioStream_1(stream) \ + Assert_3(IsAudioStreamValid(stream), "AssertAudioStream(%s) - Audio stream not loaded", #stream) #define AssertAudioStream_2(stream, message) Assert_2(IsAudioStreamValid(stream), message) #define AssertAudioStream_3(stream, message, p1) Assert_3(IsAudioStreamValid(stream), message, p1) #define AssertAudioStream_4(stream, message, p1, p2) Assert_4(IsAudioStreamValid(stream), message, p1, p2) #define AssertAudioStream_5(stream, message, p1, p2, p3) Assert_5(IsAudioStreamValid(stream), message, p1, p2, p3) -#define AssertAudioStream_6(stream, message, p1, p2, p3, p4) Assert_6(IsAudioStreamValid(stream), message, p1, p2, p3, p4) -#define AssertAudioStream_7(stream, message, p1, p2, p3, p4, p5) Assert_7(IsAudioStreamValid(stream), message, p1, p2, p3, p4, p5) +#define AssertAudioStream_6(stream, message, p1, p2, p3, p4) \ + Assert_6(IsAudioStreamValid(stream), message, p1, p2, p3, p4) +#define AssertAudioStream_7(stream, message, p1, p2, p3, p4, p5) \ + Assert_7(IsAudioStreamValid(stream), message, p1, p2, p3, p4, p5) #ifdef __cplusplus } diff --git a/tests/raylib_cpp_test.cpp b/tests/raylib_cpp_test.cpp index 1dc65090..d2539e85 100644 --- a/tests/raylib_cpp_test.cpp +++ b/tests/raylib_cpp_test.cpp @@ -1,5 +1,7 @@ +// clang-format off #include "raylib-cpp.hpp" #include "raylib-assert.h" +// clang-format on #include #include @@ -84,7 +86,9 @@ int main(int argc, char* argv[]) { } // Keyboard - { AssertNot(raylib::Keyboard::IsKeyPressed(KEY_MINUS)); } + { + AssertNot(raylib::Keyboard::IsKeyPressed(KEY_MINUS)); + } // raylib::LoadDirectoryFiles() {