feat(webgl): Fix WebGL GAL rendering with proper coordinate setup

- Fix coordinate system for 1:1 pixel mapping (was using nm scale)
- Set worldUnitLength to 1/96 to match native test setup
- Add SetLookAtPoint and SetZoomFactor for proper view transformation
- Fix glDrawBuffers for WebGL 2.0 (array index must match attachment)
- Add legacy_gl_stubs.js for wxWidgets compatibility
- Add isReady() check to prevent race condition in Playwright tests

All 28 GAL test scenarios now render correctly in WebGL.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-01-08 10:13:11 +01:00
commit 18c73c355e
8 changed files with 165 additions and 27 deletions

View file

@ -129,13 +129,23 @@
// Run a single scenario
function runScenario(index) {
if (!wasmModule) return;
console.log('[DEBUG JS] runScenario called with index:', index, 'wasmModule:', !!wasmModule);
if (!wasmModule) {
console.log('[DEBUG JS] wasmModule is null, returning early');
return;
}
const result = wasmModule.ccall('runScenario', 'number', ['number'], [index]);
if (result === 0) {
setStatus(`Rendered: ${SCENARIO_NAMES[index]}`);
} else {
setStatus(`ERROR: Failed scenario ${index}`);
try {
console.log('[DEBUG JS] Calling ccall...');
const result = wasmModule.ccall('runScenario', 'number', ['number'], [index]);
console.log('[DEBUG JS] ccall returned:', result);
if (result === 0) {
setStatus(`Rendered: ${SCENARIO_NAMES[index]}`);
} else {
setStatus(`ERROR: Failed scenario ${index}`);
}
} catch (e) {
console.error('[DEBUG JS] ccall threw error:', e);
}
}
@ -182,7 +192,8 @@
runAllScenarios,
getScenarioName: (index) => SCENARIO_NAMES[index],
getTotalScenarios: () => SCENARIO_NAMES.length,
getGLCanvas: getGLCanvas
getGLCanvas: getGLCanvas,
isReady: () => wasmModule !== null
};
// Create canvas immediately (before module loads)