pcbjam/tests/3d-regression/scenarios/scene3d_test_rig.h
Istvan Matejcsok ce1473c9ab test(3d): screenshot-baseline TDD suite for the 3D viewer OpenGL->WebGL port — 47 native goldens + red-state WebGL harness
tests/3d-regression mirrors the gal-regression pattern at renderer scale:
shared C++ scenarios call real KiCad 3D-viewer code (opengl_utils, display
lists + DrawCulled stencil subtraction, MODEL_3D VBOs, private generators via
a rob-template accessor, and full reload()+Redraw() composites over a
synthetic BOARD_ADAPTER). A native macOS harness renders them on real OpenGL
into 47 committed goldens (bit-deterministic, FBO capture); the wasm harness
compiles the same TUs against wasm/stubs/gl_ffp_stub.c no-ops so every
scenario renders blank — the TDD red state (parity meter: 47/47 changed).
Comparisons use the CI pixelmatch engine via the new generic compare-dirs.ts
(floors.json levels; manifest.json cmp-guards registry drift).

Documents an upstream bug: appendPostMachiningGeometry's countersink path
adds middle quads without normals, silently erasing the walls of any
display list it is batched into (3d-post-machining.png keeps the lists
separate to record it).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 15:45:58 +02:00

44 lines
1.3 KiB
C++

/**
* Shared Tier-2/Tier-3 rig: stub settings + synthetic BOARD_ADAPTER
* (native/board_adapter_test_impl.cpp InitSettings) + a real RENDER_3D_OPENGL
* bound to the scenario camera, initialized the way the first real Redraw()
* would (initializeOpenGL under the fresh identity modelview — init_lights
* re-runs identically, keeping the directional lights eye-anchored).
*/
#ifndef SCENE3D_TEST_RIG_H
#define SCENE3D_TEST_RIG_H
#include "scene3d_test_ctx.h"
#include "../native/render3d_test_accessor.h"
#include "3d_canvas/board_adapter.h"
#include "3d_rendering/opengl/render_3d_opengl.h"
#include "3d_viewer/eda_3d_viewer_settings.h"
#include <memory>
struct SCENE3D_TEST_RIG
{
EDA_3D_VIEWER_SETTINGS m_cfg;
BOARD_ADAPTER m_adapter;
std::unique_ptr<RENDER_3D_OPENGL> m_renderer;
explicit SCENE3D_TEST_RIG( SCENE3D_CTX& aCtx )
{
m_adapter.m_Cfg = &m_cfg;
m_adapter.InitSettings( nullptr, nullptr );
m_renderer = std::make_unique<RENDER_3D_OPENGL>( nullptr, m_adapter, aCtx.m_camera );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
R3D_InitializeOpenGL( *m_renderer );
}
RENDER_3D_OPENGL& operator*() { return *m_renderer; }
RENDER_3D_OPENGL* operator->() { return m_renderer.get(); }
};
#endif // SCENE3D_TEST_RIG_H