diff --git a/include/lol/base/utils.h b/include/lol/bigint similarity index 87% rename from include/lol/base/utils.h rename to include/lol/bigint index 96c10aa2..9520cd9d 100644 --- a/include/lol/base/utils.h +++ b/include/lol/bigint @@ -12,6 +12,5 @@ #pragma once -#include "private/string.h" -#include "private/containers.h" +#include "private/types/bigint.h" diff --git a/include/lol/color b/include/lol/color new file mode 100644 index 00000000..d018baec --- /dev/null +++ b/include/lol/color @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/image/color.h" + diff --git a/include/lol/base/dialogs.h b/include/lol/dialogs similarity index 77% rename from include/lol/base/dialogs.h rename to include/lol/dialogs index c4c42480..84c23242 100644 --- a/include/lol/base/dialogs.h +++ b/include/lol/dialogs @@ -13,9 +13,9 @@ #pragma once // -// The Portable File Dialogs classes -// ————————————————————————————————— +// The Portable File Dialogs +// ————————————————————————— // -#include "../3rdparty/portable-file-dialogs/portable-file-dialogs.h" +#include "3rdparty/portable-file-dialogs/portable-file-dialogs.h" diff --git a/include/lol/getopt b/include/lol/getopt new file mode 100644 index 00000000..9f0b70b5 --- /dev/null +++ b/include/lol/getopt @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/sys/getopt.h" + diff --git a/include/lol/half b/include/lol/half new file mode 100644 index 00000000..303eeebc --- /dev/null +++ b/include/lol/half @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/types/half.h" + diff --git a/include/lol/math b/include/lol/math new file mode 100644 index 00000000..17d0ace9 --- /dev/null +++ b/include/lol/math @@ -0,0 +1,19 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/math/constants.h" +#include "private/math/functions.h" +#include "private/math/rand.h" +#include "private/math/polynomial.h" + diff --git a/include/lol/math/noise.h b/include/lol/noise similarity index 83% rename from include/lol/math/noise.h rename to include/lol/noise index 7699743d..087f4c82 100644 --- a/include/lol/math/noise.h +++ b/include/lol/noise @@ -17,6 +17,7 @@ // ——————————————— // -#include "private/perlin.h" -#include "private/simplex.h" +#include "private/math/gradient.h" +#include "private/math/perlin.h" +#include "private/math/simplex.h" diff --git a/include/lol/base/pegtl.h b/include/lol/pegtl similarity index 88% rename from include/lol/base/pegtl.h rename to include/lol/pegtl index 2df72784..18175f30 100644 --- a/include/lol/base/pegtl.h +++ b/include/lol/pegtl @@ -24,10 +24,5 @@ # define _WIN32_WINNT 0x0602 #endif -//namespace lol -//{ - -#include "../3rdparty/pegtl/include/tao/pegtl.hpp" - -//} // namespace lol +#include "3rdparty/pegtl/include/tao/pegtl.hpp" diff --git a/include/lol/base/private/containers.h b/include/lol/private/base/containers.h similarity index 100% rename from include/lol/base/private/containers.h rename to include/lol/private/base/containers.h diff --git a/include/lol/base/core.h b/include/lol/private/base/env.h similarity index 85% rename from include/lol/base/core.h rename to include/lol/private/base/env.h index 0e99cb8f..64b4def6 100644 --- a/include/lol/base/core.h +++ b/include/lol/private/base/env.h @@ -18,7 +18,7 @@ namespace lol { -namespace os +namespace sys { static inline std::string getenv(std::string const &var) @@ -39,14 +39,6 @@ static inline std::string getenv(std::string const &var) return std::string(); } -// A handy endianness test function -static inline bool is_big_endian() -{ - union { int i; char c; } u; - u.i = 1; - return u.c == 0; -} - } // namespace os } // namespace lol diff --git a/include/lol/private/base/misc.h b/include/lol/private/base/misc.h new file mode 100644 index 00000000..7a260b0f --- /dev/null +++ b/include/lol/private/base/misc.h @@ -0,0 +1,31 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +namespace lol +{ + +namespace sys +{ + +// A handy endianness test function +static inline bool is_big_endian() +{ + union { int i; char c; } u; + u.i = 1; + return u.c == 0; +} + +} // namespace os + +} // namespace lol diff --git a/include/lol/base/private/string.h b/include/lol/private/base/string.h similarity index 93% rename from include/lol/base/private/string.h rename to include/lol/private/base/string.h index 7c5e7042..ed6e034e 100644 --- a/include/lol/base/private/string.h +++ b/include/lol/private/base/string.h @@ -19,7 +19,7 @@ // Contains some utilities to work with std::string objects. // -#include "features.h" +#include "../features.h" #include // std::vector #include // std::basic_string @@ -149,7 +149,7 @@ std::basic_string toupper(T const *s) // Format a string, printf-style template -std::basic_string vformat(char const *format, va_list ap) +std::basic_string vformat(char const *fmt, va_list ap) { va_list ap2; #if defined va_copy || !defined _MSC_VER @@ -161,7 +161,7 @@ std::basic_string vformat(char const *format, va_list ap) // vsnprintf() tells us how many characters we need, not counting // the terminating null character. - size_t needed = vsnprintf(nullptr, 0, format, ap2); + size_t needed = vsnprintf(nullptr, 0, fmt, ap2); #if defined va_copy || !defined _MSC_VER // do not call va_end() if va_copy() wasn't called. @@ -170,17 +170,17 @@ std::basic_string vformat(char const *format, va_list ap) std::string ret; ret.resize(needed); - vsnprintf(&ret[0], needed + 1, format, ap); + vsnprintf(&ret[0], needed + 1, fmt, ap); return ret; } template lol_attr_printf_format(1, 2) -std::basic_string format(T const *format, ...) +std::basic_string format(T const *fmt, ...) { va_list ap; - va_start(ap, format); - std::string ret = vformat(format, ap); + va_start(ap, fmt); + std::string ret = vformat(fmt, ap); va_end(ap); return ret; } diff --git a/include/lol/base/private/features.h b/include/lol/private/features.h similarity index 100% rename from include/lol/base/private/features.h rename to include/lol/private/features.h diff --git a/include/lol/image/private/cie1931.ipp b/include/lol/private/image/cie1931.ipp similarity index 100% rename from include/lol/image/private/cie1931.ipp rename to include/lol/private/image/cie1931.ipp diff --git a/include/lol/image/color.h b/include/lol/private/image/color.h similarity index 97% rename from include/lol/image/color.h rename to include/lol/private/image/color.h index de35ac0c..3309399b 100644 --- a/include/lol/image/color.h +++ b/include/lol/private/image/color.h @@ -18,9 +18,9 @@ // Provides various color conversion routines. // -#include // FIXME: try to remove this -#include // vec_t -#include // mat_t +#include +#include // vec_t +#include // mat_t #include // std::fabs #include // std::min @@ -362,7 +362,7 @@ public: using color = color_t; -} /* namespace lol */ +} // namespace lol -#include "private/color.ipp" -#include "private/cie1931.ipp" +#include "color.ipp" +#include "cie1931.ipp" diff --git a/include/lol/image/private/color.ipp b/include/lol/private/image/color.ipp similarity index 100% rename from include/lol/image/private/color.ipp rename to include/lol/private/image/color.ipp diff --git a/include/lol/base/lolunit.h b/include/lol/private/lolunit.h similarity index 100% rename from include/lol/base/lolunit.h rename to include/lol/private/lolunit.h diff --git a/include/lol/math/constants.h b/include/lol/private/math/constants.h similarity index 100% rename from include/lol/math/constants.h rename to include/lol/private/math/constants.h diff --git a/include/lol/math/functions.h b/include/lol/private/math/functions.h similarity index 95% rename from include/lol/math/functions.h rename to include/lol/private/math/functions.h index 1b6cfeff..72fe4f32 100644 --- a/include/lol/math/functions.h +++ b/include/lol/private/math/functions.h @@ -17,8 +17,6 @@ // ——————————————————————— // -#include - #include #include #include @@ -110,6 +108,17 @@ LOL_FORWARD_FP_1_ARG(round) return degrees * (LD_PI / 180.0L); } +// Integer version of radians() for convenience +[[nodiscard]] static inline double radians(int32_t degrees) +{ + return radians(double(degrees)); +} + +[[nodiscard]] static inline double radians(int64_t degrees) +{ + return radians(double(degrees)); +} + // Interpolation template [[nodiscard]] static inline T2 mix(T a, T b, T x) diff --git a/include/lol/math/private/gradient.h b/include/lol/private/math/gradient.h similarity index 95% rename from include/lol/math/private/gradient.h rename to include/lol/private/math/gradient.h index e8d0ae7f..c3470575 100644 --- a/include/lol/math/private/gradient.h +++ b/include/lol/private/math/gradient.h @@ -14,11 +14,10 @@ #pragma once -#include // vec_t -#include // rand() - -#include // std::array -#include // std::min +#include // lol::vec_t +#include // lol::rand() +#include // std::array +#include // std::min namespace lol { diff --git a/include/lol/math/private/matrix.h b/include/lol/private/math/matrix.h similarity index 99% rename from include/lol/math/private/matrix.h rename to include/lol/private/math/matrix.h index 632a700b..77d31bcc 100644 --- a/include/lol/math/private/matrix.h +++ b/include/lol/private/math/matrix.h @@ -18,10 +18,9 @@ // #include "ops.h" -#include - -#include // std::ostream -#include // std::fabs +#include // lol::vec_t +#include // std::ostream +#include // std::fabs #if _WIN32 # pragma push_macro("near") diff --git a/include/lol/math/private/matrix.ipp b/include/lol/private/math/matrix.ipp similarity index 100% rename from include/lol/math/private/matrix.ipp rename to include/lol/private/math/matrix.ipp diff --git a/include/lol/math/private/ops.h b/include/lol/private/math/ops.h similarity index 100% rename from include/lol/math/private/ops.h rename to include/lol/private/math/ops.h diff --git a/include/lol/math/private/perlin.h b/include/lol/private/math/perlin.h similarity index 98% rename from include/lol/math/private/perlin.h rename to include/lol/private/math/perlin.h index af3889a7..19a08c5f 100644 --- a/include/lol/math/private/perlin.h +++ b/include/lol/private/math/perlin.h @@ -14,7 +14,7 @@ #pragma once -#include // for clamp() +#include "functions.h" // for clamp() #include "gradient.h" #include // std::sqrt diff --git a/include/lol/math/polynomial.h b/include/lol/private/math/polynomial.h similarity index 99% rename from include/lol/math/polynomial.h rename to include/lol/private/math/polynomial.h index fbddf58d..ea05e5dc 100644 --- a/include/lol/math/polynomial.h +++ b/include/lol/private/math/polynomial.h @@ -19,7 +19,7 @@ // added guarantee that the leading coefficient is always non-zero. // -#include "../base/private/features.h" +#include "../features.h" #include // std::vector #include // std::min diff --git a/include/lol/math/rand.h b/include/lol/private/math/rand.h similarity index 98% rename from include/lol/math/rand.h rename to include/lol/private/math/rand.h index 2f86ac76..13426606 100644 --- a/include/lol/math/rand.h +++ b/include/lol/private/math/rand.h @@ -17,8 +17,6 @@ // ———————————————————————————— // -#include "../base/private/features.h" - #include #include #include diff --git a/include/lol/math/private/simplex.h b/include/lol/private/math/simplex.h similarity index 98% rename from include/lol/math/private/simplex.h rename to include/lol/private/math/simplex.h index a857f6c0..a35c7c36 100644 --- a/include/lol/math/private/simplex.h +++ b/include/lol/private/math/simplex.h @@ -16,12 +16,11 @@ #include "gradient.h" -#include // vec_t -#include // mat_t - -#include // std::vector -#include // std::fabs -#include // std::min, std::max +#include // lol::vec_t +#include // lol::mat_t +#include // std::vector +#include // std::fabs +#include // std::min, std::max namespace lol { diff --git a/include/lol/math/transform.h b/include/lol/private/math/transform.h similarity index 99% rename from include/lol/math/transform.h rename to include/lol/private/math/transform.h index 67a36f68..c461a689 100644 --- a/include/lol/math/transform.h +++ b/include/lol/private/math/transform.h @@ -17,13 +17,12 @@ // ——————————————————————————————————————————————————— // -#include -#include - +#include #include // std::ostream #include // std::atan2, std::sqrt -#include "private/matrix.h" +#include "ops.h" +#include "matrix.h" namespace lol { @@ -591,6 +590,6 @@ typedef imat4x3 int4x3; } // namespace lol -#include "private/matrix.ipp" -#include "private/transform.ipp" +#include "matrix.ipp" +#include "transform.ipp" diff --git a/include/lol/math/private/transform.ipp b/include/lol/private/math/transform.ipp similarity index 100% rename from include/lol/math/private/transform.ipp rename to include/lol/private/math/transform.ipp diff --git a/include/lol/math/vector.h b/include/lol/private/math/vector.h similarity index 99% rename from include/lol/math/vector.h rename to include/lol/private/math/vector.h index c54d8923..89396503 100644 --- a/include/lol/math/vector.h +++ b/include/lol/private/math/vector.h @@ -26,7 +26,7 @@ // FIXME: get rid of this, too #include <../legacy/lol/base/types.h> -#include "private/ops.h" +#include "ops.h" #if _MSC_VER # pragma push_macro("min") @@ -1437,7 +1437,7 @@ typedef ivec12 int12; } // namespace lol -#include "private/vector.ipp" +#include "vector.ipp" #if _MSC_VER # pragma pop_macro("min") diff --git a/include/lol/math/private/vector.ipp b/include/lol/private/math/vector.ipp similarity index 95% rename from include/lol/math/private/vector.ipp rename to include/lol/private/math/vector.ipp index 348c20dc..32aafe44 100644 --- a/include/lol/math/private/vector.ipp +++ b/include/lol/private/math/vector.ipp @@ -12,7 +12,7 @@ #pragma once -#include // lol::format +#include "../base/string.h" // lol::format namespace lol { diff --git a/include/lol/base/getopt.h b/include/lol/private/sys/getopt.h similarity index 100% rename from include/lol/base/getopt.h rename to include/lol/private/sys/getopt.h diff --git a/include/lol/base/thread.h b/include/lol/private/sys/threading.h similarity index 98% rename from include/lol/base/thread.h rename to include/lol/private/sys/threading.h index 6965fed5..b90a0628 100644 --- a/include/lol/base/thread.h +++ b/include/lol/private/sys/threading.h @@ -17,7 +17,7 @@ // ————————————————————— // -#include // os::getenv +#include "../base/env.h" // sys::getenv #include // std::function #include @@ -73,7 +73,7 @@ public: // FIXME: move to os::has_threads? static bool has_threads() { - static bool const disable_threads = os::getenv("LOL_NOTHREADS").size() > 0; + static bool const disable_threads = sys::getenv("LOL_NOTHREADS").size() > 0; #if defined __EMSCRIPTEN__ && !defined __EMSCRIPTEN_PTHREADS__ // For some reason hardware_concurrency() will return the actual number // of threads/cores even though the system cannot spawn threads. diff --git a/include/lol/types/bigint.h b/include/lol/private/types/bigint.h similarity index 100% rename from include/lol/types/bigint.h rename to include/lol/private/types/bigint.h diff --git a/include/lol/types/half.h b/include/lol/private/types/half.h similarity index 99% rename from include/lol/types/half.h rename to include/lol/private/types/half.h index ab98f592..29c58d58 100644 --- a/include/lol/types/half.h +++ b/include/lol/private/types/half.h @@ -22,7 +22,8 @@ #include // uint32_t etc. // FIXME: get rid of this -#include +#include "../math/constants.h" +#include "../math/functions.h" namespace lol { diff --git a/include/lol/types/real.h b/include/lol/private/types/real.h similarity index 99% rename from include/lol/types/real.h rename to include/lol/private/types/real.h index e65f9c8b..6be1d72a 100644 --- a/include/lol/types/real.h +++ b/include/lol/private/types/real.h @@ -17,7 +17,7 @@ // ————————————————————— // -#include "../base/private/features.h" +#include "../features.h" #include // std::numeric_limits #include // std::vector @@ -265,7 +265,7 @@ typedef real_t real; } // namespace lol -#include "private/real.ipp" +#include "real.ipp" #if _MSC_VER # pragma pop_macro("min") diff --git a/include/lol/types/private/real.ipp b/include/lol/private/types/real.ipp similarity index 100% rename from include/lol/types/private/real.ipp rename to include/lol/private/types/real.ipp diff --git a/include/lol/real b/include/lol/real new file mode 100644 index 00000000..093493ce --- /dev/null +++ b/include/lol/real @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/types/real.h" + diff --git a/include/lol/thread b/include/lol/thread new file mode 100644 index 00000000..37167910 --- /dev/null +++ b/include/lol/thread @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/sys/threading.h" + diff --git a/include/lol/transform b/include/lol/transform new file mode 100644 index 00000000..78b0088b --- /dev/null +++ b/include/lol/transform @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/math/transform.h" + diff --git a/include/lol/unit_test b/include/lol/unit_test new file mode 100644 index 00000000..9dc08bed --- /dev/null +++ b/include/lol/unit_test @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/lolunit.h" + diff --git a/include/lol/utils b/include/lol/utils new file mode 100644 index 00000000..a0cc21f0 --- /dev/null +++ b/include/lol/utils @@ -0,0 +1,20 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/features.h" +#include "private/base/env.h" +#include "private/base/string.h" +#include "private/base/containers.h" +#include "private/base/misc.h" + diff --git a/include/lol/vector b/include/lol/vector new file mode 100644 index 00000000..cc22357a --- /dev/null +++ b/include/lol/vector @@ -0,0 +1,16 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/math/vector.h" + diff --git a/legacy/lol/algorithm/portal.h b/legacy/lol/algorithm/portal.h index 53895dd2..1261473b 100644 --- a/legacy/lol/algorithm/portal.h +++ b/legacy/lol/algorithm/portal.h @@ -14,12 +14,12 @@ #pragma once #include -#include // vec_t -#include // mat_t +#include // vec_t +#include // mat_t #include -#include +#include -#include /* for FLT_MAX */ +#include // FLT_MAX namespace lol { diff --git a/legacy/lol/image/pixel.h b/legacy/lol/image/pixel.h index 497d4533..b5535df7 100644 --- a/legacy/lol/image/pixel.h +++ b/legacy/lol/image/pixel.h @@ -18,7 +18,7 @@ // #include <../legacy/lol/base/types.h> -#include +#include namespace lol { diff --git a/legacy/lol/math/arraynd.h b/legacy/lol/math/arraynd.h index 1aa7d9c9..7973fcbc 100644 --- a/legacy/lol/math/arraynd.h +++ b/legacy/lol/math/arraynd.h @@ -20,12 +20,7 @@ // A N-Dimensional array class allowing var[i][j][k]... indexing, // -// -// XXX: This file is in lol/math/ instead of lol/base/ because it uses vec_t. -// - -#include // vec_t - +#include // lol::vec_t #include // std::vector #include // std::min #include // memset diff --git a/legacy/lol/math/geometry.h b/legacy/lol/math/geometry.h index f1de22b1..1cc9d63a 100644 --- a/legacy/lol/math/geometry.h +++ b/legacy/lol/math/geometry.h @@ -19,9 +19,9 @@ // #include -#include // distance, clamp… -#include // vec_t -#include // mat_t +#include // distance, clamp… +#include // vec_t +#include // mat_t #include #include diff --git a/legacy/lol/math/interp.h b/legacy/lol/math/interp.h index d49d0f67..f7c71300 100644 --- a/legacy/lol/math/interp.h +++ b/legacy/lol/math/interp.h @@ -12,7 +12,7 @@ #pragma once -#include <../legacy/lol/math/functions.h> +#include // // Interpolator classes diff --git a/legacy/numeric.h b/legacy/numeric.h index 6ecc2f5b..c381f8fa 100644 --- a/legacy/numeric.h +++ b/legacy/numeric.h @@ -17,8 +17,7 @@ // —————————————————————————————— // -#include - +#include // lol::lerp, lol::clamp #include #include