Merge remote-tracking branch 'refs/remotes/tpgc/main'
commit
94624bddec
|
@ -55,7 +55,7 @@ if(${ZLIB_FOUND})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(BLT PRIVATE /W4)
|
#target_compile_options(BLT PRIVATE /W4)
|
||||||
else()
|
else()
|
||||||
# perhaps we should warn on usused variables, but BLT will have lots of them.
|
# perhaps we should warn on usused variables, but BLT will have lots of them.
|
||||||
target_compile_options(BLT PRIVATE -Wall -Wextra -Wpedantic)
|
target_compile_options(BLT PRIVATE -Wall -Wextra -Wpedantic)
|
||||||
|
@ -66,8 +66,10 @@ message("BLT ${CMAKE_PROJECT_VERSION} Successfully included!")
|
||||||
if(${BUILD_TESTS})
|
if(${BUILD_TESTS})
|
||||||
project(BLT_TESTS)
|
project(BLT_TESTS)
|
||||||
|
|
||||||
add_compile_options(-fsanitize=address)
|
if(${CMAKE_BUILD_TYPE} MATCHES Debug AND LINUX)
|
||||||
add_link_options(-fsanitize=address)
|
add_compile_options(-fsanitize=address)
|
||||||
|
add_link_options(-fsanitize=address)
|
||||||
|
endif()
|
||||||
|
|
||||||
file(GLOB_RECURSE TESTS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.cpp")
|
file(GLOB_RECURSE TESTS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.cpp")
|
||||||
|
|
||||||
|
@ -76,7 +78,10 @@ if(${BUILD_TESTS})
|
||||||
target_link_libraries(BLT_TESTS PUBLIC BLT)
|
target_link_libraries(BLT_TESTS PUBLIC BLT)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(BLT_TESTS PRIVATE /W4)
|
#target_compile_options(BLT_TESTS PRIVATE /W4)
|
||||||
|
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||||
|
target_link_options(BLT_TESTS PRIVATE /DEBUG)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
target_compile_options(BLT_TESTS PRIVATE -Wall -Wextra -Wpedantic)
|
target_compile_options(BLT_TESTS PRIVATE -Wall -Wextra -Wpedantic)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "x64-Debug",
|
||||||
|
"generator": "Visual Studio 17 2022 Win64",
|
||||||
|
"configurationType": "Debug",
|
||||||
|
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"variables": [
|
||||||
|
{
|
||||||
|
"name": "BUILD_TESTS",
|
||||||
|
"value": "True",
|
||||||
|
"type": "BOOL"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Release",
|
||||||
|
"generator": "Visual Studio 17 2022 Win64",
|
||||||
|
"configurationType": "Release",
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||||
|
"intelliSenseMode": "windows-msvc-x64",
|
||||||
|
"variables": [
|
||||||
|
{
|
||||||
|
"name": "BUILD_TESTS",
|
||||||
|
"value": "True",
|
||||||
|
"type": "BOOL"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -9,6 +9,11 @@
|
||||||
|
|
||||||
#include <blt/math/vectors.h>
|
#include <blt/math/vectors.h>
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
// MSVC does not have M_PI
|
||||||
|
# define M_PI 3.14159265358979323846
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace blt {
|
namespace blt {
|
||||||
|
|
||||||
class mat4x4 {
|
class mat4x4 {
|
||||||
|
|
|
@ -19,8 +19,16 @@ namespace blt {
|
||||||
static inline constexpr bool f_equal(float v1, float v2) {
|
static inline constexpr bool f_equal(float v1, float v2) {
|
||||||
return v1 >= v2 - EPSILON && v1 <= v2 + EPSILON;
|
return v1 >= v2 - EPSILON && v1 <= v2 + EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MSVC_COMPILER (!defined(__GNUC__) && !defined(__clang__))
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MSVC_COMPILER
|
||||||
|
template<typename T, uint32_t size>
|
||||||
|
#else
|
||||||
|
// STFINAE is broken in MSVC?
|
||||||
template<typename T, uint32_t size, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr>
|
template<typename T, uint32_t size, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr>
|
||||||
|
#endif
|
||||||
struct vec {
|
struct vec {
|
||||||
private:
|
private:
|
||||||
T elements[size]{};
|
T elements[size]{};
|
||||||
|
@ -78,7 +86,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline vec<T, size> normalize() const {
|
[[nodiscard]] inline vec<T, size> normalize() const {
|
||||||
auto mag = this->magnitude();
|
T mag = this->magnitude();
|
||||||
if (mag == 0)
|
if (mag == 0)
|
||||||
return vec<T, size>(*this);
|
return vec<T, size>(*this);
|
||||||
return *this / mag;
|
return *this / mag;
|
||||||
|
@ -160,8 +168,8 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline constexpr vec<T, size> project(const vec<T, size>& u, const vec<T, size>& v){
|
static inline constexpr vec<T, size> project(const vec<T, size>& u, const vec<T, size>& v){
|
||||||
float du = dot(u);
|
T du = dot(u);
|
||||||
float dv = dot(v);
|
T dv = dot(v);
|
||||||
return (du / dv) * v;
|
return (du / dv) * v;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -183,7 +191,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
inline constexpr vec<T, size> operator+(const vec<T, size>& left, float f) {
|
inline constexpr vec<T, size> operator+(const vec<T, size>& left, T f) {
|
||||||
T initializer[size];
|
T initializer[size];
|
||||||
for (uint32_t i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
initializer[i] = left[i] + f;
|
initializer[i] = left[i] + f;
|
||||||
|
@ -191,7 +199,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
inline constexpr vec<T, size> operator-(const vec<T, size>& left, float f) {
|
inline constexpr vec<T, size> operator-(const vec<T, size>& left, T f) {
|
||||||
T initializer[size];
|
T initializer[size];
|
||||||
for (uint32_t i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
initializer[i] = left[i] + f;
|
initializer[i] = left[i] + f;
|
||||||
|
@ -199,7 +207,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
inline constexpr vec<T, size> operator+(float f, const vec<T, size>& right) {
|
inline constexpr vec<T, size> operator+(T f, const vec<T, size>& right) {
|
||||||
T initializer[size];
|
T initializer[size];
|
||||||
for (uint32_t i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
initializer[i] = f + right[i];
|
initializer[i] = f + right[i];
|
||||||
|
@ -207,7 +215,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
inline constexpr vec<T, size> operator-(float f, const vec<T, size>& right) {
|
inline constexpr vec<T, size> operator-(T f, const vec<T, size>& right) {
|
||||||
T initializer[size];
|
T initializer[size];
|
||||||
for (uint32_t i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
initializer[i] = f - right[i];
|
initializer[i] = f - right[i];
|
||||||
|
@ -223,7 +231,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
inline constexpr vec<T, size> operator*(const vec<T, size>& left, float f) {
|
inline constexpr vec<T, size> operator*(const vec<T, size>& left, T f) {
|
||||||
T initializer[size];
|
T initializer[size];
|
||||||
for (uint32_t i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
initializer[i] = left[i] * f;
|
initializer[i] = left[i] * f;
|
||||||
|
@ -231,7 +239,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
inline constexpr vec<T, size> operator*(float f, const vec<T, size>& right) {
|
inline constexpr vec<T, size> operator*(T f, const vec<T, size>& right) {
|
||||||
T initializer[size];
|
T initializer[size];
|
||||||
for (uint32_t i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
initializer[i] = f * right[i];
|
initializer[i] = f * right[i];
|
||||||
|
@ -239,7 +247,7 @@ namespace blt {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
inline constexpr vec<T, size> operator/(const vec<T, size>& left, float f) {
|
inline constexpr vec<T, size> operator/(const vec<T, size>& left, T f) {
|
||||||
T initializer[size];
|
T initializer[size];
|
||||||
for (uint32_t i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
initializer[i] = left[i] / f;
|
initializer[i] = left[i] / f;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace blt::fs {
|
||||||
// 32768 block size seems the fastest on my system
|
// 32768 block size seems the fastest on my system
|
||||||
unsigned long m_bufferSize;
|
unsigned long m_bufferSize;
|
||||||
public:
|
public:
|
||||||
explicit block_reader(unsigned long bufferSize): m_bufferSize(bufferSize) {}
|
explicit block_reader(size_t bufferSize): m_bufferSize(bufferSize) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads bytes from the internal filesystem implementation
|
* Reads bytes from the internal filesystem implementation
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace blt::string {
|
||||||
// taken from java, adapted for c++.
|
// taken from java, adapted for c++.
|
||||||
static inline utf8_string createUTFString(const std::string& str) {
|
static inline utf8_string createUTFString(const std::string& str) {
|
||||||
|
|
||||||
const unsigned int strlen = str.size();
|
const unsigned int strlen = (unsigned int) str.size();
|
||||||
unsigned int utflen = strlen;
|
unsigned int utflen = strlen;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < strlen; i++) {
|
for (unsigned int i = 0; i < strlen; i++) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ std::vector<std::string> blt::fs::getLinesFromFile(const std::string& path) {
|
||||||
shaderSource = shaderStream.str();
|
shaderSource = shaderStream.str();
|
||||||
} catch (std::ifstream::failure& e) {
|
} catch (std::ifstream::failure& e) {
|
||||||
BLT_WARN("Unable to read file '%s'!\n", path.c_str());
|
BLT_WARN("Unable to read file '%s'!\n", path.c_str());
|
||||||
|
BLT_WARN("Exception: %s", e.what());
|
||||||
throw std::runtime_error("Failed to read file!\n");
|
throw std::runtime_error("Failed to read file!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ std::vector<std::string> blt::fs::recursiveShaderInclude(const std::string& path
|
||||||
includes.insert({i, recursiveShaderInclude((pathOnly + "/" + file))});
|
includes.insert({i, recursiveShaderInclude((pathOnly + "/" + file))});
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
BLT_FATAL("Shader file contains an invalid #include statement. (Missing < or \")\n");
|
BLT_FATAL("Shader file contains an invalid #include statement. (Missing < or \")\n");
|
||||||
|
BLT_FATAL("Exception: %s", e.what());
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,8 +166,11 @@ namespace blt::logging {
|
||||||
|
|
||||||
std::string formattedString;
|
std::string formattedString;
|
||||||
applyFormatting(format, formattedString, args);
|
applyFormatting(format, formattedString, args);
|
||||||
|
|
||||||
bool hasEndingLinefeed = formattedString[formattedString.length()-1] == '\n';
|
bool hasEndingLinefeed = false;
|
||||||
|
|
||||||
|
if (formattedString.length() > 0)
|
||||||
|
hasEndingLinefeed = formattedString[formattedString.length() - 1] == '\n';
|
||||||
|
|
||||||
if (hasEndingLinefeed)
|
if (hasEndingLinefeed)
|
||||||
formattedString = formattedString.substr(0, formattedString.length()-1);
|
formattedString = formattedString.substr(0, formattedString.length()-1);
|
||||||
|
|
Loading…
Reference in New Issue