diff options
| author | nathan <nathansmith@disroot.org> | 2025-12-26 14:14:54 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-12-26 14:14:54 +0000 |
| commit | c9ae1941816183553c8c4313eac27cc831cbefba (patch) | |
| tree | 053ab2ca0819f3c9021574bcce9a24fc69cadc95 /src/utils.c | |
| parent | a5443e22bfce9ac00fdc6e746e17eb4aa68565f2 (diff) | |
| download | FindThings-c9ae1941816183553c8c4313eac27cc831cbefba.tar.gz FindThings-c9ae1941816183553c8c4313eac27cc831cbefba.tar.bz2 FindThings-c9ae1941816183553c8c4313eac27cc831cbefba.zip | |
Working on buildings
Diffstat (limited to 'src/utils.c')
| -rw-r--r-- | src/utils.c | 32 |
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? |
