diff --git a/CHANGELOG.md b/CHANGELOG.md index ba0a9cf..11981f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v3.5.0-beta2] - Unreleased +## [v3.5.0-beta2] - 2021-01-18 ### Fixed - `Font.charsPadding` loading ### Removed diff --git a/LICENSE b/LICENSE index d2a515d..a663e98 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,13 @@ -Copyright (c) 2019-2020 Rob Loach (@RobLoach) +Copyright (c) 2019-2021 Rob Loach (@RobLoach) -This software is provided "as-is", without any express or implied warranty. In no event +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 +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 + 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 diff --git a/README.md b/README.md index 9817608..ec78216 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,12 @@ int main() { int screenWidth = 800; int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib-cpp - basic window"); + raylib::Window window(screenWidth, screenHeight, "raylib-cpp - basic window"); raylib::Texture logo("raylib_logo.png"); SetTargetFPS(60); - while (!w.ShouldClose()) + while (!window.ShouldClose()) { BeginDrawing(); @@ -28,7 +28,7 @@ int main() { // Object methods. logo.Draw( - screenWidth / 2 - logo.GetWidth() / 2, + screenWidth / 2 - logo.GetWidth() / 2, screenHeight / 2 - logo.GetHeight() / 2); EndDrawing(); @@ -154,7 +154,7 @@ ImageResize(&cat, 150, 200); // raylib-cpp raylib::Image cat("cat.png"); -cat.Crop((Rectangle){ 100, 10, 280, 380 }) +cat.Crop(100, 10, 280, 380) .FlipHorizontal() .Resize(150, 200); ``` diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 37fcab4..8816aa8 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,6 +11,7 @@ if (NOT raylib_FOUND) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib) endif() +# Find all examples foreach(example_dir ${example_dirs}) file(GLOB sources ${example_dir}/*.cpp) list(APPEND example_sources ${sources}) @@ -20,7 +21,7 @@ foreach(example_dir ${example_dirs}) list(APPEND example_resources ${resources}) endforeach() -# Do each example +# Compile all examples foreach(example_source ${example_sources}) # Create the basename for the example get_filename_component(example_name ${example_source} NAME) @@ -37,4 +38,5 @@ foreach(example_source ${example_sources}) endforeach() +# Copy all the resources file(COPY ${example_resources} DESTINATION "resources/") diff --git a/examples/audio/audio_music_stream.cpp b/examples/audio/audio_music_stream.cpp index ad57e1d..fb1565d 100644 --- a/examples/audio/audio_music_stream.cpp +++ b/examples/audio/audio_music_stream.cpp @@ -17,7 +17,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)"); + raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)"); raylib::AudioDevice audio; // Initialize audio device @@ -32,7 +32,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/audio/audio_sound_loading.cpp b/examples/audio/audio_sound_loading.cpp index 0872aa0..425f44a 100644 --- a/examples/audio/audio_sound_loading.cpp +++ b/examples/audio/audio_sound_loading.cpp @@ -17,7 +17,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing"); + raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing"); raylib::AudioDevice audiodevice; // Initialize audio device @@ -28,7 +28,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/core/core_3d_camera_first_person.cpp b/examples/core/core_3d_camera_first_person.cpp index 62f669b..36eb94d 100644 --- a/examples/core/core_3d_camera_first_person.cpp +++ b/examples/core/core_3d_camera_first_person.cpp @@ -19,7 +19,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); raylib::Color background(RAYWHITE); // Define the camera to look into our 3d world (position, target, up vector) @@ -48,7 +48,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/core/core_basic_window.cpp b/examples/core/core_basic_window.cpp index 25823cb..8925343 100644 --- a/examples/core/core_basic_window.cpp +++ b/examples/core/core_basic_window.cpp @@ -27,13 +27,13 @@ int main() { int screenWidth = 800; int screenHeight = 450; raylib::Color textColor(LIGHTGRAY); - raylib::Window w(screenWidth, screenHeight, "raylib [core] example - basic window"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - basic window"); SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/core/core_drop_files.cpp b/examples/core/core_drop_files.cpp index 824009c..7078f5c 100644 --- a/examples/core/core_drop_files.cpp +++ b/examples/core/core_drop_files.cpp @@ -19,7 +19,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [core] example - drop files"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - drop files"); std::vector droppedFiles; @@ -27,7 +27,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/core/core_input_mouse.cpp b/examples/core/core_input_mouse.cpp index eba7dd9..fed16c0 100644 --- a/examples/core/core_input_mouse.cpp +++ b/examples/core/core_input_mouse.cpp @@ -17,7 +17,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [core] example - mouse input"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - mouse input"); raylib::Vector2 ballPosition(-100.0f, -100.0f); raylib::Color background(RAYWHITE); @@ -28,7 +28,7 @@ int main() { //--------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/core/core_random_values.cpp b/examples/core/core_random_values.cpp index 9085405..7090afc 100644 --- a/examples/core/core_random_values.cpp +++ b/examples/core/core_random_values.cpp @@ -17,7 +17,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [core] example - generate random values"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - generate random values"); int framesCounter = 0; // Variable used to count frames @@ -27,7 +27,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/core/core_world_screen.cpp b/examples/core/core_world_screen.cpp index e647d3c..f87269c 100644 --- a/examples/core/core_world_screen.cpp +++ b/examples/core/core_world_screen.cpp @@ -17,7 +17,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); // Define the camera to look into our 3d world raylib::Camera camera( @@ -36,7 +36,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/models/models_billboard.cpp b/examples/models/models_billboard.cpp index 8744e42..8bf2053 100644 --- a/examples/models/models_billboard.cpp +++ b/examples/models/models_billboard.cpp @@ -17,7 +17,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); + raylib::Window window(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); // Define the camera to look into our 3d world raylib::Camera camera( @@ -37,7 +37,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/physics/physics_demo.cpp b/examples/physics/physics_demo.cpp index 5344235..39dbdb8 100644 --- a/examples/physics/physics_demo.cpp +++ b/examples/physics/physics_demo.cpp @@ -29,7 +29,7 @@ int main(void) const int screenHeight = 450; SetConfigFlags(FLAG_MSAA_4X_HINT); - raylib::Window w(screenWidth, screenHeight, "Physac [raylib-cpp] - Physics demo"); + raylib::Window window(screenWidth, screenHeight, "Physac [raylib-cpp] - Physics demo"); // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; @@ -51,7 +51,7 @@ int main(void) //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/shapes/shapes_collision_area.cpp b/examples/shapes/shapes_collision_area.cpp index 3af0ca1..8458f40 100644 --- a/examples/shapes/shapes_collision_area.cpp +++ b/examples/shapes/shapes_collision_area.cpp @@ -20,7 +20,7 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [shapes] example - collision area"); + raylib::Window window(screenWidth, screenHeight, "raylib [shapes] example - collision area"); // Box A: Moving box raylib::Rectangle boxA(10, GetScreenHeight()/2 - 50, 200, 100); @@ -41,7 +41,7 @@ int main(void) //---------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //----------------------------------------------------- diff --git a/examples/shapes/shapes_logo_raylib.cpp b/examples/shapes/shapes_logo_raylib.cpp index 9aa19cc..69305c9 100644 --- a/examples/shapes/shapes_logo_raylib.cpp +++ b/examples/shapes/shapes_logo_raylib.cpp @@ -17,7 +17,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes"); + raylib::Window window(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes"); raylib::Color foreground = raylib::Color(0, 68, 130); raylib::Color background = RAYWHITE; @@ -25,7 +25,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/text/text_font_loading.cpp b/examples/text/text_font_loading.cpp index 8b8dfb7..1cc959d 100644 --- a/examples/text/text_font_loading.cpp +++ b/examples/text/text_font_loading.cpp @@ -27,7 +27,7 @@ int main() { const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [text] example - font loading"); + raylib::Window window(screenWidth, screenHeight, "raylib [text] example - font loading"); // Define characters to draw // NOTE: raylib supports UTF-8 encoding, following list is actually codified as UTF8 internally @@ -44,11 +44,11 @@ int main() { bool useTtf = false; - w.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 (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -58,7 +58,7 @@ int main() { // Draw //---------------------------------------------------------------------------------- - w.BeginDrawing(); + window.BeginDrawing(); ClearBackground(RAYWHITE); diff --git a/examples/text/text_font_spritefont.cpp b/examples/text/text_font_spritefont.cpp index a2ea4b0..97a4d83 100644 --- a/examples/text/text_font_spritefont.cpp +++ b/examples/text/text_font_spritefont.cpp @@ -20,7 +20,7 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage"); + raylib::Window window(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage"); std::string msg1 = "THIS IS A custom SPRITE FONT..."; std::string msg2 = "...and this is ANOTHER CUSTOM font..."; @@ -44,7 +44,7 @@ int main(void) //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/text/text_raylib_fonts.cpp b/examples/text/text_raylib_fonts.cpp index fe400fd..9f53ae2 100644 --- a/examples/text/text_raylib_fonts.cpp +++ b/examples/text/text_raylib_fonts.cpp @@ -25,7 +25,7 @@ int main() { int screenWidth = 800; int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); + raylib::Window window(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); raylib::Color background(RAYWHITE); raylib::Color textColor(DARKGRAY); @@ -72,7 +72,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/textures/textures_bunnymark.cpp b/examples/textures/textures_bunnymark.cpp index 5555870..1a1781a 100644 --- a/examples/textures/textures_bunnymark.cpp +++ b/examples/textures/textures_bunnymark.cpp @@ -53,7 +53,7 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [textures] example - bunnymark"); + raylib::Window window(screenWidth, screenHeight, "raylib [textures] example - bunnymark"); // Load bunny texture raylib::Texture2D texBunny("resources/wabbit_alpha.png"); @@ -64,7 +64,7 @@ int main(void) //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/textures/textures_image_drawing.cpp b/examples/textures/textures_image_drawing.cpp index 835b2e9..f760da5 100644 --- a/examples/textures/textures_image_drawing.cpp +++ b/examples/textures/textures_image_drawing.cpp @@ -20,7 +20,7 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [textures] example - image drawing"); + raylib::Window window(screenWidth, screenHeight, "raylib [textures] example - image drawing"); raylib::Color background(RAYWHITE); raylib::Color darkGray(DARKGRAY); @@ -51,7 +51,7 @@ int main(void) //--------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -60,7 +60,7 @@ int main(void) // Draw //---------------------------------------------------------------------------------- - w.BeginDrawing(); + BeginDrawing(); background.ClearBackground(); @@ -70,7 +70,7 @@ int main(void) 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); - w.EndDrawing(); + EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/textures/textures_image_loading.cpp b/examples/textures/textures_image_loading.cpp index f6bf8fe..f18dee8 100644 --- a/examples/textures/textures_image_loading.cpp +++ b/examples/textures/textures_image_loading.cpp @@ -19,13 +19,13 @@ int main() { int screenWidth = 800; int screenHeight = 450; - raylib::Window w(screenWidth, screenHeight, "raylib [textures] example - image loading"); + raylib::Window window(screenWidth, screenHeight, "raylib [textures] example - image loading"); raylib::Texture texture("resources/raylib_logo.png"); raylib::Color background(RAYWHITE); raylib::Color textColor(LIGHTGRAY); // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/include/Functions.hpp b/include/Functions.hpp index 39e7772..26439ee 100644 --- a/include/Functions.hpp +++ b/include/Functions.hpp @@ -205,19 +205,19 @@ inline void UpdateCamera(Camera& camera) { ::UpdateCamera(&camera); } -inline Image LoadImage(const std::string& fileName) { +inline ::Image LoadImage(const std::string& fileName) { return ::LoadImage(fileName.c_str()); } -inline Image LoadImageRaw(const std::string& fileName, int width, int height, int format, int headerSize) { +inline ::Image LoadImageRaw(const std::string& fileName, int width, int height, int format, int headerSize) { return ::LoadImageRaw(fileName.c_str(), width, height, format, headerSize); } -inline Image LoadImageAnim(const std::string& fileName, int *frames) { +inline ::Image LoadImageAnim(const std::string& fileName, int *frames) { return ::LoadImageAnim(fileName.c_str(), frames); } -inline Image LoadImageFromMemory(const std::string& fileType, const unsigned char *fileData, int dataSize) { +inline ::Image LoadImageFromMemory(const std::string& fileType, const unsigned char *fileData, int dataSize) { return ::LoadImageFromMemory(fileType.c_str(), fileData, dataSize); } diff --git a/include/Image.hpp b/include/Image.hpp index 3ff2edd..de1be90 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -273,7 +273,7 @@ class Image : public ::Image { } /** - * Crop an image to area defined by a vector + * Crop an image to a new given width and height based on a vector. */ inline Image& Crop(::Vector2 size) { return Crop(0, 0, static_cast(size.x), static_cast(size.y)); diff --git a/include/Matrix.hpp b/include/Matrix.hpp index 3a7c1dc..dde4398 100644 --- a/include/Matrix.hpp +++ b/include/Matrix.hpp @@ -166,10 +166,16 @@ class Matrix : public ::Matrix { } #ifndef RAYLIB_CPP_NO_MATH + /** + * Returns the trace of the matrix (sum of the values along the diagonal) + */ inline float Trace() const { return ::MatrixTrace(*this); } + /** + * Transposes provided matrix + */ inline Matrix Transpose() const { return ::MatrixTranspose(*this); } diff --git a/include/Mesh.hpp b/include/Mesh.hpp index 71aae55..e3fe058 100644 --- a/include/Mesh.hpp +++ b/include/Mesh.hpp @@ -169,10 +169,16 @@ class Mesh : public ::Mesh { } } + /** + * Compute mesh bounding box limits + */ inline raylib::BoundingBox BoundingBox() const { return ::MeshBoundingBox(*this); } + /** + * Compute mesh bounding box limits + */ operator raylib::BoundingBox() { return BoundingBox(); } diff --git a/package.json b/package.json index 37e71b3..8dcd6ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "raylib-cpp", - "version": "3.5.0-beta1", + "version": "3.5.0-beta2", "description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib", "homepage": "https://github.com/robloach/raylib-cpp", "bugs": { diff --git a/projects/CMake/main.cpp b/projects/CMake/main.cpp index dc640fd..62931df 100644 --- a/projects/CMake/main.cpp +++ b/projects/CMake/main.cpp @@ -28,13 +28,13 @@ int main() { int screenHeight = 450; raylib::Color background(RAYWHITE); raylib::Color textColor(LIGHTGRAY); - raylib::Window w(screenWidth, screenHeight, "raylib [core] example - basic window"); + raylib::Window window(screenWidth, screenHeight, "raylib [core] example - basic window"); SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop - while (!w.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/tests/catch.hpp b/tests/catch.hpp index 89ed9a4..0384171 100644 --- a/tests/catch.hpp +++ b/tests/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v2.13.3 - * Generated: 2020-10-31 18:20:31.045274 + * Catch v2.13.4 + * Generated: 2020-12-29 14:48:00.116107 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. @@ -15,7 +15,7 @@ #define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 3 +#define CATCH_VERSION_PATCH 4 #ifdef __clang__ # pragma clang system_header @@ -14126,24 +14126,28 @@ namespace Catch { namespace { struct TestHasher { - explicit TestHasher(Catch::SimplePcg32& rng_instance) { - basis = rng_instance(); - basis <<= 32; - basis |= rng_instance(); - } + using hash_t = uint64_t; - uint64_t basis; + explicit TestHasher( hash_t hashSuffix ): + m_hashSuffix{ hashSuffix } {} - uint64_t operator()(TestCase const& t) const { - // Modified FNV-1a hash - static constexpr uint64_t prime = 1099511628211; - uint64_t hash = basis; - for (const char c : t.name) { + uint32_t operator()( TestCase const& t ) const { + // FNV-1a hash with multiplication fold. + const hash_t prime = 1099511628211u; + hash_t hash = 14695981039346656037u; + for ( const char c : t.name ) { hash ^= c; hash *= prime; } - return hash; + hash ^= m_hashSuffix; + hash *= prime; + const uint32_t low{ static_cast( hash ) }; + const uint32_t high{ static_cast( hash >> 32 ) }; + return low * high; } + + private: + hash_t m_hashSuffix; }; } // end unnamed namespace @@ -14161,9 +14165,9 @@ namespace Catch { case RunTests::InRandomOrder: { seedRng( config ); - TestHasher h( rng() ); + TestHasher h{ config.rngSeed() }; - using hashedTest = std::pair; + using hashedTest = std::pair; std::vector indexed_tests; indexed_tests.reserve( unsortedTestCases.size() ); @@ -15316,7 +15320,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 13, 3, "", 0 ); + static Version version( 2, 13, 4, "", 0 ); return version; } @@ -17874,3 +17878,4 @@ using Catch::Detail::Approx; // end catch_reenable_warnings.h // end catch.hpp #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +