feat(webgl): Fix GL initialization and add GLSL ES shader conversion

Progress on WEBGL_GAL rendering:

- Fix GLImmediateShim initialization by adding GL function dependencies
  (glBegin, glEnd, glVertex2f, etc.) to $GLImmediateShim__deps
- Add COLOR4D(EDA_COLOR_T) constructor stub to wasm_stubs.cpp
- Fix GAL context locking - add LockContext/UnlockContext calls
- Add exception catching to build (-sNO_DISABLE_EXCEPTION_CATCHING)
- Create GLSL ES 1.00 shader converter in generate_shaders.py:
  - Remove #version 120 directive (ES 1.00 default)
  - Add precision highp float/int qualifiers
  - Convert int * float to float literals (2 * x -> 2.0 * x)
- Update build script to clean output files for linker flag changes
- Add console capture to test spec for debugging

Current status:
- WASM builds and loads successfully
- GLImmediateShim initializes correctly
- WEBGL_GAL creates successfully
- Shader compilation fails due to Emscripten LEGACY_GL_EMULATION
  prepending code that conflicts with custom shader precision

Next: Investigate shader compilation with LEGACY_GL_EMULATION or
consider alternative approaches for GL compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-01-07 21:59:21 +01:00
commit 6c2cf85177
17 changed files with 182 additions and 24 deletions

View file

@ -81,6 +81,15 @@ test.describe('GAL WebGL Regression Tests', () => {
const scenarioIndex = i;
test(`Scenario ${scenarioIndex}: ${scenarioName}`, async ({ page, testLogger }) => {
// Capture console output for debugging
const consoleLogs: string[] = [];
page.on('console', msg => {
consoleLogs.push(`[${msg.type()}] ${msg.text()}`);
});
page.on('pageerror', err => {
consoleLogs.push(`[ERROR] ${err.message}`);
});
await page.goto('/gal-webgl/gal_webgl_test.html');
// Wait for module to be ready
@ -133,6 +142,13 @@ test.describe('GAL WebGL Regression Tests', () => {
const screenshotPath = path.join(OUTPUT_DIR, `gal-${scenarioName}.png`);
await canvas.screenshot({ path: screenshotPath });
// Print console logs for first scenario (debugging)
if (scenarioIndex === 0) {
console.log('\n=== Console logs ===');
consoleLogs.forEach(log => console.log(log));
console.log('===================\n');
}
console.log(`Saved: ${screenshotPath}`);
});
}