feat(webgl): Add GAL native test harness for visual regression testing
Add a standalone test application that compiles KiCad's actual OPENGL_GAL
against system wxWidgets to generate baseline screenshots for comparing
native OpenGL rendering against WebGL rendering in the browser.
Architecture:
- Compiles 18 KiCad GAL source files from the kicad submodule
- Uses template-based private member accessor (safer than #define private public)
- Generates shader C++ files from GLSL (10 shader pairs for SMAA AA)
- Minimal stubs for KiCad dependencies (PGM_BASE, ADVANCED_CFG, etc.)
Test coverage:
- 11 scenarios testing ~19% of GAL API
- basic-lines, line-widths, circles, arcs, rectangles, polygons
- alpha-blending, transforms, grid-cursor, segments, complex-scene
Key insights documented:
- GAL uses world-to-screen transformation requiring 1:1 pixel mapping
- FBO reading required for clean screenshots on macOS
- Layer depth needed for proper z-ordering in complex scenes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 09:42:31 +01:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
project(gal_native_test)
|
|
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
|
|
# Suppress deprecation warnings on macOS
|
|
|
|
|
if(APPLE)
|
|
|
|
|
add_compile_definitions(GL_SILENCE_DEPRECATION)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Find wxWidgets (system installation)
|
|
|
|
|
set(wxWidgets_CONFIG_EXECUTABLE "/opt/homebrew/bin/wx-config")
|
|
|
|
|
find_package(wxWidgets REQUIRED COMPONENTS core base gl)
|
|
|
|
|
include(${wxWidgets_USE_FILE})
|
|
|
|
|
|
|
|
|
|
# Find other required packages
|
|
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
|
find_package(GLEW REQUIRED)
|
|
|
|
|
|
|
|
|
|
# KiCad source root
|
|
|
|
|
set(KICAD_ROOT ${CMAKE_SOURCE_DIR}/../../../kicad)
|
|
|
|
|
|
|
|
|
|
# Generated shader files
|
|
|
|
|
set(SHADER_SOURCES
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_kicad_frag.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_kicad_vert.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_base.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_pass_1_frag_color.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_pass_1_frag_luma.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_pass_1_vert.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_pass_2_frag.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_pass_2_vert.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_pass_3_frag.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated/glsl_smaa_pass_3_vert.cpp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# KiCad OpenGL GAL sources
|
|
|
|
|
set(KICAD_GAL_SOURCES
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/opengl_gal.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/gl_context_mgr.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/shader.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/vertex_manager.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/vertex_item.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/vertex_container.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/cached_container.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/cached_container_gpu.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/cached_container_ram.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/noncached_container.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/gpu_manager.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/opengl_compositor.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/antialiasing.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/utils.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/opengl/gl_resources.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/graphics_abstraction_layer.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/color4d.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/gal_display_options.cpp
|
|
|
|
|
${KICAD_ROOT}/common/gal/hidpi_gl_canvas.cpp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Our stub and test files
|
|
|
|
|
set(STUB_SOURCES
|
|
|
|
|
${CMAKE_SOURCE_DIR}/kicad_stubs.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/gal_test_accessor.cpp
|
2026-01-07 09:58:52 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Test scenario files
|
|
|
|
|
set(SCENARIO_SOURCES
|
feat(webgl): Add GAL native test harness for visual regression testing
Add a standalone test application that compiles KiCad's actual OPENGL_GAL
against system wxWidgets to generate baseline screenshots for comparing
native OpenGL rendering against WebGL rendering in the browser.
Architecture:
- Compiles 18 KiCad GAL source files from the kicad submodule
- Uses template-based private member accessor (safer than #define private public)
- Generates shader C++ files from GLSL (10 shader pairs for SMAA AA)
- Minimal stubs for KiCad dependencies (PGM_BASE, ADVANCED_CFG, etc.)
Test coverage:
- 11 scenarios testing ~19% of GAL API
- basic-lines, line-widths, circles, arcs, rectangles, polygons
- alpha-blending, transforms, grid-cursor, segments, complex-scene
Key insights documented:
- GAL uses world-to-screen transformation requiring 1:1 pixel mapping
- FBO reading required for clean screenshots on macOS
- Layer depth needed for proper z-ordering in complex scenes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 09:42:31 +01:00
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/gal_test_scenarios.cpp
|
2026-01-07 09:58:52 +01:00
|
|
|
# New modular scenarios
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_bezier_curves.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_arc_segments.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_segment_chain.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_group_caching.cpp
|
2026-01-07 12:27:06 +01:00
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_polylines_multi.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_hole_walls.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_grid_native.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_cursor_native.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_render_targets.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_screen_transform.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_clear_colors.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_depth_testing.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_negative_mode.cpp
|
|
|
|
|
# Additional scenarios (24-27)
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_text_attrs.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_glyphs.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_bitmap.cpp
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios/scenario_transform.cpp
|
feat(webgl): Add GAL native test harness for visual regression testing
Add a standalone test application that compiles KiCad's actual OPENGL_GAL
against system wxWidgets to generate baseline screenshots for comparing
native OpenGL rendering against WebGL rendering in the browser.
Architecture:
- Compiles 18 KiCad GAL source files from the kicad submodule
- Uses template-based private member accessor (safer than #define private public)
- Generates shader C++ files from GLSL (10 shader pairs for SMAA AA)
- Minimal stubs for KiCad dependencies (PGM_BASE, ADVANCED_CFG, etc.)
Test coverage:
- 11 scenarios testing ~19% of GAL API
- basic-lines, line-widths, circles, arcs, rectangles, polygons
- alpha-blending, transforms, grid-cursor, segments, complex-scene
Key insights documented:
- GAL uses world-to-screen transformation requiring 1:1 pixel mapping
- FBO reading required for clean screenshots on macOS
- Layer depth needed for proper z-ordering in complex scenes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 09:42:31 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Main executable
|
|
|
|
|
add_executable(gal_native_test
|
|
|
|
|
gal_native_test.cpp
|
|
|
|
|
${STUB_SOURCES}
|
2026-01-07 09:58:52 +01:00
|
|
|
${SCENARIO_SOURCES}
|
feat(webgl): Add GAL native test harness for visual regression testing
Add a standalone test application that compiles KiCad's actual OPENGL_GAL
against system wxWidgets to generate baseline screenshots for comparing
native OpenGL rendering against WebGL rendering in the browser.
Architecture:
- Compiles 18 KiCad GAL source files from the kicad submodule
- Uses template-based private member accessor (safer than #define private public)
- Generates shader C++ files from GLSL (10 shader pairs for SMAA AA)
- Minimal stubs for KiCad dependencies (PGM_BASE, ADVANCED_CFG, etc.)
Test coverage:
- 11 scenarios testing ~19% of GAL API
- basic-lines, line-widths, circles, arcs, rectangles, polygons
- alpha-blending, transforms, grid-cursor, segments, complex-scene
Key insights documented:
- GAL uses world-to-screen transformation requiring 1:1 pixel mapping
- FBO reading required for clean screenshots on macOS
- Layer depth needed for proper z-ordering in complex scenes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 09:42:31 +01:00
|
|
|
${KICAD_GAL_SOURCES}
|
|
|
|
|
${SHADER_SOURCES}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Include directories - our stubs first, then KiCad, then wxWidgets
|
|
|
|
|
target_include_directories(gal_native_test PRIVATE
|
|
|
|
|
# Our stubs (for KiCad-specific types not in wxWidgets)
|
|
|
|
|
${CMAKE_SOURCE_DIR}
|
|
|
|
|
${CMAKE_SOURCE_DIR}/../scenarios
|
|
|
|
|
${CMAKE_SOURCE_DIR}/generated
|
|
|
|
|
|
|
|
|
|
# KiCad includes
|
|
|
|
|
${KICAD_ROOT}/include
|
|
|
|
|
${KICAD_ROOT}/include/gal
|
|
|
|
|
${KICAD_ROOT}/include/gal/opengl
|
|
|
|
|
${KICAD_ROOT}/common # For gal/opengl/antialiasing.h
|
|
|
|
|
|
|
|
|
|
# KiCad libs
|
|
|
|
|
${KICAD_ROOT}/libs/kimath/include
|
|
|
|
|
${KICAD_ROOT}/libs/kimath/include/math
|
|
|
|
|
${KICAD_ROOT}/libs/kimath/include/geometry
|
|
|
|
|
${KICAD_ROOT}/libs/core/include
|
|
|
|
|
|
|
|
|
|
# KiCad thirdparty
|
|
|
|
|
${KICAD_ROOT}/thirdparty/thread-pool
|
|
|
|
|
|
|
|
|
|
# System includes
|
|
|
|
|
${OPENGL_INCLUDE_DIR}
|
|
|
|
|
${GLEW_INCLUDE_DIRS}
|
|
|
|
|
|
|
|
|
|
# Homebrew dependencies
|
|
|
|
|
/opt/homebrew/include # nlohmann-json, clipper2
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Link libraries
|
|
|
|
|
target_link_libraries(gal_native_test
|
|
|
|
|
${wxWidgets_LIBRARIES}
|
|
|
|
|
OpenGL::GL
|
|
|
|
|
GLEW::GLEW
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Compile definitions
|
|
|
|
|
target_compile_definitions(gal_native_test PRIVATE
|
|
|
|
|
GAL_TEST_BUILD=1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
message(STATUS "KiCad root: ${KICAD_ROOT}")
|
|
|
|
|
message(STATUS "wxWidgets libraries: ${wxWidgets_LIBRARIES}")
|
|
|
|
|
message(STATUS "Building GAL native test with actual KiCad OPENGL_GAL sources")
|