From 8bdc4754647c9c6691130fa91d51fee93c5fc88f Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 1 Feb 2026 10:51:15 +0100 Subject: 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. --- src/tests/test_procedural.cc | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/tests/test_procedural.cc (limited to 'src/tests/test_procedural.cc') 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 +#include +#include + +void test_noise() { + std::cout << "Testing Noise Generator..." << std::endl; + int w = 64, h = 64; + std::vector 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 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; +} -- cgit v1.2.3