Set C standard to C11 and add new assets

Changed CMakeLists.txt to set the C standard to C11.
Added multiple binary image files for new visual assets.
Added several new image files to enhance rendering capabilities.
Changed stb_image.h to improve support for various image formats.
Changed ray tracing engine to enhance ray creation and intersection.
Changed triangle structure to use a vertex array for better attribute handling.
Changed scene initialization to accommodate new texture management.
This commit is contained in:
2025-04-29 01:43:52 +09:00
parent 4db14ffdb0
commit 3de6b83d32
53 changed files with 8939 additions and 162671 deletions

77
header/Common/String.h Normal file
View File

@@ -0,0 +1,77 @@
#ifndef STRING_H
#define STRING_H
#include <ctype.h>
#include <string.h>
static inline bool is_absolute_path(const char* path)
{
if (!path || !*path) return false;
#ifdef _WIN32
// 1) Drive-letter paths: "C:\…", "D:/…"
if (isalpha((unsigned char)path[0]) &&
path[1] == ':' &&
(path[2] == '\\' || path[2] == '/'))
{
return true;
}
// 2) UNC paths: "\\server\share\…"
if (path[0] == '\\' && path[1] == '\\')
{
return true;
}
return false;
#else
// POSIX: anything starting with '/'
return path[0] == '/';
#endif
}
static inline void get_path_directory(const char* path, char* out, size_t out_size)
{
if (path == NULL || out == NULL || out_size == 0)
{
if (out && out_size > 0)
{
out[0] = '\0'; // ensure output is empty on invalid input
}
return;
}
const char* last_slash = strrchr(path, '/');
if (!last_slash)
{
if (out_size > 0)
out[0] = '\0';
return;
}
size_t dir_len = (size_t)(last_slash - path);
if (dir_len >= out_size)
{
dir_len = out_size - 1;
}
memcpy(out, path, dir_len);
out[dir_len] = '/';
out[dir_len + 1] = '\0';
}
static inline void string_join(const char* a, const char* b, char* out, size_t out_size)
{
if (a == NULL || b == NULL || out == NULL || out_size == 0) return;
size_t a_len = strlen(a);
size_t b_len = strlen(b);
if (a_len + b_len + 1 >= out_size) return; // +1 for null terminator
strcpy(out, a);
strcat(out, b);
}
#endif // STRING_H