aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-12-26 14:14:54 +0000
committernathan <nathansmith@disroot.org>2025-12-26 14:14:54 +0000
commitc9ae1941816183553c8c4313eac27cc831cbefba (patch)
tree053ab2ca0819f3c9021574bcce9a24fc69cadc95 /src/utils.c
parenta5443e22bfce9ac00fdc6e746e17eb4aa68565f2 (diff)
downloadFindThings-c9ae1941816183553c8c4313eac27cc831cbefba.tar.gz
FindThings-c9ae1941816183553c8c4313eac27cc831cbefba.tar.bz2
FindThings-c9ae1941816183553c8c4313eac27cc831cbefba.zip
Working on buildings
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 02d7388..6d09293 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -34,4 +34,36 @@ Vector3 randomDirection3(int seed, int* nextSeed)
return Vector3Normalize(direction);
}
+Image generateCubemapImage(bool** cubemap, int width, int height)
+{
+ // Allocate pixel data.
+ Image image = (Image){
+ .data = FT_CALLOC(width * height, sizeof(Color)),
+ .width = width,
+ .height = height,
+ .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
+ .mipmaps = 1
+ };
+
+ if (image.data == NULL)
+ {
+ ALLOCATION_ERROR;
+ return image;
+ }
+
+ // Convert cubemap to image data.
+ int index = 0;
+
+ for (int y = 0; y < height; ++y)
+ {
+ for (int x = 0; x < width; ++x)
+ {
+ ((Color*)image.data)[index] = cubemap[y][x] ? BLACK : WHITE;
+ ++index;
+ }
+ }
+
+ return image;
+}
+
// Why does the universe feel strange to exist in?