more math & testing

This commit is contained in:
Asuro
2025-03-01 04:32:30 +01:00
parent b0c80c1bbb
commit f7c01cb7b5
9 changed files with 139 additions and 31 deletions

View File

@@ -5,18 +5,30 @@
#include <debugapi.h>
#define ESC "\x1B["
#define YELLOW ESC "33m"
#define RED ESC "31m"
#define END ESC "39m"
namespace
{
char LineBuffer[1024]{0};
char OutBuffer[1024]{0};
bx::HandleHashMapT<1024> OnceMap;
constexpr char LogFormat[]{"%s\n"};
constexpr char WarnFormat[]{YELLOW "%s" END "\n"};
constexpr char ErrorFormat[]{RED "%s" END "\n"};
} // namespace
void Log(ELogType logType, const char* file, uint32_t line, const char* format, ...)
{
const char* LineFormat = LogFormat;
if (logType == ELogType::Warn) LineFormat = WarnFormat;
if (logType == ELogType::Error) LineFormat = ErrorFormat;
va_list args;
va_start(args, format);
bx::snprintf(LineBuffer, sizeof(LineBuffer), "%s\n", format);
bx::snprintf(LineBuffer, sizeof(LineBuffer), LineFormat, format);
bx::vprintf(LineBuffer, args);
bx::vsnprintf(OutBuffer, sizeof(OutBuffer), LineBuffer, args);
va_end(args);