summaryrefslogtreecommitdiff
path: root/src/gpu/texture_manager.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-03 19:06:41 +0100
committerskal <pascal.massimino@gmail.com>2026-02-03 19:06:41 +0100
commit3108fb0065a51dfc3548836ea16b287e92cd8881 (patch)
treeb20d3ffd904b65596ce9dd2df15a527b91a6539f /src/gpu/texture_manager.cc
parentc3714939897af2541c655c03bcdd61108fff46ea (diff)
feat: side-quest - Perlin noise sky and ProcGenFunc error handling
- Updated ProcGenFunc signature to return bool for error reporting. - Implemented gen_perlin (Fractional Brownian Motion) in procedural/generator.cc. - Added support for sky texture in Renderer3D and its shader. - Integrated Perlin noise sky texture in test_3d_render.cc. - Caught and handled memory/generation errors in AssetManager and TextureManager. - Assigned reference numbers to all remaining tasks in documentation. handoff(Gemini): Side-quest complete. ProcGenFunc now returns bool. Perlin noise added and used for sky in 3D test. Windows build remains stable. All tasks numbered.
Diffstat (limited to 'src/gpu/texture_manager.cc')
-rw-r--r--src/gpu/texture_manager.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gpu/texture_manager.cc b/src/gpu/texture_manager.cc
index 5da82c0..0c30c94 100644
--- a/src/gpu/texture_manager.cc
+++ b/src/gpu/texture_manager.cc
@@ -2,7 +2,7 @@
// It implements the TextureManager.
#include "gpu/texture_manager.h"
-#include <iostream>
+#include <cstdio>
#include <vector>
#if defined(DEMO_CROSS_COMPILE_WIN32)
@@ -33,14 +33,18 @@ void TextureManager::create_procedural_texture(
// 1. Generate Data on CPU
std::vector<uint8_t> pixel_data;
pixel_data.resize(def.width * def.height * 4);
- def.gen_func(pixel_data.data(), def.width, def.height, def.params.data(),
- (int)def.params.size());
+ if (!def.gen_func(pixel_data.data(), def.width, def.height, def.params.data(),
+ (int)def.params.size())) {
+ fprintf(stderr, "Error: Procedural texture generation failed for: %s\n",
+ name.c_str());
+ return;
+ }
create_texture(name, def.width, def.height, pixel_data.data());
#if !defined(STRIP_ALL)
- std::cout << "Generated procedural texture: " << name << " (" << def.width
- << "x" << def.height << ")" << std::endl;
+ printf("Generated procedural texture: %s (%dx%d)\n", name.c_str(), def.width,
+ def.height);
#endif
}