diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-01 10:51:15 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-01 10:51:15 +0100 |
| commit | 8bdc4754647c9c6691130fa91d51fee93c5fc88f (patch) | |
| tree | 2cfd7f72a21541c488ea48629eef47a6774fc2c4 /src/tests/test_procedural.cc | |
| parent | 7905abd9f7ad35231289e729b42e3ad57a943ff5 (diff) | |
feat: Implement 3D system and procedural texture manager
- Extended mini_math.h with mat4 multiplication and affine transforms.
- Implemented TextureManager for runtime procedural texture generation and GPU upload.
- Added 3D system components: Camera, Object, Scene, and Renderer3D.
- Created test_3d_render mini-demo for interactive 3D verification.
- Fixed WebGPU validation errors regarding depthSlice and unimplemented WaitAny.
Diffstat (limited to 'src/tests/test_procedural.cc')
| -rw-r--r-- | src/tests/test_procedural.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/tests/test_procedural.cc b/src/tests/test_procedural.cc new file mode 100644 index 0000000..3b82fa0 --- /dev/null +++ b/src/tests/test_procedural.cc @@ -0,0 +1,51 @@ +// This file is part of the 64k demo project. +// It tests the procedural generation system. + +#include "procedural/generator.h" +#include <cassert> +#include <iostream> +#include <vector> + +void test_noise() { + std::cout << "Testing Noise Generator..." << std::endl; + int w = 64, h = 64; + std::vector<uint8_t> buffer(w * h * 4); + float params[] = {12345, 1.0f}; // Seed, Intensity + + procedural::gen_noise(buffer.data(), w, h, params, 2); + + // Check simple properties: alpha should be 255 + assert(buffer[3] == 255); + // Check that not all pixels are black (very unlikely with noise) + bool nonzero = false; + for (size_t i = 0; i < buffer.size(); i += 4) { + if (buffer[i] > 0) { + nonzero = true; + break; + } + } + assert(nonzero); +} + +void test_grid() { + std::cout << "Testing Grid Generator..." << std::endl; + int w = 100, h = 100; + std::vector<uint8_t> buffer(w * h * 4); + float params[] = {10, 1}; // Size 10, Thickness 1 + + procedural::gen_grid(buffer.data(), w, h, params, 2); + + // Pixel (0,0) should be white (on line) + assert(buffer[0] == 255); + // Pixel (5,5) should be black (off line, since size=10) + assert(buffer[(5 * w + 5) * 4] == 0); + // Pixel (10,0) should be white (on vertical line) + assert(buffer[(0 * w + 10) * 4] == 255); +} + +int main() { + test_noise(); + test_grid(); + std::cout << "--- PROCEDURAL TESTS PASSED ---" << std::endl; + return 0; +} |
