feat(webgl): Wire up WEBGL_GAL test harness with proper canvas setup

- Add wasm_stubs.cpp with WASM-specific stub implementations for
  COLOR4D::BLACK/WHITE, GLU tesselator, PGM_BASE, and other KiCad
  dependencies
- Update Makefile to include KiCad sources (GAL base class, display
  options, HiDPI canvas) and test scenarios
- Fix kiglew.h to define GLEW guard (__glew_h__) preventing conflicts
  with Emscripten's GLEW header
- Update test HTML to create canvas before module load (MODULARIZE
  requires passing canvas in Module config, not preRun)
- Update Playwright tests to find canvas elements correctly
- Add #window-container for wxWidgets GL canvas support

Build produces 8.4MB WASM with full WEBGL_GAL implementation.
Tests pass but rendering still shows dark output (debugging in progress).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-01-07 21:32:53 +01:00
commit c23bc974be
7 changed files with 747 additions and 180 deletions

View file

@ -96,9 +96,38 @@ test.describe('GAL WebGL Regression Tests', () => {
// Wait for rendering to complete
await page.waitForTimeout(100);
// Get the canvas element and take a screenshot of just the canvas
const canvas = await page.locator('#canvas');
await expect(canvas).toBeVisible();
// Debug: list all canvases on the page
const canvasInfo = await page.evaluate(() => {
const canvases = document.querySelectorAll('canvas');
const windowContainer = document.getElementById('window-container');
return {
canvases: Array.from(canvases).map(c => ({
id: c.id,
className: c.className,
width: c.width,
height: c.height,
display: window.getComputedStyle(c).display,
parentId: c.parentElement?.id
})),
windowContainerChildren: windowContainer?.children.length || 0,
allElements: document.querySelectorAll('#window-container *').length
};
});
console.log('Canvas debug:', JSON.stringify(canvasInfo, null, 2));
// Get the canvas element
// First try GL canvas, fall back to main canvas
let canvas = page.locator('.gl-canvas').first();
if (!(await canvas.count())) {
canvas = page.locator('#canvas');
}
// If still no canvas, use first available
if (!(await canvas.count())) {
canvas = page.locator('canvas').first();
}
await expect(canvas).toBeVisible({ timeout: 5000 });
// Screenshot the canvas (matching native 800x600 output)
const screenshotPath = path.join(OUTPUT_DIR, `gal-${scenarioName}.png`);