feat(examples): add wireframe cubes test to GraphicsBenchmark
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 15 Mar 2026 02:56:31 +0000 (04:56 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 15 Mar 2026 02:56:31 +0000 (04:56 +0200)
Add WireframeCubesTest benchmark variant using WireframeBox shapes,
and update documentation with example benchmark output.

doc/index.org
src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphicsBenchmark.java

index 6ca38c4..db97fed 100644 (file)
@@ -216,6 +216,27 @@ Controls:
 Compare FPS between solid and textured modes to see exactly what
 texture sampling costs on your hardware.
 
+
+Example test run:
+#+begin_example
+================================================================================
+                         GRAPHICS BENCHMARK RESULTS
+================================================================================
+Date:       2026-03-15 04:53:17
+Resolution: 1920x1080
+Cubes:      4096 (16x16x16 grid)
+Duration:   30 seconds per test
+
+--------------------------------------------------------------------------------
+Test                         Duration    Frames    Avg FPS
+--------------------------------------------------------------------------------
+Solid Cubes                  30.02s      1136      37.84
+Textured Cubes               30.00s      793       26.43
+Wireframe Cubes              30.01s      1161      38.69
+================================================================================
+#+end_example
+
+
 * Source code
 :PROPERTIES:
 :CUSTOM_ID: source-code
index 4c523c0..0071d47 100644 (file)
@@ -14,9 +14,11 @@ import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.math.Vertex;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
+import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon.TexturedPolygon;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.solid.SolidPolygonCube;
+import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.WireframeBox;
 import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
 
 import java.time.LocalDateTime;
@@ -191,6 +193,58 @@ public class GraphicsBenchmark implements FrameListener {
         }
     }
 
+    /**
+     * Benchmark test for wireframe cubes.
+     */
+    public static class WireframeCubesTest implements BenchmarkTest {
+        private final Random random = new Random(RANDOM_SEED);
+        private final List<Object> cubes = new ArrayList<>();
+
+        @Override
+        public String getName() {
+            return "Wireframe Cubes";
+        }
+
+        @Override
+        public void setup(ShapeCollection shapes, Texture[] textures, int[] cubeTextureIndices) {
+            random.setSeed(RANDOM_SEED);
+            double offset = -(GRID_SIZE - 1) * SPACING / 2;
+
+            for (int x = 0; x < GRID_SIZE; x++) {
+                for (int y = 0; y < GRID_SIZE; y++) {
+                    for (int z = 0; z < GRID_SIZE; z++) {
+                        double px = offset + x * SPACING;
+                        double py = offset + y * SPACING;
+                        double pz = offset + z * SPACING;
+
+                        Color color = new Color(
+                                100 + random.nextInt(155),
+                                100 + random.nextInt(155),
+                                100 + random.nextInt(155)
+                        );
+                        LineAppearance appearance = new LineAppearance(1.5, color);
+
+                        Point3D center = new Point3D(px, py, pz);
+                        Point3D p1 = new Point3D(center.x - CUBE_SIZE, center.y - CUBE_SIZE, center.z - CUBE_SIZE);
+                        Point3D p2 = new Point3D(center.x + CUBE_SIZE, center.y + CUBE_SIZE, center.z + CUBE_SIZE);
+
+                        WireframeBox cube = new WireframeBox(p1, p2, appearance);
+                        shapes.addShape(cube);
+                        cubes.add(cube);
+                    }
+                }
+            }
+        }
+
+        @Override
+        public void teardown(ShapeCollection shapes) {
+            for (Object cube : cubes) {
+                shapes.getShapes().remove(cube);
+            }
+            cubes.clear();
+        }
+    }
+
     /**
      * Entry point for the graphics benchmark.
      * @param args command line arguments (ignored)
@@ -239,6 +293,7 @@ public class GraphicsBenchmark implements FrameListener {
     private void registerTests() {
         tests.add(new SolidCubesTest());
         tests.add(new TexturedCubesTest());
+        tests.add(new WireframeCubesTest());
     }
 
     private void startNextTest() {