Fix Emscripten immediate mode GL and add comprehensive tests

- Fix immediate mode (glBegin/glEnd) by using color-per-vertex pattern
- Document Emscripten's requirement for color per vertex in GL_README.md
- Add OpenGL test tab with visual rendering verification
- Test GL_TRIANGLES, GL_QUADS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP
- Update wxwidgets submodule with improved context management

Key finding: Emscripten's LEGACY_GL_EMULATION requires glColor*() to be
called before EACH glVertex*() call, not using OpenGL's "current color"
semantic. This is because the stride calculation expects interleaved
vertex data with color per vertex.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2025-11-28 20:14:59 +01:00
commit 0db33b10f7
5 changed files with 875 additions and 10 deletions

View file

@ -1,18 +1,28 @@
# Makefile for minimal wxWidgets WASM test app
# Uses the local wxWidgets build
# Makefile for wxWidgets WASM test app with OpenGL support
# Uses the local wxWidgets build with legacy GL emulation
WXCONFIG = ../../build-wasm/wxwidgets-universal/wx-config
TOOLS_ROOT = ../../wxwidgets/build/wasm
CXX = em++
WX_CXXFLAGS := $(shell $(WXCONFIG) --cxxflags)
WX_LDFLAGS := $(shell $(WXCONFIG) --libs base,core)
# Include GL library for OpenGL tests
WX_LDFLAGS := $(shell $(WXCONFIG) --libs base,core,gl)
TARGET = minimal_test
SOURCES = minimal_test.cpp
CXXFLAGS = -O2 $(WX_CXXFLAGS)
LDFLAGS = -s TOTAL_MEMORY=32MB -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s "EXPORTED_RUNTIME_METHODS=['HEAPU8','HEAP8','HEAP32']" $(WX_LDFLAGS)
# Emscripten flags:
# -sLEGACY_GL_EMULATION: Enable legacy OpenGL (glBegin/glEnd, etc.) emulation on WebGL
# -sMAX_WEBGL_VERSION=2: Enable WebGL 2.0 support (required since wxGLCanvas requests WebGL 2)
# Note: Cannot combine LEGACY_GL_EMULATION with FULL_ES2 - they are mutually exclusive
EM_GL_FLAGS = -sLEGACY_GL_EMULATION -sMAX_WEBGL_VERSION=2
LDFLAGS = -sALLOW_MEMORY_GROWTH -sERROR_ON_UNDEFINED_SYMBOLS=0 \
-s "EXPORTED_RUNTIME_METHODS=['HEAPU8','HEAP8','HEAP32']" \
$(EM_GL_FLAGS) $(WX_LDFLAGS)
JS = $(TOOLS_ROOT)/wx.js
HTML = $(TOOLS_ROOT)/template.html