diff options
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? |
