[HTML5] Add WebGL2 (GLES3) support using the OpenGL renderer.

Note, the editor build requires the mbedtls module to be manually
enabled, as it is currently needed as a ResourceUID dependency.

This will need to be addressed in a separate PR.
This commit is contained in:
Fabio Alessandrelli 2021-10-25 19:16:40 +02:00
parent 42f8bfaff0
commit 46fdba5f8b
9 changed files with 80 additions and 85 deletions

View file

@ -180,6 +180,13 @@ def configure(env):
env.Prepend(CPPPATH=["#platform/javascript"])
env.Append(CPPDEFINES=["JAVASCRIPT_ENABLED", "UNIX_ENABLED"])
if env["opengl3"]:
env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"])
# This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1.
env.Append(LINKFLAGS=["-s", "USE_WEBGL2=1"])
# Allow use to take control of swapping WebGL buffers.
env.Append(LINKFLAGS=["-s", "OFFSCREEN_FRAMEBUFFER=1"])
if env["javascript_eval"]:
env.Append(CPPDEFINES=["JAVASCRIPT_EVAL_ENABLED"])
@ -218,25 +225,11 @@ def configure(env):
# us since we don't know requirements at compile-time.
env.Append(LINKFLAGS=["-s", "ALLOW_MEMORY_GROWTH=1"])
# This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1.
env.Append(LINKFLAGS=["-s", "USE_WEBGL2=1"])
# Do not call main immediately when the support code is ready.
env.Append(LINKFLAGS=["-s", "INVOKE_RUN=0"])
# Allow use to take control of swapping WebGL buffers.
env.Append(LINKFLAGS=["-s", "OFFSCREEN_FRAMEBUFFER=1"])
# callMain for manual start, cwrap for the mono version.
env.Append(LINKFLAGS=["-s", "EXPORTED_RUNTIME_METHODS=['callMain','cwrap']"])
# Add code that allow exiting runtime.
env.Append(LINKFLAGS=["-s", "EXIT_RUNTIME=1"])
# TODO remove once we have GLES support back (temporary fix undefined symbols due to dead code elimination).
env.Append(
LINKFLAGS=[
"-s",
"EXPORTED_FUNCTIONS=['_main', '_emscripten_webgl_get_current_context']",
]
)