Create custom JS library (lib/gl_immediate_shim.js) that fixes two Emscripten LEGACY_GL_EMULATION issues without modifying KiCad source: 1. Color-per-vertex requirement: Emscripten requires glColor before each glVertex, but standard OpenGL uses persistent "current color". The shim tracks color state and auto-injects before each vertex. 2. Missing double-precision functions: glVertex2d, glVertex3d, glColor3d, glColor4d are unimplemented in Emscripten (wontfix). The shim provides these as wrappers to float variants. Update test code to use standard OpenGL patterns (color set once, multiple vertices) to verify the shim works correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
45 lines
1.5 KiB
Text
45 lines
1.5 KiB
Text
# 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)
|
|
# 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)
|
|
|
|
# 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
|
|
|
|
# GL immediate mode shim - fixes Emscripten's color-per-vertex requirement
|
|
# and provides missing glVertex2d/glColor4d implementations
|
|
GL_SHIM = ../../lib/gl_immediate_shim.js
|
|
|
|
LDFLAGS = -sALLOW_MEMORY_GROWTH -sERROR_ON_UNDEFINED_SYMBOLS=0 \
|
|
-s "EXPORTED_RUNTIME_METHODS=['HEAPU8','HEAP8','HEAP32']" \
|
|
$(EM_GL_FLAGS) --js-library=$(GL_SHIM) $(WX_LDFLAGS)
|
|
|
|
JS = $(TOOLS_ROOT)/wx.js
|
|
HTML = $(TOOLS_ROOT)/template.html
|
|
|
|
all: $(TARGET).html
|
|
|
|
$(TARGET).o: $(SOURCES)
|
|
$(CXX) -c $(CXXFLAGS) $< -o $@
|
|
|
|
$(TARGET).html: $(TARGET).o
|
|
$(CXX) $(TARGET).o $(LDFLAGS) --pre-js $(JS) --shell-file $(HTML) -o $@
|
|
|
|
clean:
|
|
rm -f $(TARGET).o $(TARGET).html $(TARGET).js $(TARGET).wasm
|
|
|
|
.PHONY: all clean
|