feat(webgl): Replace legacy GL with modern OpenGL ES 3.0

Major refactoring to remove ALL legacy OpenGL immediate mode calls from
WEBGL_GAL and replace them with WebGL 2.0/OpenGL ES 3.0 compatible code.

Key changes:
- Add MVP matrix uniform support (replaces glMatrixMode/glOrtho/glLoadMatrix)
- Add matrix math helpers (computeOrthoMatrix, multiplyMatrix4x4, etc.)
- Replace glBegin/glEnd/glVertex with vertex manager pattern
- Rewrite DrawCursor to use vertex manager and DrawLine() calls
- Rewrite DrawBitmap to use vertex manager with SHADER_FONT mode
- Replace glEnableClientState with glVertexAttribPointer
- Replace glDrawBuffer with glDrawBuffers (WebGL 2.0 API)
- Add fullscreen_quad.cpp/h for compositor Present()
- Update SHADER class with mat4 uniform support
- Add MultiplyMatrix() to vertex_manager for Transform()
- Remove all legacy GL stubs from wasm_stubs.cpp

Build now completes with FULL_ES3 mode (no LEGACY_GL_EMULATION).
Remaining issue: wxWidgets GL library calls glColor3f internally.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-01-07 23:33:49 +01:00
commit d2f1a496f5
27 changed files with 840 additions and 349 deletions

View file

@ -68,12 +68,11 @@ BASE_LDFLAGS = -sALLOW_MEMORY_GROWTH=1 \
-sEXPORT_NAME='createGALTest' \
-sENVIRONMENT=web
# GL-specific flags - LEGACY_GL_EMULATION handles legacy GL calls (glBegin/glEnd)
# WebGL 2.0 for modern shader support
EM_GL_FLAGS = -sLEGACY_GL_EMULATION=1 -sMAX_WEBGL_VERSION=2
GL_SHIM = $(PROJECT_ROOT)/wasm/shims/gl_immediate_shim.js
# GL-specific flags - WebGL 2.0 with full ES3 support
# No LEGACY_GL_EMULATION - WEBGL_GAL uses VBOs and custom shaders
EM_GL_FLAGS = -sFULL_ES3=1 -sMAX_WEBGL_VERSION=2
LDFLAGS = $(DEBUG_LDFLAGS) $(BASE_LDFLAGS) $(EM_GL_FLAGS) --js-library=$(GL_SHIM) $(WX_LDFLAGS)
LDFLAGS = $(DEBUG_LDFLAGS) $(BASE_LDFLAGS) $(EM_GL_FLAGS) $(WX_LDFLAGS)
# Templates
JS = $(TOOLS_ROOT)/wx.js
@ -117,6 +116,7 @@ WEBGL_SRCS = webgl/webgl_gal.cpp \
webgl/cached_container_ram.cpp \
webgl/shader.cpp \
webgl/webgl_compositor.cpp \
webgl/fullscreen_quad.cpp \
webgl/utils.cpp \
webgl/gl_context_mgr.cpp \
webgl/gl_resources.cpp \