webruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/webruby +36 -0
- data/driver/driver.c +50 -0
- data/driver/main.c +40 -0
- data/lib/webruby/app.rb +13 -0
- data/lib/webruby/config.rb +61 -0
- data/lib/webruby/environment.rb +32 -0
- data/lib/webruby/rake/files.rake +66 -0
- data/lib/webruby/rake/general.rake +22 -0
- data/lib/webruby/rake/mruby.rake +44 -0
- data/lib/webruby/utility.rb +132 -0
- data/lib/webruby.rb +10 -0
- data/modules/emscripten/AUTHORS +89 -0
- data/modules/emscripten/LICENSE +68 -0
- data/modules/emscripten/README.markdown +14 -0
- data/modules/emscripten/cmake/Platform/Emscripten.cmake +61 -0
- data/modules/emscripten/cmake/Platform/Emscripten_unix.cmake +24 -0
- data/modules/emscripten/em++ +12 -0
- data/modules/emscripten/em++.bat +2 -0
- data/modules/emscripten/em-config +24 -0
- data/modules/emscripten/em-config.bat +2 -0
- data/modules/emscripten/emar +24 -0
- data/modules/emscripten/emar.bat +2 -0
- data/modules/emscripten/emcc +1744 -0
- data/modules/emscripten/emcc.bat +2 -0
- data/modules/emscripten/emcc.py +5 -0
- data/modules/emscripten/emconfigure +27 -0
- data/modules/emscripten/emconfigure.bat +2 -0
- data/modules/emscripten/emlibtool +11 -0
- data/modules/emscripten/emlibtool.bat +2 -0
- data/modules/emscripten/emlink.py +293 -0
- data/modules/emscripten/emmake +29 -0
- data/modules/emscripten/emmake.bat +2 -0
- data/modules/emscripten/emranlib +9 -0
- data/modules/emscripten/emranlib.bat +2 -0
- data/modules/emscripten/emscons +20 -0
- data/modules/emscripten/emscripten.py +835 -0
- data/modules/emscripten/patches/README +4 -0
- data/modules/emscripten/patches/series +2 -0
- data/modules/emscripten/scons-tools/closure.py +28 -0
- data/modules/emscripten/scons-tools/emscripten.py +359 -0
- data/modules/emscripten/scons-tools/llvm.py +33 -0
- data/modules/emscripten/src/analyzer.js +1695 -0
- data/modules/emscripten/src/compiler.html +48 -0
- data/modules/emscripten/src/compiler.js +298 -0
- data/modules/emscripten/src/corruptionCheck.js +98 -0
- data/modules/emscripten/src/determinstic.js +20 -0
- data/modules/emscripten/src/embind/embind.js +1677 -0
- data/modules/emscripten/src/embind/emval.js +283 -0
- data/modules/emscripten/src/experimental/allow_loopvars_from_memsetcpy_inasm.diff +97 -0
- data/modules/emscripten/src/experimental/batching.diff +44 -0
- data/modules/emscripten/src/experimental/functypeopt.diff +113 -0
- data/modules/emscripten/src/experimental/multiple_heaps.diff +175 -0
- data/modules/emscripten/src/experimental/noncallgraphprofiling.diff +197 -0
- data/modules/emscripten/src/experimental/optimize_memcpy_for_ta1.diff +124 -0
- data/modules/emscripten/src/experimental/remove__label__s.diff +140 -0
- data/modules/emscripten/src/experimental/renderer_cache_hash.diff +99 -0
- data/modules/emscripten/src/experimental/sdl_key_forwarding.diff +57 -0
- data/modules/emscripten/src/experimental/simplifyGeneratedFunctionsDetection.diff +336 -0
- data/modules/emscripten/src/experimental/stringCache.diff +147 -0
- data/modules/emscripten/src/fastLong.js +299 -0
- data/modules/emscripten/src/framework.js +257 -0
- data/modules/emscripten/src/gl-matrix.js +1952 -0
- data/modules/emscripten/src/headless.js +904 -0
- data/modules/emscripten/src/intertyper.js +1050 -0
- data/modules/emscripten/src/jsifier.js +1827 -0
- data/modules/emscripten/src/library.js +8270 -0
- data/modules/emscripten/src/library_browser.js +911 -0
- data/modules/emscripten/src/library_egl.js +491 -0
- data/modules/emscripten/src/library_gc.js +236 -0
- data/modules/emscripten/src/library_gl.js +4452 -0
- data/modules/emscripten/src/library_glfw.js +576 -0
- data/modules/emscripten/src/library_glut.js +449 -0
- data/modules/emscripten/src/library_jansson.js +320 -0
- data/modules/emscripten/src/library_openal.js +602 -0
- data/modules/emscripten/src/library_sdl.js +2024 -0
- data/modules/emscripten/src/library_strtok_r.c +97 -0
- data/modules/emscripten/src/library_xlib.js +23 -0
- data/modules/emscripten/src/long.js +1609 -0
- data/modules/emscripten/src/modules.js +491 -0
- data/modules/emscripten/src/parseTools.js +2474 -0
- data/modules/emscripten/src/postamble.js +170 -0
- data/modules/emscripten/src/postamble_sharedlib.js +16 -0
- data/modules/emscripten/src/preamble.js +914 -0
- data/modules/emscripten/src/preamble_sharedlib.js +25 -0
- data/modules/emscripten/src/relooper/README.markdown +14 -0
- data/modules/emscripten/src/relooper/Relooper.cpp +1236 -0
- data/modules/emscripten/src/relooper/Relooper.h +250 -0
- data/modules/emscripten/src/relooper/doit.sh +70 -0
- data/modules/emscripten/src/relooper/emscripten/glue.js +57 -0
- data/modules/emscripten/src/relooper/emscripten/test.js +44 -0
- data/modules/emscripten/src/relooper/fuzzer.py +116 -0
- data/modules/emscripten/src/relooper/ministring.h +35 -0
- data/modules/emscripten/src/relooper/paper.pdf +0 -0
- data/modules/emscripten/src/relooper/test.cpp +262 -0
- data/modules/emscripten/src/relooper/test.txt +155 -0
- data/modules/emscripten/src/relooper/test2.c +44 -0
- data/modules/emscripten/src/relooper/test2.txt +12 -0
- data/modules/emscripten/src/relooper/test3.c +42 -0
- data/modules/emscripten/src/relooper/test3.txt +27 -0
- data/modules/emscripten/src/relooper/test4.cpp +40 -0
- data/modules/emscripten/src/relooper/test4.txt +23 -0
- data/modules/emscripten/src/relooper/test5.cpp +40 -0
- data/modules/emscripten/src/relooper/test5.txt +32 -0
- data/modules/emscripten/src/relooper/test6.cpp +31 -0
- data/modules/emscripten/src/relooper/test6.txt +12 -0
- data/modules/emscripten/src/relooper/test_dead.cpp +28 -0
- data/modules/emscripten/src/relooper/test_dead.txt +9 -0
- data/modules/emscripten/src/relooper/test_debug.cpp +30 -0
- data/modules/emscripten/src/relooper/test_debug.txt +128 -0
- data/modules/emscripten/src/relooper/test_fuzz1.cpp +52 -0
- data/modules/emscripten/src/relooper/test_fuzz1.txt +32 -0
- data/modules/emscripten/src/relooper/test_fuzz2.cpp +34 -0
- data/modules/emscripten/src/relooper/test_fuzz2.txt +13 -0
- data/modules/emscripten/src/relooper/test_fuzz3.cpp +36 -0
- data/modules/emscripten/src/relooper/test_fuzz3.txt +9 -0
- data/modules/emscripten/src/relooper/test_fuzz4.cpp +38 -0
- data/modules/emscripten/src/relooper/test_fuzz4.txt +19 -0
- data/modules/emscripten/src/relooper/test_fuzz5.cpp +57 -0
- data/modules/emscripten/src/relooper/test_fuzz5.txt +52 -0
- data/modules/emscripten/src/relooper/test_fuzz6.cpp +322 -0
- data/modules/emscripten/src/relooper/test_fuzz6.txt +108 -0
- data/modules/emscripten/src/relooper/test_inf.cpp +813 -0
- data/modules/emscripten/src/relooper/test_inf.txt +385 -0
- data/modules/emscripten/src/relooper/testit.sh +62 -0
- data/modules/emscripten/src/relooper/updateit.sh +17 -0
- data/modules/emscripten/src/relooper.js +11516 -0
- data/modules/emscripten/src/relooper.js.raw.js +11511 -0
- data/modules/emscripten/src/runtime.js +546 -0
- data/modules/emscripten/src/settings.js +1284 -0
- data/modules/emscripten/src/shell.html +92 -0
- data/modules/emscripten/src/shell.js +153 -0
- data/modules/emscripten/src/shell_sharedlib.js +12 -0
- data/modules/emscripten/src/socket.io.js +3870 -0
- data/modules/emscripten/src/utility.js +379 -0
- data/modules/emscripten/src/wrtcp.js +821 -0
- data/modules/emscripten/system/include/AL/al.h +172 -0
- data/modules/emscripten/system/include/AL/alc.h +84 -0
- data/modules/emscripten/system/include/EGL/egl.h +329 -0
- data/modules/emscripten/system/include/EGL/eglext.h +398 -0
- data/modules/emscripten/system/include/EGL/eglplatform.h +141 -0
- data/modules/emscripten/system/include/GL/freeglut_std.h +628 -0
- data/modules/emscripten/system/include/GL/gl.h +2241 -0
- data/modules/emscripten/system/include/GL/glew.h +6 -0
- data/modules/emscripten/system/include/GL/glext.h +11127 -0
- data/modules/emscripten/system/include/GL/glfw.h +518 -0
- data/modules/emscripten/system/include/GL/glu.h +353 -0
- data/modules/emscripten/system/include/GL/glut.h +21 -0
- data/modules/emscripten/system/include/GLES/gl.h +770 -0
- data/modules/emscripten/system/include/GLES/glext.h +1278 -0
- data/modules/emscripten/system/include/GLES/glplatform.h +30 -0
- data/modules/emscripten/system/include/GLES2/gl2.h +621 -0
- data/modules/emscripten/system/include/GLES2/gl2ext.h +803 -0
- data/modules/emscripten/system/include/GLES2/gl2platform.h +30 -0
- data/modules/emscripten/system/include/KHR/khrplatform.h +277 -0
- data/modules/emscripten/system/include/SDL/COPYING +19 -0
- data/modules/emscripten/system/include/SDL/SDL.h +162 -0
- data/modules/emscripten/system/include/SDL/SDL_assert.h +241 -0
- data/modules/emscripten/system/include/SDL/SDL_atomic.h +318 -0
- data/modules/emscripten/system/include/SDL/SDL_audio.h +509 -0
- data/modules/emscripten/system/include/SDL/SDL_blendmode.h +60 -0
- data/modules/emscripten/system/include/SDL/SDL_clipboard.h +75 -0
- data/modules/emscripten/system/include/SDL/SDL_compat.h +365 -0
- data/modules/emscripten/system/include/SDL/SDL_config.h +48 -0
- data/modules/emscripten/system/include/SDL/SDL_config.h.in +297 -0
- data/modules/emscripten/system/include/SDL/SDL_config_android.h +133 -0
- data/modules/emscripten/system/include/SDL/SDL_config_iphoneos.h +148 -0
- data/modules/emscripten/system/include/SDL/SDL_config_macosx.h +172 -0
- data/modules/emscripten/system/include/SDL/SDL_config_minimal.h +74 -0
- data/modules/emscripten/system/include/SDL/SDL_config_nintendods.h +129 -0
- data/modules/emscripten/system/include/SDL/SDL_config_pandora.h +125 -0
- data/modules/emscripten/system/include/SDL/SDL_config_windows.h +207 -0
- data/modules/emscripten/system/include/SDL/SDL_config_wiz.h +119 -0
- data/modules/emscripten/system/include/SDL/SDL_copying.h +20 -0
- data/modules/emscripten/system/include/SDL/SDL_cpuinfo.h +150 -0
- data/modules/emscripten/system/include/SDL/SDL_endian.h +248 -0
- data/modules/emscripten/system/include/SDL/SDL_error.h +77 -0
- data/modules/emscripten/system/include/SDL/SDL_events.h +639 -0
- data/modules/emscripten/system/include/SDL/SDL_gesture.h +91 -0
- data/modules/emscripten/system/include/SDL/SDL_gfxPrimitives.h +246 -0
- data/modules/emscripten/system/include/SDL/SDL_haptic.h +1200 -0
- data/modules/emscripten/system/include/SDL/SDL_hints.h +206 -0
- data/modules/emscripten/system/include/SDL/SDL_image.h +138 -0
- data/modules/emscripten/system/include/SDL/SDL_input.h +87 -0
- data/modules/emscripten/system/include/SDL/SDL_joystick.h +208 -0
- data/modules/emscripten/system/include/SDL/SDL_keyboard.h +169 -0
- data/modules/emscripten/system/include/SDL/SDL_keycode.h +344 -0
- data/modules/emscripten/system/include/SDL/SDL_loadso.h +85 -0
- data/modules/emscripten/system/include/SDL/SDL_log.h +211 -0
- data/modules/emscripten/system/include/SDL/SDL_main.h +98 -0
- data/modules/emscripten/system/include/SDL/SDL_mixer.h +634 -0
- data/modules/emscripten/system/include/SDL/SDL_mouse.h +213 -0
- data/modules/emscripten/system/include/SDL/SDL_mutex.h +248 -0
- data/modules/emscripten/system/include/SDL/SDL_name.h +11 -0
- data/modules/emscripten/system/include/SDL/SDL_opengl.h +11116 -0
- data/modules/emscripten/system/include/SDL/SDL_opengles.h +38 -0
- data/modules/emscripten/system/include/SDL/SDL_opengles2.h +38 -0
- data/modules/emscripten/system/include/SDL/SDL_pixels.h +423 -0
- data/modules/emscripten/system/include/SDL/SDL_platform.h +160 -0
- data/modules/emscripten/system/include/SDL/SDL_power.h +79 -0
- data/modules/emscripten/system/include/SDL/SDL_quit.h +58 -0
- data/modules/emscripten/system/include/SDL/SDL_rect.h +136 -0
- data/modules/emscripten/system/include/SDL/SDL_render.h +615 -0
- data/modules/emscripten/system/include/SDL/SDL_revision.h +2 -0
- data/modules/emscripten/system/include/SDL/SDL_revision.h.orig +2 -0
- data/modules/emscripten/system/include/SDL/SDL_rotozoom.h +123 -0
- data/modules/emscripten/system/include/SDL/SDL_rwops.h +220 -0
- data/modules/emscripten/system/include/SDL/SDL_scancode.h +398 -0
- data/modules/emscripten/system/include/SDL/SDL_shape.h +147 -0
- data/modules/emscripten/system/include/SDL/SDL_stdinc.h +764 -0
- data/modules/emscripten/system/include/SDL/SDL_surface.h +499 -0
- data/modules/emscripten/system/include/SDL/SDL_syswm.h +241 -0
- data/modules/emscripten/system/include/SDL/SDL_thread.h +182 -0
- data/modules/emscripten/system/include/SDL/SDL_timer.h +108 -0
- data/modules/emscripten/system/include/SDL/SDL_touch.h +124 -0
- data/modules/emscripten/system/include/SDL/SDL_ttf.h +249 -0
- data/modules/emscripten/system/include/SDL/SDL_types.h +29 -0
- data/modules/emscripten/system/include/SDL/SDL_version.h +166 -0
- data/modules/emscripten/system/include/SDL/SDL_video.h +820 -0
- data/modules/emscripten/system/include/SDL/begin_code.h +135 -0
- data/modules/emscripten/system/include/SDL/close_code.h +37 -0
- data/modules/emscripten/system/include/X11/X.h +717 -0
- data/modules/emscripten/system/include/X11/Xatom.h +79 -0
- data/modules/emscripten/system/include/X11/Xfuncproto.h +127 -0
- data/modules/emscripten/system/include/X11/Xlib.h +4023 -0
- data/modules/emscripten/system/include/X11/Xosdefs.h +116 -0
- data/modules/emscripten/system/include/X11/Xutil.h +826 -0
- data/modules/emscripten/system/include/X11/keysym.h +73 -0
- data/modules/emscripten/system/include/X11/keysymdef.h +2389 -0
- data/modules/emscripten/system/include/bsd/float.h +91 -0
- data/modules/emscripten/system/include/bsd/readme.txt +2 -0
- data/modules/emscripten/system/include/bsd/sys/mman.h +180 -0
- data/modules/emscripten/system/include/bsd/sys/utsname.h +70 -0
- data/modules/emscripten/system/include/dlfcn.h +31 -0
- data/modules/emscripten/system/include/emscripten/bind.h +1210 -0
- data/modules/emscripten/system/include/emscripten/emscripten.h +388 -0
- data/modules/emscripten/system/include/emscripten/val.h +311 -0
- data/modules/emscripten/system/include/emscripten/wire.h +393 -0
- data/modules/emscripten/system/include/err.h +95 -0
- data/modules/emscripten/system/include/execinfo.h +44 -0
- data/modules/emscripten/system/include/features.h +3 -0
- data/modules/emscripten/system/include/gc.h +70 -0
- data/modules/emscripten/system/include/gfx/png.h +3798 -0
- data/modules/emscripten/system/include/gfx/pngconf.h +1665 -0
- data/modules/emscripten/system/include/gfx/tiff.h +654 -0
- data/modules/emscripten/system/include/gfx/tiffconf.h +104 -0
- data/modules/emscripten/system/include/gfx/tiffio.h +526 -0
- data/modules/emscripten/system/include/gfx/tiffvers.h +9 -0
- data/modules/emscripten/system/include/jansson.h +323 -0
- data/modules/emscripten/system/include/jansson_config.h +54 -0
- data/modules/emscripten/system/include/libc/_ansi.h +135 -0
- data/modules/emscripten/system/include/libc/_syslist.h +40 -0
- data/modules/emscripten/system/include/libc/alloca.h +21 -0
- data/modules/emscripten/system/include/libc/ar.h +69 -0
- data/modules/emscripten/system/include/libc/argz.h +33 -0
- data/modules/emscripten/system/include/libc/assert.h +46 -0
- data/modules/emscripten/system/include/libc/complex.h +124 -0
- data/modules/emscripten/system/include/libc/ctype.h +196 -0
- data/modules/emscripten/system/include/libc/dirent.h +16 -0
- data/modules/emscripten/system/include/libc/endian.h +3 -0
- data/modules/emscripten/system/include/libc/envlock.h +15 -0
- data/modules/emscripten/system/include/libc/envz.h +16 -0
- data/modules/emscripten/system/include/libc/errno.h +11 -0
- data/modules/emscripten/system/include/libc/fastmath.h +13 -0
- data/modules/emscripten/system/include/libc/fcntl.h +1 -0
- data/modules/emscripten/system/include/libc/fnmatch.h +55 -0
- data/modules/emscripten/system/include/libc/getopt.h +196 -0
- data/modules/emscripten/system/include/libc/glob.h +89 -0
- data/modules/emscripten/system/include/libc/grp.h +94 -0
- data/modules/emscripten/system/include/libc/iconv.h +62 -0
- data/modules/emscripten/system/include/libc/ieeefp.h +256 -0
- data/modules/emscripten/system/include/libc/ifaddrs.h +64 -0
- data/modules/emscripten/system/include/libc/inttypes.h +290 -0
- data/modules/emscripten/system/include/libc/iso646.h +43 -0
- data/modules/emscripten/system/include/libc/langinfo.h +316 -0
- data/modules/emscripten/system/include/libc/libgen.h +23 -0
- data/modules/emscripten/system/include/libc/limits.h +155 -0
- data/modules/emscripten/system/include/libc/locale.h +80 -0
- data/modules/emscripten/system/include/libc/machine/_default_types.h +121 -0
- data/modules/emscripten/system/include/libc/machine/_types.h +8 -0
- data/modules/emscripten/system/include/libc/machine/ansi.h +1 -0
- data/modules/emscripten/system/include/libc/machine/endian.h +31 -0
- data/modules/emscripten/system/include/libc/machine/fastmath.h +100 -0
- data/modules/emscripten/system/include/libc/machine/ieeefp.h +376 -0
- data/modules/emscripten/system/include/libc/machine/malloc.h +8 -0
- data/modules/emscripten/system/include/libc/machine/param.h +1 -0
- data/modules/emscripten/system/include/libc/machine/setjmp-dj.h +43 -0
- data/modules/emscripten/system/include/libc/machine/setjmp.h +361 -0
- data/modules/emscripten/system/include/libc/machine/stdlib.h +8 -0
- data/modules/emscripten/system/include/libc/machine/termios.h +1 -0
- data/modules/emscripten/system/include/libc/machine/time.h +19 -0
- data/modules/emscripten/system/include/libc/machine/types.h +30 -0
- data/modules/emscripten/system/include/libc/malloc.h +169 -0
- data/modules/emscripten/system/include/libc/math.h +594 -0
- data/modules/emscripten/system/include/libc/newlib.h +2 -0
- data/modules/emscripten/system/include/libc/paths.h +7 -0
- data/modules/emscripten/system/include/libc/process.h +44 -0
- data/modules/emscripten/system/include/libc/pthread.h +362 -0
- data/modules/emscripten/system/include/libc/pwd.h +78 -0
- data/modules/emscripten/system/include/libc/readme.txt +3 -0
- data/modules/emscripten/system/include/libc/reent.h +183 -0
- data/modules/emscripten/system/include/libc/regdef.h +7 -0
- data/modules/emscripten/system/include/libc/regex.h +102 -0
- data/modules/emscripten/system/include/libc/sched.h +97 -0
- data/modules/emscripten/system/include/libc/search.h +59 -0
- data/modules/emscripten/system/include/libc/setjmp.h +20 -0
- data/modules/emscripten/system/include/libc/signal.h +30 -0
- data/modules/emscripten/system/include/libc/stdarg.h +50 -0
- data/modules/emscripten/system/include/libc/stddef.h +64 -0
- data/modules/emscripten/system/include/libc/stdint.h +493 -0
- data/modules/emscripten/system/include/libc/stdio.h +694 -0
- data/modules/emscripten/system/include/libc/stdlib.h +230 -0
- data/modules/emscripten/system/include/libc/string.h +105 -0
- data/modules/emscripten/system/include/libc/strings.h +35 -0
- data/modules/emscripten/system/include/libc/sys/_default_fcntl.h +223 -0
- data/modules/emscripten/system/include/libc/sys/_types.h +93 -0
- data/modules/emscripten/system/include/libc/sys/cdefs.h +123 -0
- data/modules/emscripten/system/include/libc/sys/config.h +255 -0
- data/modules/emscripten/system/include/libc/sys/custom_file.h +2 -0
- data/modules/emscripten/system/include/libc/sys/dir.h +10 -0
- data/modules/emscripten/system/include/libc/sys/dirent.h +58 -0
- data/modules/emscripten/system/include/libc/sys/errno.h +190 -0
- data/modules/emscripten/system/include/libc/sys/fcntl.h +4 -0
- data/modules/emscripten/system/include/libc/sys/features.h +212 -0
- data/modules/emscripten/system/include/libc/sys/file.h +2 -0
- data/modules/emscripten/system/include/libc/sys/iconvnls.h +77 -0
- data/modules/emscripten/system/include/libc/sys/lock.h +24 -0
- data/modules/emscripten/system/include/libc/sys/param.h +25 -0
- data/modules/emscripten/system/include/libc/sys/queue.h +471 -0
- data/modules/emscripten/system/include/libc/sys/reent.h +843 -0
- data/modules/emscripten/system/include/libc/sys/resource.h +59 -0
- data/modules/emscripten/system/include/libc/sys/sched.h +67 -0
- data/modules/emscripten/system/include/libc/sys/signal.h +314 -0
- data/modules/emscripten/system/include/libc/sys/stat.h +222 -0
- data/modules/emscripten/system/include/libc/sys/stdio.h +27 -0
- data/modules/emscripten/system/include/libc/sys/string.h +2 -0
- data/modules/emscripten/system/include/libc/sys/syslimits.h +65 -0
- data/modules/emscripten/system/include/libc/sys/termios.h +280 -0
- data/modules/emscripten/system/include/libc/sys/time.h +85 -0
- data/modules/emscripten/system/include/libc/sys/timeb.h +39 -0
- data/modules/emscripten/system/include/libc/sys/times.h +28 -0
- data/modules/emscripten/system/include/libc/sys/ttydefaults.h +97 -0
- data/modules/emscripten/system/include/libc/sys/types.h +481 -0
- data/modules/emscripten/system/include/libc/sys/unistd.h +514 -0
- data/modules/emscripten/system/include/libc/sys/utime.h +26 -0
- data/modules/emscripten/system/include/libc/sys/wait.h +40 -0
- data/modules/emscripten/system/include/libc/tar.h +39 -0
- data/modules/emscripten/system/include/libc/termios.h +7 -0
- data/modules/emscripten/system/include/libc/time.h +273 -0
- data/modules/emscripten/system/include/libc/unctrl.h +46 -0
- data/modules/emscripten/system/include/libc/unistd.h +6 -0
- data/modules/emscripten/system/include/libc/utime.h +12 -0
- data/modules/emscripten/system/include/libc/utmp.h +8 -0
- data/modules/emscripten/system/include/libc/wchar.h +194 -0
- data/modules/emscripten/system/include/libc/wctype.h +47 -0
- data/modules/emscripten/system/include/libc/wordexp.h +53 -0
- data/modules/emscripten/system/include/libcxx/CREDITS.TXT +91 -0
- data/modules/emscripten/system/include/libcxx/LICENSE.txt +76 -0
- data/modules/emscripten/system/include/libcxx/__bit_reference +1268 -0
- data/modules/emscripten/system/include/libcxx/__config +485 -0
- data/modules/emscripten/system/include/libcxx/__debug +193 -0
- data/modules/emscripten/system/include/libcxx/__functional_03 +2130 -0
- data/modules/emscripten/system/include/libcxx/__functional_base +437 -0
- data/modules/emscripten/system/include/libcxx/__functional_base_03 +1087 -0
- data/modules/emscripten/system/include/libcxx/__hash_table +1945 -0
- data/modules/emscripten/system/include/libcxx/__locale +1435 -0
- data/modules/emscripten/system/include/libcxx/__mutex_base +438 -0
- data/modules/emscripten/system/include/libcxx/__split_buffer +654 -0
- data/modules/emscripten/system/include/libcxx/__sso_allocator +77 -0
- data/modules/emscripten/system/include/libcxx/__std_stream +317 -0
- data/modules/emscripten/system/include/libcxx/__tree +2293 -0
- data/modules/emscripten/system/include/libcxx/__tuple +305 -0
- data/modules/emscripten/system/include/libcxx/__tuple_03 +27 -0
- data/modules/emscripten/system/include/libcxx/__undef_min_max +19 -0
- data/modules/emscripten/system/include/libcxx/algorithm +5458 -0
- data/modules/emscripten/system/include/libcxx/array +341 -0
- data/modules/emscripten/system/include/libcxx/atomic +1521 -0
- data/modules/emscripten/system/include/libcxx/bitset +1081 -0
- data/modules/emscripten/system/include/libcxx/cassert +25 -0
- data/modules/emscripten/system/include/libcxx/ccomplex +29 -0
- data/modules/emscripten/system/include/libcxx/cctype +164 -0
- data/modules/emscripten/system/include/libcxx/cerrno +393 -0
- data/modules/emscripten/system/include/libcxx/cfenv +82 -0
- data/modules/emscripten/system/include/libcxx/cfloat +78 -0
- data/modules/emscripten/system/include/libcxx/chrono +898 -0
- data/modules/emscripten/system/include/libcxx/cinttypes +259 -0
- data/modules/emscripten/system/include/libcxx/ciso646 +25 -0
- data/modules/emscripten/system/include/libcxx/climits +48 -0
- data/modules/emscripten/system/include/libcxx/clocale +53 -0
- data/modules/emscripten/system/include/libcxx/cmath +1683 -0
- data/modules/emscripten/system/include/libcxx/codecvt +547 -0
- data/modules/emscripten/system/include/libcxx/complex +1526 -0
- data/modules/emscripten/system/include/libcxx/complex.h +35 -0
- data/modules/emscripten/system/include/libcxx/condition_variable +256 -0
- data/modules/emscripten/system/include/libcxx/csetjmp +52 -0
- data/modules/emscripten/system/include/libcxx/csignal +58 -0
- data/modules/emscripten/system/include/libcxx/cstdarg +48 -0
- data/modules/emscripten/system/include/libcxx/cstdbool +32 -0
- data/modules/emscripten/system/include/libcxx/cstddef +103 -0
- data/modules/emscripten/system/include/libcxx/cstdint +191 -0
- data/modules/emscripten/system/include/libcxx/cstdio +175 -0
- data/modules/emscripten/system/include/libcxx/cstdlib +172 -0
- data/modules/emscripten/system/include/libcxx/cstring +112 -0
- data/modules/emscripten/system/include/libcxx/ctgmath +29 -0
- data/modules/emscripten/system/include/libcxx/ctime +72 -0
- data/modules/emscripten/system/include/libcxx/cwchar +208 -0
- data/modules/emscripten/system/include/libcxx/cwctype +213 -0
- data/modules/emscripten/system/include/libcxx/deque +2846 -0
- data/modules/emscripten/system/include/libcxx/exception +250 -0
- data/modules/emscripten/system/include/libcxx/ext/__hash +46 -0
- data/modules/emscripten/system/include/libcxx/ext/hash_map +1003 -0
- data/modules/emscripten/system/include/libcxx/ext/hash_set +657 -0
- data/modules/emscripten/system/include/libcxx/forward_list +1636 -0
- data/modules/emscripten/system/include/libcxx/fstream +1415 -0
- data/modules/emscripten/system/include/libcxx/functional +2063 -0
- data/modules/emscripten/system/include/libcxx/future +2505 -0
- data/modules/emscripten/system/include/libcxx/initializer_list +105 -0
- data/modules/emscripten/system/include/libcxx/iomanip +504 -0
- data/modules/emscripten/system/include/libcxx/ios +988 -0
- data/modules/emscripten/system/include/libcxx/iosfwd +194 -0
- data/modules/emscripten/system/include/libcxx/iostream +60 -0
- data/modules/emscripten/system/include/libcxx/istream +1713 -0
- data/modules/emscripten/system/include/libcxx/iterator +1869 -0
- data/modules/emscripten/system/include/libcxx/limits +809 -0
- data/modules/emscripten/system/include/libcxx/list +2275 -0
- data/modules/emscripten/system/include/libcxx/locale +4591 -0
- data/modules/emscripten/system/include/libcxx/map +1924 -0
- data/modules/emscripten/system/include/libcxx/memory +5437 -0
- data/modules/emscripten/system/include/libcxx/mutex +566 -0
- data/modules/emscripten/system/include/libcxx/new +117 -0
- data/modules/emscripten/system/include/libcxx/numeric +197 -0
- data/modules/emscripten/system/include/libcxx/ostream +1286 -0
- data/modules/emscripten/system/include/libcxx/queue +717 -0
- data/modules/emscripten/system/include/libcxx/random +6750 -0
- data/modules/emscripten/system/include/libcxx/ratio +487 -0
- data/modules/emscripten/system/include/libcxx/readme.txt +1 -0
- data/modules/emscripten/system/include/libcxx/regex +6439 -0
- data/modules/emscripten/system/include/libcxx/scoped_allocator +578 -0
- data/modules/emscripten/system/include/libcxx/set +1025 -0
- data/modules/emscripten/system/include/libcxx/sstream +888 -0
- data/modules/emscripten/system/include/libcxx/stack +292 -0
- data/modules/emscripten/system/include/libcxx/stdexcept +162 -0
- data/modules/emscripten/system/include/libcxx/streambuf +564 -0
- data/modules/emscripten/system/include/libcxx/string +3987 -0
- data/modules/emscripten/system/include/libcxx/strstream +400 -0
- data/modules/emscripten/system/include/libcxx/support/solaris/floatingpoint.h +5 -0
- data/modules/emscripten/system/include/libcxx/support/solaris/wchar.h +38 -0
- data/modules/emscripten/system/include/libcxx/support/solaris/xlocale.h +146 -0
- data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +79 -0
- data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +116 -0
- data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +113 -0
- data/modules/emscripten/system/include/libcxx/support/win32/support.h +115 -0
- data/modules/emscripten/system/include/libcxx/system_error +636 -0
- data/modules/emscripten/system/include/libcxx/tgmath.h +29 -0
- data/modules/emscripten/system/include/libcxx/thread +459 -0
- data/modules/emscripten/system/include/libcxx/tuple +1092 -0
- data/modules/emscripten/system/include/libcxx/type_traits +3040 -0
- data/modules/emscripten/system/include/libcxx/typeindex +103 -0
- data/modules/emscripten/system/include/libcxx/typeinfo +124 -0
- data/modules/emscripten/system/include/libcxx/unordered_map +1864 -0
- data/modules/emscripten/system/include/libcxx/unordered_set +1144 -0
- data/modules/emscripten/system/include/libcxx/utility +583 -0
- data/modules/emscripten/system/include/libcxx/valarray +4779 -0
- data/modules/emscripten/system/include/libcxx/vector +3228 -0
- data/modules/emscripten/system/include/memory.h +10 -0
- data/modules/emscripten/system/include/mntent.h +23 -0
- data/modules/emscripten/system/include/net/arpa/inet.h +32 -0
- data/modules/emscripten/system/include/net/arpa/nameser.h +535 -0
- data/modules/emscripten/system/include/net/arpa/nameser_compat.h +187 -0
- data/modules/emscripten/system/include/net/if.h +87 -0
- data/modules/emscripten/system/include/net/netinet/in.h +166 -0
- data/modules/emscripten/system/include/net/netinet/tcp.h +246 -0
- data/modules/emscripten/system/include/net/resolv.h +389 -0
- data/modules/emscripten/system/include/netdb.h +94 -0
- data/modules/emscripten/system/include/nl_types.h +19 -0
- data/modules/emscripten/system/include/poll.h +3 -0
- data/modules/emscripten/system/include/pty.h +6 -0
- data/modules/emscripten/system/include/semaphore.h +31 -0
- data/modules/emscripten/system/include/spawn.h +105 -0
- data/modules/emscripten/system/include/stdbool.h +16 -0
- data/modules/emscripten/system/include/sys/bitypes.h +3 -0
- data/modules/emscripten/system/include/sys/io.h +14 -0
- data/modules/emscripten/system/include/sys/ioctl.h +26 -0
- data/modules/emscripten/system/include/sys/poll.h +31 -0
- data/modules/emscripten/system/include/sys/select.h +14 -0
- data/modules/emscripten/system/include/sys/socket.h +101 -0
- data/modules/emscripten/system/include/sys/socketvar.h +3 -0
- data/modules/emscripten/system/include/sys/statvfs.h +32 -0
- data/modules/emscripten/system/include/sys/sysctl.h +14 -0
- data/modules/emscripten/system/include/sys/uio.h +22 -0
- data/modules/emscripten/system/include/sys/un.h +66 -0
- data/modules/emscripten/system/include/sysexits.h +108 -0
- data/modules/emscripten/system/include/unwind.h +154 -0
- data/modules/emscripten/system/include/xlocale.h +47 -0
- data/modules/emscripten/system/include/zconf.h +428 -0
- data/modules/emscripten/system/include/zlib.h +1613 -0
- data/modules/emscripten/system/lib/compiler-rt/LICENSE.TXT +97 -0
- data/modules/emscripten/system/lib/compiler-rt/divdi3.c +47 -0
- data/modules/emscripten/system/lib/compiler-rt/int_endianness.h +116 -0
- data/modules/emscripten/system/lib/compiler-rt/int_lib.h +46 -0
- data/modules/emscripten/system/lib/compiler-rt/int_math.h +67 -0
- data/modules/emscripten/system/lib/compiler-rt/int_types.h +140 -0
- data/modules/emscripten/system/lib/compiler-rt/int_util.h +29 -0
- data/modules/emscripten/system/lib/compiler-rt/muldi3.c +56 -0
- data/modules/emscripten/system/lib/compiler-rt/readme.txt +20 -0
- data/modules/emscripten/system/lib/compiler-rt/udivdi3.c +36 -0
- data/modules/emscripten/system/lib/compiler-rt/udivmoddi4.c +251 -0
- data/modules/emscripten/system/lib/debugging.cpp +24 -0
- data/modules/emscripten/system/lib/dlmalloc.c +6299 -0
- data/modules/emscripten/system/lib/embind/bind.cpp +63 -0
- data/modules/emscripten/system/lib/libc/gen/err.c +49 -0
- data/modules/emscripten/system/lib/libc/gen/errx.c +49 -0
- data/modules/emscripten/system/lib/libc/gen/verr.c +58 -0
- data/modules/emscripten/system/lib/libc/gen/verrx.c +51 -0
- data/modules/emscripten/system/lib/libc/gen/vwarn.c +55 -0
- data/modules/emscripten/system/lib/libc/gen/vwarnx.c +48 -0
- data/modules/emscripten/system/lib/libc/gen/warn.c +49 -0
- data/modules/emscripten/system/lib/libc/gen/warnx.c +49 -0
- data/modules/emscripten/system/lib/libc/musl/COPYRIGHT +92 -0
- data/modules/emscripten/system/lib/libc/musl/readme.txt +1 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/alpha.h +125 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalnum.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalpha.c +14 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswblank.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswcntrl.c +10 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswctype.c +63 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswdigit.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswgraph.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswlower.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswprint.c +19 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswpunct.c +12 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswspace.c +19 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswupper.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswxdigit.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/nonspacing.h +62 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/punct.h +109 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/towctrans.c +268 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wcswidth.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wctrans.c +16 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wcwidth.c +29 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wide.h +42 -0
- data/modules/emscripten/system/lib/libc/musl/src/internal/libc.c +22 -0
- data/modules/emscripten/system/lib/libc/musl/src/internal/libc.h +71 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/btowc.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.c +38 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.h +22 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mblen.c +17 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrlen.c +18 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrtowc.c +57 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsinit.c +17 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsnrtowcs.c +65 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsrtowcs.c +100 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbstowcs.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbtowc.c +53 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcrtomb.c +38 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsnrtombs.c +52 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsrtombs.c +58 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcstombs.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctob.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctomb.c +18 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcpcpy.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcpncpy.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscat.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcschr.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscmp.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscpy.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscspn.c +10 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsdup.c +11 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcslen.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncat.c +10 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncmp.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncpy.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsnlen.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcspbrk.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsrchr.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsspn.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsstr.c +108 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcstok.c +12 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcswcs.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemchr.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemcmp.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemcpy.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemmove.c +12 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemset.c +9 -0
- data/modules/emscripten/system/lib/libc/stdlib/getopt_long.c +511 -0
- data/modules/emscripten/system/lib/libc/stdlib/strtod.c +305 -0
- data/modules/emscripten/system/lib/libc.symbols +81 -0
- data/modules/emscripten/system/lib/libcextra.symbols +61 -0
- data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +91 -0
- data/modules/emscripten/system/lib/libcxx/LICENSE.txt +76 -0
- data/modules/emscripten/system/lib/libcxx/algorithm.cpp +83 -0
- data/modules/emscripten/system/lib/libcxx/bind.cpp +30 -0
- data/modules/emscripten/system/lib/libcxx/chrono.cpp +132 -0
- data/modules/emscripten/system/lib/libcxx/condition_variable.cpp +81 -0
- data/modules/emscripten/system/lib/libcxx/debug.cpp +504 -0
- data/modules/emscripten/system/lib/libcxx/exception.cpp +226 -0
- data/modules/emscripten/system/lib/libcxx/future.cpp +285 -0
- data/modules/emscripten/system/lib/libcxx/hash.cpp +564 -0
- data/modules/emscripten/system/lib/libcxx/ios.cpp +455 -0
- data/modules/emscripten/system/lib/libcxx/iostream.cpp +68 -0
- data/modules/emscripten/system/lib/libcxx/locale.cpp +6093 -0
- data/modules/emscripten/system/lib/libcxx/memory.cpp +223 -0
- data/modules/emscripten/system/lib/libcxx/mutex.cpp +250 -0
- data/modules/emscripten/system/lib/libcxx/new.cpp +205 -0
- data/modules/emscripten/system/lib/libcxx/random.cpp +48 -0
- data/modules/emscripten/system/lib/libcxx/readme.txt +1 -0
- data/modules/emscripten/system/lib/libcxx/regex.cpp +325 -0
- data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +196 -0
- data/modules/emscripten/system/lib/libcxx/string.cpp +687 -0
- data/modules/emscripten/system/lib/libcxx/strstream.cpp +329 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/README +4 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/mbsnrtowcs.inc +76 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/wcsnrtombs.inc +93 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/xlocale.c +245 -0
- data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +94 -0
- data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +70 -0
- data/modules/emscripten/system/lib/libcxx/symbols +2927 -0
- data/modules/emscripten/system/lib/libcxx/system_error.cpp +201 -0
- data/modules/emscripten/system/lib/libcxx/thread.cpp +208 -0
- data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +60 -0
- data/modules/emscripten/system/lib/libcxx/utility.cpp +17 -0
- data/modules/emscripten/system/lib/libcxx/valarray.cpp +54 -0
- data/modules/emscripten/system/lib/libcxxabi/CREDITS.TXT +38 -0
- data/modules/emscripten/system/lib/libcxxabi/LICENSE.TXT +76 -0
- data/modules/emscripten/system/lib/libcxxabi/include/cxa_demangle.h +167 -0
- data/modules/emscripten/system/lib/libcxxabi/include/cxxabi.h +175 -0
- data/modules/emscripten/system/lib/libcxxabi/lib/buildit +99 -0
- data/modules/emscripten/system/lib/libcxxabi/readme.txt +1 -0
- data/modules/emscripten/system/lib/libcxxabi/src/abort_message.cpp +50 -0
- data/modules/emscripten/system/lib/libcxxabi/src/abort_message.h +33 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_aux_runtime.cpp +34 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_demangle.cpp +11036 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.cpp +622 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.hpp +123 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception_storage.cpp +91 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_guard.cpp +231 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.cpp +125 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.hpp +54 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_new_delete.cpp +242 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_personality.cpp +1055 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_unexpected.cpp +27 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_vector.cpp +367 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_virtual.cpp +31 -0
- data/modules/emscripten/system/lib/libcxxabi/src/exception.cpp +41 -0
- data/modules/emscripten/system/lib/libcxxabi/src/fallback_malloc.ipp +174 -0
- data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.cpp +1146 -0
- data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.h +248 -0
- data/modules/emscripten/system/lib/libcxxabi/src/stdexcept.cpp +169 -0
- data/modules/emscripten/system/lib/libcxxabi/src/typeinfo.cpp +53 -0
- data/modules/emscripten/system/lib/libcxxabi/symbols +236 -0
- data/modules/emscripten/system/lib/sdl.cpp +13 -0
- data/modules/emscripten/system/lib/sdl.symbols +1 -0
- data/modules/emscripten/tests/hello_world.js +92 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/CppHeaderParser.py +2347 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/__init__.py +4 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/doc/CppHeaderParser.html +657 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/SampleClass.h +147 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/readSampleClass.py +74 -0
- data/modules/emscripten/third_party/CppHeaderParser/PKG-INFO +249 -0
- data/modules/emscripten/third_party/CppHeaderParser/README.html +544 -0
- data/modules/emscripten/third_party/CppHeaderParser/README.txt +226 -0
- data/modules/emscripten/third_party/CppHeaderParser/setup.py +43 -0
- data/modules/emscripten/third_party/ansidecl.h +371 -0
- data/modules/emscripten/third_party/closure-compiler/COPYING +202 -0
- data/modules/emscripten/third_party/closure-compiler/README +292 -0
- data/modules/emscripten/third_party/closure-compiler/compiler.jar +0 -0
- data/modules/emscripten/third_party/closure-compiler/readme.txt +3 -0
- data/modules/emscripten/third_party/cp-demangle.h +161 -0
- data/modules/emscripten/third_party/demangle.h +549 -0
- data/modules/emscripten/third_party/demangler.py +49 -0
- data/modules/emscripten/third_party/gcc_demangler.c +4226 -0
- data/modules/emscripten/third_party/gcc_demangler.js +21282 -0
- data/modules/emscripten/third_party/jni/emjvm.cpp +133 -0
- data/modules/emscripten/third_party/jni/emjvm.h +8 -0
- data/modules/emscripten/third_party/jni/emjvm.js +185 -0
- data/modules/emscripten/third_party/jni/jni.h +1154 -0
- data/modules/emscripten/third_party/libiberty.h +634 -0
- data/modules/emscripten/third_party/lzma.js/README.markdown +37 -0
- data/modules/emscripten/third_party/lzma.js/doit.sh +37 -0
- data/modules/emscripten/third_party/lzma.js/lzip/AUTHORS +7 -0
- data/modules/emscripten/third_party/lzma.js/lzip/COPYING +676 -0
- data/modules/emscripten/third_party/lzma.js/lzip/ChangeLog +201 -0
- data/modules/emscripten/third_party/lzma.js/lzip/INSTALL +56 -0
- data/modules/emscripten/third_party/lzma.js/lzip/Makefile +160 -0
- data/modules/emscripten/third_party/lzma.js/lzip/Makefile.in +138 -0
- data/modules/emscripten/third_party/lzma.js/lzip/NEWS +22 -0
- data/modules/emscripten/third_party/lzma.js/lzip/README +77 -0
- data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.cc +204 -0
- data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.h +106 -0
- data/modules/emscripten/third_party/lzma.js/lzip/configure +192 -0
- data/modules/emscripten/third_party/lzma.js/lzip/decoder.cc +252 -0
- data/modules/emscripten/third_party/lzma.js/lzip/decoder.h +268 -0
- data/modules/emscripten/third_party/lzma.js/lzip/encoder.cc +643 -0
- data/modules/emscripten/third_party/lzma.js/lzip/encoder.h +582 -0
- data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.cc +378 -0
- data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.h +171 -0
- data/modules/emscripten/third_party/lzma.js/lzip/lzip.h +264 -0
- data/modules/emscripten/third_party/lzma.js/lzip/main.cc +545 -0
- data/modules/emscripten/third_party/lzma.js/lzma-decoder.js +27 -0
- data/modules/emscripten/third_party/lzma.js/lzma-full.js +27 -0
- data/modules/emscripten/third_party/lzma.js/native_test.sh +5 -0
- data/modules/emscripten/third_party/lzma.js/post.js +13 -0
- data/modules/emscripten/third_party/lzma.js/pre.js +13 -0
- data/modules/emscripten/third_party/lzma.js/test-decoder.js +39 -0
- data/modules/emscripten/third_party/lzma.js/test-full.html +9 -0
- data/modules/emscripten/third_party/lzma.js/test-full.js +78 -0
- data/modules/emscripten/third_party/ply/ANNOUNCE +40 -0
- data/modules/emscripten/third_party/ply/CHANGES +1093 -0
- data/modules/emscripten/third_party/ply/PKG-INFO +22 -0
- data/modules/emscripten/third_party/ply/README +271 -0
- data/modules/emscripten/third_party/ply/TODO +16 -0
- data/modules/emscripten/third_party/ply/doc/internal.html +874 -0
- data/modules/emscripten/third_party/ply/doc/makedoc.py +194 -0
- data/modules/emscripten/third_party/ply/doc/ply.html +3262 -0
- data/modules/emscripten/third_party/ply/example/BASIC/README +79 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basic.py +71 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basiclex.py +74 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basiclog.py +79 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basinterp.py +441 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basparse.py +424 -0
- data/modules/emscripten/third_party/ply/example/BASIC/dim.bas +14 -0
- data/modules/emscripten/third_party/ply/example/BASIC/func.bas +5 -0
- data/modules/emscripten/third_party/ply/example/BASIC/gcd.bas +22 -0
- data/modules/emscripten/third_party/ply/example/BASIC/gosub.bas +13 -0
- data/modules/emscripten/third_party/ply/example/BASIC/hello.bas +4 -0
- data/modules/emscripten/third_party/ply/example/BASIC/linear.bas +17 -0
- data/modules/emscripten/third_party/ply/example/BASIC/maxsin.bas +12 -0
- data/modules/emscripten/third_party/ply/example/BASIC/powers.bas +13 -0
- data/modules/emscripten/third_party/ply/example/BASIC/rand.bas +4 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sales.bas +20 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sears.bas +18 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sqrt1.bas +5 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sqrt2.bas +4 -0
- data/modules/emscripten/third_party/ply/example/GardenSnake/GardenSnake.py +709 -0
- data/modules/emscripten/third_party/ply/example/GardenSnake/README +5 -0
- data/modules/emscripten/third_party/ply/example/README +10 -0
- data/modules/emscripten/third_party/ply/example/ansic/README +2 -0
- data/modules/emscripten/third_party/ply/example/ansic/clex.py +164 -0
- data/modules/emscripten/third_party/ply/example/ansic/cparse.py +863 -0
- data/modules/emscripten/third_party/ply/example/calc/calc.py +107 -0
- data/modules/emscripten/third_party/ply/example/calcdebug/calc.py +113 -0
- data/modules/emscripten/third_party/ply/example/classcalc/calc.py +157 -0
- data/modules/emscripten/third_party/ply/example/cleanup.sh +2 -0
- data/modules/emscripten/third_party/ply/example/closurecalc/calc.py +130 -0
- data/modules/emscripten/third_party/ply/example/hedit/hedit.py +48 -0
- data/modules/emscripten/third_party/ply/example/newclasscalc/calc.py +160 -0
- data/modules/emscripten/third_party/ply/example/optcalc/README +9 -0
- data/modules/emscripten/third_party/ply/example/optcalc/calc.py +119 -0
- data/modules/emscripten/third_party/ply/example/unicalc/calc.py +117 -0
- data/modules/emscripten/third_party/ply/example/yply/README +41 -0
- data/modules/emscripten/third_party/ply/example/yply/ylex.py +112 -0
- data/modules/emscripten/third_party/ply/example/yply/yparse.py +217 -0
- data/modules/emscripten/third_party/ply/example/yply/yply.py +53 -0
- data/modules/emscripten/third_party/ply/ply/__init__.py +4 -0
- data/modules/emscripten/third_party/ply/ply/cpp.py +898 -0
- data/modules/emscripten/third_party/ply/ply/ctokens.py +133 -0
- data/modules/emscripten/third_party/ply/ply/lex.py +1058 -0
- data/modules/emscripten/third_party/ply/ply/yacc.py +3276 -0
- data/modules/emscripten/third_party/ply/setup.py +31 -0
- data/modules/emscripten/third_party/ply/test/README +7 -0
- data/modules/emscripten/third_party/ply/test/calclex.py +49 -0
- data/modules/emscripten/third_party/ply/test/cleanup.sh +4 -0
- data/modules/emscripten/third_party/ply/test/lex_closure.py +54 -0
- data/modules/emscripten/third_party/ply/test/lex_doc1.py +26 -0
- data/modules/emscripten/third_party/ply/test/lex_dup1.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_dup2.py +33 -0
- data/modules/emscripten/third_party/ply/test/lex_dup3.py +31 -0
- data/modules/emscripten/third_party/ply/test/lex_empty.py +20 -0
- data/modules/emscripten/third_party/ply/test/lex_error1.py +24 -0
- data/modules/emscripten/third_party/ply/test/lex_error2.py +26 -0
- data/modules/emscripten/third_party/ply/test/lex_error3.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_error4.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_hedit.py +47 -0
- data/modules/emscripten/third_party/ply/test/lex_ignore.py +31 -0
- data/modules/emscripten/third_party/ply/test/lex_ignore2.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_literal1.py +25 -0
- data/modules/emscripten/third_party/ply/test/lex_literal2.py +25 -0
- data/modules/emscripten/third_party/ply/test/lex_many_tokens.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_module.py +10 -0
- data/modules/emscripten/third_party/ply/test/lex_module_import.py +42 -0
- data/modules/emscripten/third_party/ply/test/lex_object.py +55 -0
- data/modules/emscripten/third_party/ply/test/lex_opt_alias.py +54 -0
- data/modules/emscripten/third_party/ply/test/lex_optimize.py +50 -0
- data/modules/emscripten/third_party/ply/test/lex_optimize2.py +50 -0
- data/modules/emscripten/third_party/ply/test/lex_optimize3.py +52 -0
- data/modules/emscripten/third_party/ply/test/lex_re1.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_re2.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_re3.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_rule1.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_rule2.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_rule3.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_state1.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state2.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state3.py +42 -0
- data/modules/emscripten/third_party/ply/test/lex_state4.py +41 -0
- data/modules/emscripten/third_party/ply/test/lex_state5.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state_noerror.py +39 -0
- data/modules/emscripten/third_party/ply/test/lex_state_norule.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state_try.py +45 -0
- data/modules/emscripten/third_party/ply/test/lex_token1.py +19 -0
- data/modules/emscripten/third_party/ply/test/lex_token2.py +22 -0
- data/modules/emscripten/third_party/ply/test/lex_token3.py +24 -0
- data/modules/emscripten/third_party/ply/test/lex_token4.py +26 -0
- data/modules/emscripten/third_party/ply/test/lex_token5.py +31 -0
- data/modules/emscripten/third_party/ply/test/lex_token_dup.py +29 -0
- data/modules/emscripten/third_party/ply/test/testlex.py +606 -0
- data/modules/emscripten/third_party/ply/test/testyacc.py +347 -0
- data/modules/emscripten/third_party/ply/test/yacc_badargs.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badid.py +77 -0
- data/modules/emscripten/third_party/ply/test/yacc_badprec.py +64 -0
- data/modules/emscripten/third_party/ply/test/yacc_badprec2.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badprec3.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badrule.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badtok.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_dup.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_error1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_error2.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_error3.py +67 -0
- data/modules/emscripten/third_party/ply/test/yacc_error4.py +72 -0
- data/modules/emscripten/third_party/ply/test/yacc_inf.py +56 -0
- data/modules/emscripten/third_party/ply/test/yacc_literal.py +69 -0
- data/modules/emscripten/third_party/ply/test/yacc_misplaced.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_missing1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_nested.py +33 -0
- data/modules/emscripten/third_party/ply/test/yacc_nodoc.py +67 -0
- data/modules/emscripten/third_party/ply/test/yacc_noerror.py +66 -0
- data/modules/emscripten/third_party/ply/test/yacc_nop.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_notfunc.py +66 -0
- data/modules/emscripten/third_party/ply/test/yacc_notok.py +67 -0
- data/modules/emscripten/third_party/ply/test/yacc_prec1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_rr.py +72 -0
- data/modules/emscripten/third_party/ply/test/yacc_rr_unused.py +30 -0
- data/modules/emscripten/third_party/ply/test/yacc_simple.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_sr.py +63 -0
- data/modules/emscripten/third_party/ply/test/yacc_term1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_unused.py +77 -0
- data/modules/emscripten/third_party/ply/test/yacc_unused_rule.py +72 -0
- data/modules/emscripten/third_party/ply/test/yacc_uprec.py +63 -0
- data/modules/emscripten/third_party/ply/test/yacc_uprec2.py +63 -0
- data/modules/emscripten/third_party/readme.txt +7 -0
- data/modules/emscripten/third_party/websockify/CHANGES.txt +23 -0
- data/modules/emscripten/third_party/websockify/LICENSE.txt +16 -0
- data/modules/emscripten/third_party/websockify/MANIFEST.in +1 -0
- data/modules/emscripten/third_party/websockify/Makefile +11 -0
- data/modules/emscripten/third_party/websockify/README.md +168 -0
- data/modules/emscripten/third_party/websockify/Windows/Windows Service Readme.txt +39 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Program.cs +24 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs +61 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.cs +19 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.resx +129 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs +36 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.Designer.cs +37 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.cs +41 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.csproj +75 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.sln +20 -0
- data/modules/emscripten/third_party/websockify/docs/LICENSE.GPL-3 +621 -0
- data/modules/emscripten/third_party/websockify/docs/LICENSE.LGPL-3 +165 -0
- data/modules/emscripten/third_party/websockify/docs/LICENSE.MPL-2.0 +373 -0
- data/modules/emscripten/third_party/websockify/docs/TODO +9 -0
- data/modules/emscripten/third_party/websockify/docs/flash_policy.txt +4 -0
- data/modules/emscripten/third_party/websockify/docs/latency_results.txt +114 -0
- data/modules/emscripten/third_party/websockify/docs/notes +17 -0
- data/modules/emscripten/third_party/websockify/docs/release.txt +9 -0
- data/modules/emscripten/third_party/websockify/docs/websockify.1 +110 -0
- data/modules/emscripten/third_party/websockify/include/VT100.js +919 -0
- data/modules/emscripten/third_party/websockify/include/base64.js +114 -0
- data/modules/emscripten/third_party/websockify/include/keysym.js +99 -0
- data/modules/emscripten/third_party/websockify/include/util.js +359 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/README.txt +109 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/WebSocketMain.swf +0 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/swfobject.js +4 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/web_socket.js +391 -0
- data/modules/emscripten/third_party/websockify/include/websock.js +422 -0
- data/modules/emscripten/third_party/websockify/include/webutil.js +216 -0
- data/modules/emscripten/third_party/websockify/include/wsirc.js +235 -0
- data/modules/emscripten/third_party/websockify/include/wstelnet.js +335 -0
- data/modules/emscripten/third_party/websockify/other/Makefile +14 -0
- data/modules/emscripten/third_party/websockify/other/README.md +51 -0
- data/modules/emscripten/third_party/websockify/other/launch.sh +108 -0
- data/modules/emscripten/third_party/websockify/other/project.clj +13 -0
- data/modules/emscripten/third_party/websockify/other/websocket.c +802 -0
- data/modules/emscripten/third_party/websockify/other/websocket.h +84 -0
- data/modules/emscripten/third_party/websockify/other/websocket.rb +456 -0
- data/modules/emscripten/third_party/websockify/other/websockify.c +385 -0
- data/modules/emscripten/third_party/websockify/other/websockify.clj +233 -0
- data/modules/emscripten/third_party/websockify/other/websockify.js +196 -0
- data/modules/emscripten/third_party/websockify/other/websockify.rb +171 -0
- data/modules/emscripten/third_party/websockify/other/wswrap +22 -0
- data/modules/emscripten/third_party/websockify/rebind +18 -0
- data/modules/emscripten/third_party/websockify/rebind.c +94 -0
- data/modules/emscripten/third_party/websockify/run +5 -0
- data/modules/emscripten/third_party/websockify/setup.py +30 -0
- data/modules/emscripten/third_party/websockify/tests/b64_vs_utf8.py +29 -0
- data/modules/emscripten/third_party/websockify/tests/base64.html +91 -0
- data/modules/emscripten/third_party/websockify/tests/base64.js +12 -0
- data/modules/emscripten/third_party/websockify/tests/echo.html +148 -0
- data/modules/emscripten/third_party/websockify/tests/echo.py +75 -0
- data/modules/emscripten/third_party/websockify/tests/echo.rb +62 -0
- data/modules/emscripten/third_party/websockify/tests/latency.html +290 -0
- data/modules/emscripten/third_party/websockify/tests/latency.py +75 -0
- data/modules/emscripten/third_party/websockify/tests/load.html +250 -0
- data/modules/emscripten/third_party/websockify/tests/load.py +167 -0
- data/modules/emscripten/third_party/websockify/tests/plain_echo.html +168 -0
- data/modules/emscripten/third_party/websockify/tests/simple.html +68 -0
- data/modules/emscripten/third_party/websockify/tests/utf8-list.py +22 -0
- data/modules/emscripten/third_party/websockify/websockify/__init__.py +2 -0
- data/modules/emscripten/third_party/websockify/websockify/websocket.py +982 -0
- data/modules/emscripten/third_party/websockify/websockify/websocketproxy.py +393 -0
- data/modules/emscripten/third_party/websockify/websockify.py +5 -0
- data/modules/emscripten/third_party/websockify/wsirc.html +99 -0
- data/modules/emscripten/third_party/websockify/wstelnet.html +74 -0
- data/modules/emscripten/tools/__init__.py +0 -0
- data/modules/emscripten/tools/__init__.pyc +0 -0
- data/modules/emscripten/tools/autodebugger.py +289 -0
- data/modules/emscripten/tools/autodebugger_c.py +37 -0
- data/modules/emscripten/tools/autodebugger_indenter.py +18 -0
- data/modules/emscripten/tools/autodebugger_js.py +47 -0
- data/modules/emscripten/tools/autodediffer.py +60 -0
- data/modules/emscripten/tools/bindings_generator.py +832 -0
- data/modules/emscripten/tools/bisect_pair.py +88 -0
- data/modules/emscripten/tools/cache.py +198 -0
- data/modules/emscripten/tools/cache.pyc +0 -0
- data/modules/emscripten/tools/clean_webconsole.py +34 -0
- data/modules/emscripten/tools/crunch-worker.js +124 -0
- data/modules/emscripten/tools/diff_autodebugger.py +15 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +5129 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +6861 -0
- data/modules/emscripten/tools/eliminator/eliminator-test-output.js +6122 -0
- data/modules/emscripten/tools/eliminator/eliminator-test.js +8856 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.html +888 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.org +463 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/bin/uglifyjs +317 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/docstyle.css +75 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/object-ast.js +75 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js +1363 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/process.js +2005 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/squeeze-more.js +51 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/package.json +22 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/beautify.js +28 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/testparser.js +402 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/mangle.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/with.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js +16 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/mangle.js +5 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/with.js +2 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/scripts.js +55 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/hoist.js +33 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument.js +97 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument2.js +138 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/test.js +16 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/uglify-js.js +17 -0
- data/modules/emscripten/tools/eliminator/safe-eliminator-test-output.js +85 -0
- data/modules/emscripten/tools/eliminator/safe-eliminator-test.js +103 -0
- data/modules/emscripten/tools/emconfiguren.py +19 -0
- data/modules/emscripten/tools/emmaken.py +230 -0
- data/modules/emscripten/tools/emmakenxx.py +18 -0
- data/modules/emscripten/tools/exec_llvm.py +50 -0
- data/modules/emscripten/tools/file2json.py +49 -0
- data/modules/emscripten/tools/file_packager.py +649 -0
- data/modules/emscripten/tools/find_bigfuncs.py +23 -0
- data/modules/emscripten/tools/find_bigis.py +18 -0
- data/modules/emscripten/tools/fix_closure.py +88 -0
- data/modules/emscripten/tools/ie7_fix.py +14 -0
- data/modules/emscripten/tools/js-optimizer.js +3440 -0
- data/modules/emscripten/tools/js_optimizer.py +341 -0
- data/modules/emscripten/tools/js_optimizer.pyc +0 -0
- data/modules/emscripten/tools/jsrun.py +27 -0
- data/modules/emscripten/tools/jsrun.pyc +0 -0
- data/modules/emscripten/tools/ll-strip.py +56 -0
- data/modules/emscripten/tools/make_file.py +19 -0
- data/modules/emscripten/tools/make_minigzip.py +13 -0
- data/modules/emscripten/tools/namespacer.py +95 -0
- data/modules/emscripten/tools/nativize_llvm.py +34 -0
- data/modules/emscripten/tools/node_modules/source-map/CHANGELOG.md +58 -0
- data/modules/emscripten/tools/node_modules/source-map/LICENSE +28 -0
- data/modules/emscripten/tools/node_modules/source-map/Makefile.dryice.js +166 -0
- data/modules/emscripten/tools/node_modules/source-map/README.md +347 -0
- data/modules/emscripten/tools/node_modules/source-map/build/assert-shim.js +56 -0
- data/modules/emscripten/tools/node_modules/source-map/build/mini-require.js +152 -0
- data/modules/emscripten/tools/node_modules/source-map/build/prefix-source-map.jsm +20 -0
- data/modules/emscripten/tools/node_modules/source-map/build/prefix-utils.jsm +18 -0
- data/modules/emscripten/tools/node_modules/source-map/build/suffix-browser.js +8 -0
- data/modules/emscripten/tools/node_modules/source-map/build/suffix-source-map.jsm +6 -0
- data/modules/emscripten/tools/node_modules/source-map/build/suffix-utils.jsm +21 -0
- data/modules/emscripten/tools/node_modules/source-map/build/test-prefix.js +8 -0
- data/modules/emscripten/tools/node_modules/source-map/build/test-suffix.js +3 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/array-set.js +96 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js +42 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/binary-search.js +81 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-consumer.js +430 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-generator.js +381 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-node.js +353 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/util.js +117 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map.js +8 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/README.md +119 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/package.json +33 -0
- data/modules/emscripten/tools/node_modules/source-map/package.json +74 -0
- data/modules/emscripten/tools/node_modules/source-map/test/run-tests.js +73 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-api.js +26 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-array-set.js +71 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64.js +35 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-consumer.js +306 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-generator.js +391 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-node.js +282 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/util.js +152 -0
- data/modules/emscripten/tools/reproduceriter.js +216 -0
- data/modules/emscripten/tools/reproduceriter.py +160 -0
- data/modules/emscripten/tools/response_file.py +28 -0
- data/modules/emscripten/tools/response_file.pyc +0 -0
- data/modules/emscripten/tools/scan_js.py +20 -0
- data/modules/emscripten/tools/scan_ll.py +18 -0
- data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/__init__.py +3 -0
- data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/emscripten.py +46 -0
- data/modules/emscripten/tools/settings_template_readonly.py +47 -0
- data/modules/emscripten/tools/shared.py +1437 -0
- data/modules/emscripten/tools/shared.pyc +0 -0
- data/modules/emscripten/tools/source-maps/sourcemap2json.js +15 -0
- data/modules/emscripten/tools/source-maps/sourcemapper.js +177 -0
- data/modules/emscripten/tools/split.py +97 -0
- data/modules/emscripten/tools/tempfiles.py +40 -0
- data/modules/emscripten/tools/tempfiles.pyc +0 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-last-output.js +75 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-last.js +91 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline-output.js +570 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline.js +606 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +540 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-pre.js +550 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs-min-output.js +36 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs-min.js +37 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs-output.js +106 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs.js +110 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-relocate-output.js +9 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-relocate.js +12 -0
- data/modules/emscripten/tools/test-js-optimizer-output.js +291 -0
- data/modules/emscripten/tools/test-js-optimizer-regs-output.js +232 -0
- data/modules/emscripten/tools/test-js-optimizer-regs.js +237 -0
- data/modules/emscripten/tools/test-js-optimizer-t2-output.js +91 -0
- data/modules/emscripten/tools/test-js-optimizer-t2.js +92 -0
- data/modules/emscripten/tools/test-js-optimizer-t2c-output.js +17 -0
- data/modules/emscripten/tools/test-js-optimizer-t2c.js +18 -0
- data/modules/emscripten/tools/test-js-optimizer-t3-output.js +49 -0
- data/modules/emscripten/tools/test-js-optimizer-t3.js +50 -0
- data/modules/emscripten/tools/test-js-optimizer.js +401 -0
- data/modules/mruby/AUTHORS +18 -0
- data/modules/mruby/CONTRIBUTING.md +65 -0
- data/modules/mruby/ChangeLog +15 -0
- data/modules/mruby/INSTALL +29 -0
- data/modules/mruby/LEGAL +6 -0
- data/modules/mruby/MITL +20 -0
- data/modules/mruby/Makefile +18 -0
- data/modules/mruby/NEWS +13 -0
- data/modules/mruby/README.md +116 -0
- data/modules/mruby/Rakefile +114 -0
- data/modules/mruby/TODO +11 -0
- data/modules/mruby/benchmark/ao-render.rb +315 -0
- data/modules/mruby/benchmark/bm_so_lists.rb +47 -0
- data/modules/mruby/benchmark/fib39.rb +8 -0
- data/modules/mruby/build_config.rb +88 -0
- data/modules/mruby/doc/compile/README.md +376 -0
- data/modules/mruby/doc/mrbgems/README.md +254 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/README.md +4 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake +23 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +5 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +20 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/test/example.rb +7 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/README.md +4 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/mrbgem.rake +23 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/src/example.c +20 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/test/example.c +7 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/test/example.rb +3 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/README.md +4 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/mrbgem.rake +23 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +5 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/test/example.rb +3 -0
- data/modules/mruby/examples/targets/ArduinoDue.rb +65 -0
- data/modules/mruby/examples/targets/chipKitMax32.rb +68 -0
- data/modules/mruby/include/mrbconf.h +87 -0
- data/modules/mruby/include/mruby/array.h +63 -0
- data/modules/mruby/include/mruby/class.h +75 -0
- data/modules/mruby/include/mruby/compile.h +176 -0
- data/modules/mruby/include/mruby/data.h +53 -0
- data/modules/mruby/include/mruby/dump.h +151 -0
- data/modules/mruby/include/mruby/gc.h +17 -0
- data/modules/mruby/include/mruby/hash.h +54 -0
- data/modules/mruby/include/mruby/irep.h +40 -0
- data/modules/mruby/include/mruby/khash.h +257 -0
- data/modules/mruby/include/mruby/numeric.h +32 -0
- data/modules/mruby/include/mruby/proc.h +62 -0
- data/modules/mruby/include/mruby/range.h +35 -0
- data/modules/mruby/include/mruby/string.h +78 -0
- data/modules/mruby/include/mruby/value.h +483 -0
- data/modules/mruby/include/mruby/variable.h +78 -0
- data/modules/mruby/include/mruby.h +388 -0
- data/modules/mruby/minirake +477 -0
- data/modules/mruby/mrbgems/default.gembox +61 -0
- data/modules/mruby/mrbgems/full-core.gembox +9 -0
- data/modules/mruby/mrbgems/mruby-array-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +204 -0
- data/modules/mruby/mrbgems/mruby-array-ext/src/array.c +140 -0
- data/modules/mruby/mrbgems/mruby-array-ext/test/array.rb +109 -0
- data/modules/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +5 -0
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +365 -0
- data/modules/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +5 -0
- data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +243 -0
- data/modules/mruby/mrbgems/mruby-enum-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +164 -0
- data/modules/mruby/mrbgems/mruby-enum-ext/test/enum.rb +44 -0
- data/modules/mruby/mrbgems/mruby-eval/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-eval/src/eval.c +23 -0
- data/modules/mruby/mrbgems/mruby-fiber/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +251 -0
- data/modules/mruby/mrbgems/mruby-fiber/test/fiber.rb +64 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +13 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +62 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/test/hash.rb +26 -0
- data/modules/mruby/mrbgems/mruby-math/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-math/src/math.c +685 -0
- data/modules/mruby/mrbgems/mruby-math/test/math.rb +136 -0
- data/modules/mruby/mrbgems/mruby-numeric-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +31 -0
- data/modules/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +10 -0
- data/modules/mruby/mrbgems/mruby-object-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-object-ext/src/object.c +108 -0
- data/modules/mruby/mrbgems/mruby-object-ext/test/nil.rb +11 -0
- data/modules/mruby/mrbgems/mruby-object-ext/test/object.rb +9 -0
- data/modules/mruby/mrbgems/mruby-objectspace/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +117 -0
- data/modules/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +38 -0
- data/modules/mruby/mrbgems/mruby-print/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-print/mrblib/print.rb +64 -0
- data/modules/mruby/mrbgems/mruby-print/src/print.c +44 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/mrblib/proc.rb +40 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/src/proc.c +97 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/test/proc.rb +41 -0
- data/modules/mruby/mrbgems/mruby-random/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.c +193 -0
- data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.h +48 -0
- data/modules/mruby/mrbgems/mruby-random/src/random.c +231 -0
- data/modules/mruby/mrbgems/mruby-random/src/random.h +12 -0
- data/modules/mruby/mrbgems/mruby-random/test/random.rb +32 -0
- data/modules/mruby/mrbgems/mruby-range-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-range-ext/src/range.c +141 -0
- data/modules/mruby/mrbgems/mruby-range-ext/test/range.rb +20 -0
- data/modules/mruby/mrbgems/mruby-sprintf/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-sprintf/src/kernel.c +30 -0
- data/modules/mruby/mrbgems/mruby-sprintf/src/sprintf.c +1102 -0
- data/modules/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +3 -0
- data/modules/mruby/mrbgems/mruby-string-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +52 -0
- data/modules/mruby/mrbgems/mruby-string-ext/src/string.c +175 -0
- data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +112 -0
- data/modules/mruby/mrbgems/mruby-struct/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-struct/mrblib/struct.rb +50 -0
- data/modules/mruby/mrbgems/mruby-struct/src/struct.c +818 -0
- data/modules/mruby/mrbgems/mruby-struct/test/struct.rb +77 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +9 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +55 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +12 -0
- data/modules/mruby/mrbgems/mruby-time/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-time/src/time.c +749 -0
- data/modules/mruby/mrbgems/mruby-time/test/time.rb +201 -0
- data/modules/mruby/mrbgems/mruby-toplevel-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb +11 -0
- data/modules/mruby/mrbgems/mruby-toplevel-ext/test/toplevel.rb +24 -0
- data/modules/mruby/mrblib/array.rb +111 -0
- data/modules/mruby/mrblib/class.rb +26 -0
- data/modules/mruby/mrblib/compar.rb +104 -0
- data/modules/mruby/mrblib/enum.rb +398 -0
- data/modules/mruby/mrblib/error.rb +66 -0
- data/modules/mruby/mrblib/hash.rb +193 -0
- data/modules/mruby/mrblib/init_mrblib.c +14 -0
- data/modules/mruby/mrblib/kernel.rb +46 -0
- data/modules/mruby/mrblib/mrblib.rake +18 -0
- data/modules/mruby/mrblib/numeric.rb +101 -0
- data/modules/mruby/mrblib/print.rb +18 -0
- data/modules/mruby/mrblib/range.rb +40 -0
- data/modules/mruby/mrblib/string.rb +145 -0
- data/modules/mruby/src/array.c +1150 -0
- data/modules/mruby/src/backtrace.c +73 -0
- data/modules/mruby/src/class.c +1942 -0
- data/modules/mruby/src/codegen.c +2864 -0
- data/modules/mruby/src/compar.c +13 -0
- data/modules/mruby/src/crc.c +38 -0
- data/modules/mruby/src/dump.c +542 -0
- data/modules/mruby/src/enum.c +14 -0
- data/modules/mruby/src/error.c +454 -0
- data/modules/mruby/src/error.h +18 -0
- data/modules/mruby/src/etc.c +204 -0
- data/modules/mruby/src/gc.c +1542 -0
- data/modules/mruby/src/hash.c +1261 -0
- data/modules/mruby/src/init.c +62 -0
- data/modules/mruby/src/kernel.c +1105 -0
- data/modules/mruby/src/keywords +50 -0
- data/modules/mruby/src/lex.def +212 -0
- data/modules/mruby/src/load.c +629 -0
- data/modules/mruby/src/mruby_core.rake +28 -0
- data/modules/mruby/src/node.h +117 -0
- data/modules/mruby/src/numeric.c +1418 -0
- data/modules/mruby/src/object.c +593 -0
- data/modules/mruby/src/opcode.h +160 -0
- data/modules/mruby/src/parse.y +6050 -0
- data/modules/mruby/src/pool.c +190 -0
- data/modules/mruby/src/print.c +71 -0
- data/modules/mruby/src/proc.c +209 -0
- data/modules/mruby/src/range.c +442 -0
- data/modules/mruby/src/re.h +13 -0
- data/modules/mruby/src/state.c +200 -0
- data/modules/mruby/src/string.c +2580 -0
- data/modules/mruby/src/symbol.c +456 -0
- data/modules/mruby/src/value_array.h +27 -0
- data/modules/mruby/src/variable.c +1147 -0
- data/modules/mruby/src/vm.c +2129 -0
- data/modules/mruby/tasks/libmruby.rake +18 -0
- data/modules/mruby/tasks/mrbgem_spec.rake +297 -0
- data/modules/mruby/tasks/mrbgems.rake +85 -0
- data/modules/mruby/tasks/mrbgems_test.rake +88 -0
- data/modules/mruby/tasks/mruby_build.rake +211 -0
- data/modules/mruby/tasks/mruby_build_commands.rake +287 -0
- data/modules/mruby/tasks/mruby_build_gem.rake +67 -0
- data/modules/mruby/tasks/ruby_ext.rake +70 -0
- data/modules/mruby/tasks/toolchains/androideabi.rake +126 -0
- data/modules/mruby/tasks/toolchains/clang.rake +8 -0
- data/modules/mruby/tasks/toolchains/gcc.rake +21 -0
- data/modules/mruby/tasks/toolchains/vs2010.rake +3 -0
- data/modules/mruby/tasks/toolchains/vs2012.rake +44 -0
- data/modules/mruby/test/README.md +7 -0
- data/modules/mruby/test/assert.rb +238 -0
- data/modules/mruby/test/driver.c +118 -0
- data/modules/mruby/test/init_mrbtest.c +24 -0
- data/modules/mruby/test/mrbtest.rake +47 -0
- data/modules/mruby/test/report.rb +4 -0
- data/modules/mruby/test/t/argumenterror.rb +21 -0
- data/modules/mruby/test/t/array.rb +309 -0
- data/modules/mruby/test/t/basicobject.rb +11 -0
- data/modules/mruby/test/t/bs_block.rb +489 -0
- data/modules/mruby/test/t/bs_literal.rb +38 -0
- data/modules/mruby/test/t/class.rb +219 -0
- data/modules/mruby/test/t/comparable.rb +72 -0
- data/modules/mruby/test/t/enumerable.rb +108 -0
- data/modules/mruby/test/t/exception.rb +337 -0
- data/modules/mruby/test/t/false.rb +33 -0
- data/modules/mruby/test/t/float.rb +145 -0
- data/modules/mruby/test/t/gc.rb +45 -0
- data/modules/mruby/test/t/hash.rb +310 -0
- data/modules/mruby/test/t/indexerror.rb +10 -0
- data/modules/mruby/test/t/integer.rb +222 -0
- data/modules/mruby/test/t/kernel.rb +425 -0
- data/modules/mruby/test/t/literals.rb +287 -0
- data/modules/mruby/test/t/localjumperror.rb +13 -0
- data/modules/mruby/test/t/methods.rb +109 -0
- data/modules/mruby/test/t/module.rb +344 -0
- data/modules/mruby/test/t/nameerror.rb +32 -0
- data/modules/mruby/test/t/nil.rb +29 -0
- data/modules/mruby/test/t/nomethoderror.rb +13 -0
- data/modules/mruby/test/t/numeric.rb +29 -0
- data/modules/mruby/test/t/object.rb +11 -0
- data/modules/mruby/test/t/proc.rb +56 -0
- data/modules/mruby/test/t/range.rb +82 -0
- data/modules/mruby/test/t/rangeerror.rb +10 -0
- data/modules/mruby/test/t/regexperror.rb +4 -0
- data/modules/mruby/test/t/runtimeerror.rb +6 -0
- data/modules/mruby/test/t/standarderror.rb +10 -0
- data/modules/mruby/test/t/string.rb +483 -0
- data/modules/mruby/test/t/symbol.rb +27 -0
- data/modules/mruby/test/t/syntax.rb +67 -0
- data/modules/mruby/test/t/true.rb +33 -0
- data/modules/mruby/test/t/typeerror.rb +11 -0
- data/modules/mruby/tools/mrbc/mrbc.c +318 -0
- data/modules/mruby/tools/mrbc/mrbc.rake +14 -0
- data/modules/mruby/travis_config.rb +6 -0
- data/modules/mrubymix/LICENSE +21 -0
- data/modules/mrubymix/README.md +6 -0
- data/modules/mrubymix/bin/mrubymix +29 -0
- data/modules/mrubymix/lib/mrubymix.rb +93 -0
- data/modules/mrubymix/mrubymix.gemspec +13 -0
- data/scripts/gen_gems_config.rb +185 -0
- data/scripts/gen_post.rb +104 -0
- data/templates/minimal/Rakefile +36 -0
- data/templates/minimal/app/app.rb +3 -0
- metadata +1408 -0
|
@@ -0,0 +1,4452 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* GL support. See https://github.com/kripken/emscripten/wiki/OpenGL-support
|
|
3
|
+
* for current status.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
var LibraryGL = {
|
|
7
|
+
$GL__postset: 'GL.init()',
|
|
8
|
+
$GL: {
|
|
9
|
+
#if GL_DEBUG
|
|
10
|
+
debug: true,
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
counter: 1, // 0 is reserved as 'null' in gl
|
|
14
|
+
buffers: [],
|
|
15
|
+
programs: [],
|
|
16
|
+
framebuffers: [],
|
|
17
|
+
renderbuffers: [],
|
|
18
|
+
textures: [],
|
|
19
|
+
uniforms: [],
|
|
20
|
+
shaders: [],
|
|
21
|
+
|
|
22
|
+
#if FULL_ES2
|
|
23
|
+
clientBuffers: [],
|
|
24
|
+
#endif
|
|
25
|
+
currArrayBuffer: 0,
|
|
26
|
+
currElementArrayBuffer: 0,
|
|
27
|
+
|
|
28
|
+
byteSizeByTypeRoot: 0x1400, // GL_BYTE
|
|
29
|
+
byteSizeByType: [
|
|
30
|
+
1, // GL_BYTE
|
|
31
|
+
1, // GL_UNSIGNED_BYTE
|
|
32
|
+
2, // GL_SHORT
|
|
33
|
+
2, // GL_UNSIGNED_SHORT
|
|
34
|
+
4, // GL_INT
|
|
35
|
+
4, // GL_UNSIGNED_INT
|
|
36
|
+
4, // GL_FLOAT
|
|
37
|
+
2, // GL_2_BYTES
|
|
38
|
+
3, // GL_3_BYTES
|
|
39
|
+
4, // GL_4_BYTES
|
|
40
|
+
8 // GL_DOUBLE
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
uniformTable: {}, // name => uniform ID. the uID must be identical until relinking, cannot create a new uID each call to glGetUniformLocation
|
|
44
|
+
|
|
45
|
+
packAlignment: 4, // default alignment is 4 bytes
|
|
46
|
+
unpackAlignment: 4, // default alignment is 4 bytes
|
|
47
|
+
|
|
48
|
+
init: function() {
|
|
49
|
+
Browser.moduleContextCreatedCallbacks.push(GL.initExtensions);
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
// Get a new ID for a texture/buffer/etc., while keeping the table dense and fast. Creation is farely rare so it is worth optimizing lookups later.
|
|
53
|
+
getNewId: function(table) {
|
|
54
|
+
var ret = GL.counter++;
|
|
55
|
+
for (var i = table.length; i < ret; i++) {
|
|
56
|
+
table[i] = null;
|
|
57
|
+
}
|
|
58
|
+
return ret;
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// Mini temp buffer
|
|
62
|
+
MINI_TEMP_BUFFER_SIZE: 16,
|
|
63
|
+
miniTempBuffer: null,
|
|
64
|
+
miniTempBufferViews: [0], // index i has the view of size i+1
|
|
65
|
+
|
|
66
|
+
// Large temporary buffers
|
|
67
|
+
MAX_TEMP_BUFFER_SIZE: {{{ GL_MAX_TEMP_BUFFER_SIZE }}},
|
|
68
|
+
tempBufferIndexLookup: null,
|
|
69
|
+
tempVertexBuffers: null,
|
|
70
|
+
tempIndexBuffers: null,
|
|
71
|
+
tempQuadIndexBuffer: null,
|
|
72
|
+
|
|
73
|
+
generateTempBuffers: function(quads) {
|
|
74
|
+
GL.tempBufferIndexLookup = new Uint8Array(GL.MAX_TEMP_BUFFER_SIZE+1);
|
|
75
|
+
GL.tempVertexBuffers = [];
|
|
76
|
+
GL.tempIndexBuffers = [];
|
|
77
|
+
var last = -1, curr = -1;
|
|
78
|
+
var size = 1;
|
|
79
|
+
for (var i = 0; i <= GL.MAX_TEMP_BUFFER_SIZE; i++) {
|
|
80
|
+
if (i > size) {
|
|
81
|
+
size <<= 1;
|
|
82
|
+
}
|
|
83
|
+
if (size != last) {
|
|
84
|
+
curr++;
|
|
85
|
+
GL.tempVertexBuffers[curr] = Module.ctx.createBuffer();
|
|
86
|
+
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, GL.tempVertexBuffers[curr]);
|
|
87
|
+
Module.ctx.bufferData(Module.ctx.ARRAY_BUFFER, size, Module.ctx.DYNAMIC_DRAW);
|
|
88
|
+
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, null);
|
|
89
|
+
GL.tempIndexBuffers[curr] = Module.ctx.createBuffer();
|
|
90
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, GL.tempIndexBuffers[curr]);
|
|
91
|
+
Module.ctx.bufferData(Module.ctx.ELEMENT_ARRAY_BUFFER, size, Module.ctx.DYNAMIC_DRAW);
|
|
92
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, null);
|
|
93
|
+
last = size;
|
|
94
|
+
}
|
|
95
|
+
GL.tempBufferIndexLookup[i] = curr;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (quads) {
|
|
99
|
+
// GL_QUAD indexes can be precalculated
|
|
100
|
+
GL.tempQuadIndexBuffer = Module.ctx.createBuffer();
|
|
101
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, GL.tempQuadIndexBuffer);
|
|
102
|
+
var numIndexes = GL.MAX_TEMP_BUFFER_SIZE >> 1;
|
|
103
|
+
var quadIndexes = new Uint16Array(numIndexes);
|
|
104
|
+
var i = 0, v = 0;
|
|
105
|
+
while (1) {
|
|
106
|
+
quadIndexes[i++] = v;
|
|
107
|
+
if (i >= numIndexes) break;
|
|
108
|
+
quadIndexes[i++] = v+1;
|
|
109
|
+
if (i >= numIndexes) break;
|
|
110
|
+
quadIndexes[i++] = v+2;
|
|
111
|
+
if (i >= numIndexes) break;
|
|
112
|
+
quadIndexes[i++] = v;
|
|
113
|
+
if (i >= numIndexes) break;
|
|
114
|
+
quadIndexes[i++] = v+2;
|
|
115
|
+
if (i >= numIndexes) break;
|
|
116
|
+
quadIndexes[i++] = v+3;
|
|
117
|
+
if (i >= numIndexes) break;
|
|
118
|
+
v += 4;
|
|
119
|
+
}
|
|
120
|
+
Module.ctx.bufferData(Module.ctx.ELEMENT_ARRAY_BUFFER, quadIndexes, Module.ctx.STATIC_DRAW);
|
|
121
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, null);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
// Find a token in a shader source string
|
|
126
|
+
findToken: function(source, token) {
|
|
127
|
+
function isIdentChar(ch) {
|
|
128
|
+
if (ch >= 48 && ch <= 57) // 0-9
|
|
129
|
+
return true;
|
|
130
|
+
if (ch >= 65 && ch <= 90) // A-Z
|
|
131
|
+
return true;
|
|
132
|
+
if (ch >= 97 && ch <= 122) // a-z
|
|
133
|
+
return true;
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
var i = -1;
|
|
137
|
+
do {
|
|
138
|
+
i = source.indexOf(token, i + 1);
|
|
139
|
+
if (i < 0) {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (i > 0 && isIdentChar(source[i - 1])) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
i += token.length;
|
|
146
|
+
if (i < source.length - 1 && isIdentChar(source[i + 1])) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
} while (true);
|
|
151
|
+
return false;
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
getSource: function(shader, count, string, length) {
|
|
155
|
+
var source = '';
|
|
156
|
+
for (var i = 0; i < count; ++i) {
|
|
157
|
+
var frag;
|
|
158
|
+
if (length) {
|
|
159
|
+
var len = {{{ makeGetValue('length', 'i*4', 'i32') }}};
|
|
160
|
+
if (len < 0) {
|
|
161
|
+
frag = Pointer_stringify({{{ makeGetValue('string', 'i*4', 'i32') }}});
|
|
162
|
+
} else {
|
|
163
|
+
frag = Pointer_stringify({{{ makeGetValue('string', 'i*4', 'i32') }}}, len);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
frag = Pointer_stringify({{{ makeGetValue('string', 'i*4', 'i32') }}});
|
|
167
|
+
}
|
|
168
|
+
source += frag;
|
|
169
|
+
}
|
|
170
|
+
// Let's see if we need to enable the standard derivatives extension
|
|
171
|
+
type = Module.ctx.getShaderParameter(GL.shaders[shader], 0x8B4F /* GL_SHADER_TYPE */);
|
|
172
|
+
if (type == 0x8B30 /* GL_FRAGMENT_SHADER */) {
|
|
173
|
+
if (GL.findToken(source, "dFdx") ||
|
|
174
|
+
GL.findToken(source, "dFdy") ||
|
|
175
|
+
GL.findToken(source, "fwidth")) {
|
|
176
|
+
source = "#extension GL_OES_standard_derivatives : enable\n" + source;
|
|
177
|
+
var extension = Module.ctx.getExtension("OES_standard_derivatives");
|
|
178
|
+
#if GL_DEBUG
|
|
179
|
+
if (!extension) {
|
|
180
|
+
Module.printErr("Shader attempts to use the standard derivatives extension which is not available.");
|
|
181
|
+
}
|
|
182
|
+
#endif
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return source;
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
computeImageSize: function(width, height, sizePerPixel, alignment) {
|
|
189
|
+
function roundedToNextMultipleOf(x, y) {
|
|
190
|
+
return Math.floor((x + y - 1) / y) * y
|
|
191
|
+
}
|
|
192
|
+
var plainRowSize = width * sizePerPixel;
|
|
193
|
+
var alignedRowSize = roundedToNextMultipleOf(plainRowSize, alignment);
|
|
194
|
+
return (height <= 0) ? 0 :
|
|
195
|
+
((height - 1) * alignedRowSize + plainRowSize);
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
getTexPixelData: function(type, format, width, height, pixels, internalFormat) {
|
|
199
|
+
var sizePerPixel;
|
|
200
|
+
switch (type) {
|
|
201
|
+
case 0x1401 /* GL_UNSIGNED_BYTE */:
|
|
202
|
+
switch (format) {
|
|
203
|
+
case 0x1906 /* GL_ALPHA */:
|
|
204
|
+
case 0x1909 /* GL_LUMINANCE */:
|
|
205
|
+
sizePerPixel = 1;
|
|
206
|
+
break;
|
|
207
|
+
case 0x1907 /* GL_RGB */:
|
|
208
|
+
sizePerPixel = 3;
|
|
209
|
+
break;
|
|
210
|
+
case 0x1908 /* GL_RGBA */:
|
|
211
|
+
sizePerPixel = 4;
|
|
212
|
+
break;
|
|
213
|
+
case 0x190A /* GL_LUMINANCE_ALPHA */:
|
|
214
|
+
sizePerPixel = 2;
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
throw 'Invalid format (' + format + ')';
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case 0x8363 /* GL_UNSIGNED_SHORT_5_6_5 */:
|
|
221
|
+
case 0x8033 /* GL_UNSIGNED_SHORT_4_4_4_4 */:
|
|
222
|
+
case 0x8034 /* GL_UNSIGNED_SHORT_5_5_5_1 */:
|
|
223
|
+
sizePerPixel = 2;
|
|
224
|
+
break;
|
|
225
|
+
case 0x1406 /* GL_FLOAT */:
|
|
226
|
+
assert(GL.floatExt, 'Must have OES_texture_float to use float textures');
|
|
227
|
+
switch (format) {
|
|
228
|
+
case 0x1907 /* GL_RGB */:
|
|
229
|
+
sizePerPixel = 3*4;
|
|
230
|
+
break;
|
|
231
|
+
case 0x1908 /* GL_RGBA */:
|
|
232
|
+
sizePerPixel = 4*4;
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
throw 'Invalid format (' + format + ')';
|
|
236
|
+
}
|
|
237
|
+
internalFormat = Module.ctx.RGBA;
|
|
238
|
+
break;
|
|
239
|
+
default:
|
|
240
|
+
throw 'Invalid type (' + type + ')';
|
|
241
|
+
}
|
|
242
|
+
var bytes = GL.computeImageSize(width, height, sizePerPixel, GL.unpackAlignment);
|
|
243
|
+
if (type == 0x1401 /* GL_UNSIGNED_BYTE */) {
|
|
244
|
+
pixels = {{{ makeHEAPView('U8', 'pixels', 'pixels+bytes') }}};
|
|
245
|
+
} else if (type == 0x1406 /* GL_FLOAT */) {
|
|
246
|
+
pixels = {{{ makeHEAPView('F32', 'pixels', 'pixels+bytes') }}};
|
|
247
|
+
} else {
|
|
248
|
+
pixels = {{{ makeHEAPView('U16', 'pixels', 'pixels+bytes') }}};
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
pixels: pixels,
|
|
252
|
+
internalFormat: internalFormat
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
#if FULL_ES2
|
|
257
|
+
calcBufLength: function(size, type, stride, count) {
|
|
258
|
+
if (stride > 0) {
|
|
259
|
+
return count * stride; // XXXvlad this is not exactly correct I don't think
|
|
260
|
+
}
|
|
261
|
+
var typeSize = GL.byteSizeByType[type - GL.byteSizeByTypeRoot];
|
|
262
|
+
return size * typeSize * count;
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
usedTempBuffers: [],
|
|
266
|
+
|
|
267
|
+
preDrawHandleClientVertexAttribBindings: function(count) {
|
|
268
|
+
GL.resetBufferBinding = false;
|
|
269
|
+
|
|
270
|
+
var used = GL.usedTempBuffers;
|
|
271
|
+
used.length = 0;
|
|
272
|
+
|
|
273
|
+
// TODO: initial pass to detect ranges we need to upload, might not need an upload per attrib
|
|
274
|
+
for (var i = 0; i < GL.maxVertexAttribs; ++i) {
|
|
275
|
+
var cb = GL.clientBuffers[i];
|
|
276
|
+
if (!cb.clientside || !cb.enabled) continue;
|
|
277
|
+
|
|
278
|
+
GL.resetBufferBinding = true;
|
|
279
|
+
|
|
280
|
+
var size = GL.calcBufLength(cb.size, cb.type, cb.stride, count);
|
|
281
|
+
var index = GL.tempBufferIndexLookup[size];
|
|
282
|
+
var buf;
|
|
283
|
+
do {
|
|
284
|
+
#if ASSERTIONS
|
|
285
|
+
assert(index < GL.tempVertexBuffers.length);
|
|
286
|
+
#endif
|
|
287
|
+
buf = GL.tempVertexBuffers[index++];
|
|
288
|
+
} while (used.indexOf(buf) >= 0);
|
|
289
|
+
used.push(buf);
|
|
290
|
+
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, buf);
|
|
291
|
+
Module.ctx.bufferSubData(Module.ctx.ARRAY_BUFFER,
|
|
292
|
+
0,
|
|
293
|
+
HEAPU8.subarray(cb.ptr, cb.ptr + size));
|
|
294
|
+
Module.ctx.vertexAttribPointer(i, cb.size, cb.type, cb.normalized, cb.stride, 0);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
postDrawHandleClientVertexAttribBindings: function() {
|
|
299
|
+
if (GL.resetBufferBinding) {
|
|
300
|
+
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, GL.buffers[GL.currArrayBuffer]);
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
#endif
|
|
304
|
+
|
|
305
|
+
initExtensions: function() {
|
|
306
|
+
if (GL.initExtensions.done) return;
|
|
307
|
+
GL.initExtensions.done = true;
|
|
308
|
+
|
|
309
|
+
if (!Module.useWebGL) return; // an app might link both gl and 2d backends
|
|
310
|
+
|
|
311
|
+
GL.miniTempBuffer = new Float32Array(GL.MINI_TEMP_BUFFER_SIZE);
|
|
312
|
+
for (var i = 0; i < GL.MINI_TEMP_BUFFER_SIZE; i++) {
|
|
313
|
+
GL.miniTempBufferViews[i] = GL.miniTempBuffer.subarray(0, i+1);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
GL.maxVertexAttribs = Module.ctx.getParameter(Module.ctx.MAX_VERTEX_ATTRIBS);
|
|
317
|
+
#if FULL_ES2
|
|
318
|
+
for (var i = 0; i < GL.maxVertexAttribs; i++) {
|
|
319
|
+
GL.clientBuffers[i] = { enabled: false, clientside: false, size: 0, type: 0, normalized: 0, stride: 0, ptr: 0 };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
GL.generateTempBuffers();
|
|
323
|
+
#endif
|
|
324
|
+
|
|
325
|
+
GL.compressionExt = Module.ctx.getExtension('WEBGL_compressed_texture_s3tc') ||
|
|
326
|
+
Module.ctx.getExtension('MOZ_WEBGL_compressed_texture_s3tc') ||
|
|
327
|
+
Module.ctx.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
|
|
328
|
+
|
|
329
|
+
GL.anisotropicExt = Module.ctx.getExtension('EXT_texture_filter_anisotropic') ||
|
|
330
|
+
Module.ctx.getExtension('MOZ_EXT_texture_filter_anisotropic') ||
|
|
331
|
+
Module.ctx.getExtension('WEBKIT_EXT_texture_filter_anisotropic');
|
|
332
|
+
|
|
333
|
+
GL.floatExt = Module.ctx.getExtension('OES_texture_float');
|
|
334
|
+
|
|
335
|
+
GL.elementIndexUintExt = Module.ctx.getExtension('OES_element_index_uint');
|
|
336
|
+
GL.standardDerivativesExt = Module.ctx.getExtension('OES_standard_derivatives');
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
glPixelStorei__sig: 'vii',
|
|
341
|
+
glPixelStorei: function(pname, param) {
|
|
342
|
+
if (pname == 0x0D05 /* GL_PACK_ALIGNMENT */) {
|
|
343
|
+
GL.packAlignment = param;
|
|
344
|
+
} else if (pname == 0x0cf5 /* GL_UNPACK_ALIGNMENT */) {
|
|
345
|
+
GL.unpackAlignment = param;
|
|
346
|
+
}
|
|
347
|
+
Module.ctx.pixelStorei(pname, param);
|
|
348
|
+
},
|
|
349
|
+
|
|
350
|
+
glGetString__sig: 'ii',
|
|
351
|
+
glGetString: function(name_) {
|
|
352
|
+
switch(name_) {
|
|
353
|
+
case 0x1F00 /* GL_VENDOR */:
|
|
354
|
+
case 0x1F01 /* GL_RENDERER */:
|
|
355
|
+
case 0x1F02 /* GL_VERSION */:
|
|
356
|
+
return allocate(intArrayFromString(Module.ctx.getParameter(name_)), 'i8', ALLOC_NORMAL);
|
|
357
|
+
case 0x1F03 /* GL_EXTENSIONS */:
|
|
358
|
+
return allocate(intArrayFromString(Module.ctx.getSupportedExtensions().join(' ')), 'i8', ALLOC_NORMAL);
|
|
359
|
+
case 0x8B8C /* GL_SHADING_LANGUAGE_VERSION */:
|
|
360
|
+
return allocate(intArrayFromString('OpenGL ES GLSL 1.00 (WebGL)'), 'i8', ALLOC_NORMAL);
|
|
361
|
+
default:
|
|
362
|
+
throw 'Failure: Invalid glGetString value: ' + name_;
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
glGetIntegerv__sig: 'vii',
|
|
367
|
+
glGetIntegerv: function(name_, p) {
|
|
368
|
+
switch(name_) { // Handle a few trivial GLES values
|
|
369
|
+
case 0x8DFA: // GL_SHADER_COMPILER
|
|
370
|
+
{{{ makeSetValue('p', '0', '1', 'i32') }}};
|
|
371
|
+
return;
|
|
372
|
+
case 0x8DF9: // GL_NUM_SHADER_BINARY_FORMATS
|
|
373
|
+
{{{ makeSetValue('p', '0', '0', 'i32') }}};
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
var result = Module.ctx.getParameter(name_);
|
|
377
|
+
switch (typeof(result)) {
|
|
378
|
+
case "number":
|
|
379
|
+
{{{ makeSetValue('p', '0', 'result', 'i32') }}};
|
|
380
|
+
break;
|
|
381
|
+
case "boolean":
|
|
382
|
+
{{{ makeSetValue('p', '0', 'result ? 1 : 0', 'i8') }}};
|
|
383
|
+
break;
|
|
384
|
+
case "string":
|
|
385
|
+
throw 'Native code calling glGetIntegerv(' + name_ + ') on a name which returns a string!';
|
|
386
|
+
case "object":
|
|
387
|
+
if (result === null) {
|
|
388
|
+
{{{ makeSetValue('p', '0', '0', 'i32') }}};
|
|
389
|
+
} else if (result instanceof Float32Array ||
|
|
390
|
+
result instanceof Uint32Array ||
|
|
391
|
+
result instanceof Int32Array ||
|
|
392
|
+
result instanceof Array) {
|
|
393
|
+
for (var i = 0; i < result.length; ++i) {
|
|
394
|
+
{{{ makeSetValue('p', 'i*4', 'result[i]', 'i32') }}};
|
|
395
|
+
}
|
|
396
|
+
} else if (result instanceof WebGLBuffer) {
|
|
397
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'i32') }}};
|
|
398
|
+
} else if (result instanceof WebGLProgram) {
|
|
399
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'i32') }}};
|
|
400
|
+
} else if (result instanceof WebGLFramebuffer) {
|
|
401
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'i32') }}};
|
|
402
|
+
} else if (result instanceof WebGLRenderbuffer) {
|
|
403
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'i32') }}};
|
|
404
|
+
} else if (result instanceof WebGLTexture) {
|
|
405
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'i32') }}};
|
|
406
|
+
} else {
|
|
407
|
+
throw 'Unknown object returned from WebGL getParameter';
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
410
|
+
case "undefined":
|
|
411
|
+
throw 'Native code calling glGetIntegerv(' + name_ + ') and it returns undefined';
|
|
412
|
+
default:
|
|
413
|
+
throw 'Why did we hit the default case?';
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
glGetFloatv__sig: 'vii',
|
|
418
|
+
glGetFloatv: function(name_, p) {
|
|
419
|
+
var result = Module.ctx.getParameter(name_);
|
|
420
|
+
switch (typeof(result)) {
|
|
421
|
+
case "number":
|
|
422
|
+
{{{ makeSetValue('p', '0', 'result', 'float') }}};
|
|
423
|
+
break;
|
|
424
|
+
case "boolean":
|
|
425
|
+
{{{ makeSetValue('p', '0', 'result ? 1.0 : 0.0', 'float') }}};
|
|
426
|
+
break;
|
|
427
|
+
case "string":
|
|
428
|
+
{{{ makeSetValue('p', '0', '0', 'float') }}};
|
|
429
|
+
case "object":
|
|
430
|
+
if (result === null) {
|
|
431
|
+
throw 'Native code calling glGetFloatv(' + name_ + ') and it returns null';
|
|
432
|
+
} else if (result instanceof Float32Array ||
|
|
433
|
+
result instanceof Uint32Array ||
|
|
434
|
+
result instanceof Int32Array ||
|
|
435
|
+
result instanceof Array) {
|
|
436
|
+
for (var i = 0; i < result.length; ++i) {
|
|
437
|
+
{{{ makeSetValue('p', 'i*4', 'result[i]', 'float') }}};
|
|
438
|
+
}
|
|
439
|
+
} else if (result instanceof WebGLBuffer) {
|
|
440
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'float') }}};
|
|
441
|
+
} else if (result instanceof WebGLProgram) {
|
|
442
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'float') }}};
|
|
443
|
+
} else if (result instanceof WebGLFramebuffer) {
|
|
444
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'float') }}};
|
|
445
|
+
} else if (result instanceof WebGLRenderbuffer) {
|
|
446
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'float') }}};
|
|
447
|
+
} else if (result instanceof WebGLTexture) {
|
|
448
|
+
{{{ makeSetValue('p', '0', 'result.name | 0', 'float') }}};
|
|
449
|
+
} else {
|
|
450
|
+
throw 'Unknown object returned from WebGL getParameter';
|
|
451
|
+
}
|
|
452
|
+
break;
|
|
453
|
+
case "undefined":
|
|
454
|
+
throw 'Native code calling glGetFloatv(' + name_ + ') and it returns undefined';
|
|
455
|
+
default:
|
|
456
|
+
throw 'Why did we hit the default case?';
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
glGetBooleanv__sig: 'vii',
|
|
461
|
+
glGetBooleanv: function(name_, p) {
|
|
462
|
+
var result = Module.ctx.getParameter(name_);
|
|
463
|
+
switch (typeof(result)) {
|
|
464
|
+
case "number":
|
|
465
|
+
{{{ makeSetValue('p', '0', 'result != 0', 'i8') }}};
|
|
466
|
+
break;
|
|
467
|
+
case "boolean":
|
|
468
|
+
{{{ makeSetValue('p', '0', 'result != 0', 'i8') }}};
|
|
469
|
+
break;
|
|
470
|
+
case "string":
|
|
471
|
+
throw 'Native code calling glGetBooleanv(' + name_ + ') on a name which returns a string!';
|
|
472
|
+
case "object":
|
|
473
|
+
if (result === null) {
|
|
474
|
+
{{{ makeSetValue('p', '0', '0', 'i8') }}};
|
|
475
|
+
} else if (result instanceof Float32Array ||
|
|
476
|
+
result instanceof Uint32Array ||
|
|
477
|
+
result instanceof Int32Array ||
|
|
478
|
+
result instanceof Array) {
|
|
479
|
+
for (var i = 0; i < result.length; ++i) {
|
|
480
|
+
{{{ makeSetValue('p', 'i', 'result[i] != 0', 'i8') }}};
|
|
481
|
+
}
|
|
482
|
+
} else if (result instanceof WebGLBuffer ||
|
|
483
|
+
result instanceof WebGLProgram ||
|
|
484
|
+
result instanceof WebGLFramebuffer ||
|
|
485
|
+
result instanceof WebGLRenderbuffer ||
|
|
486
|
+
result instanceof WebGLTexture) {
|
|
487
|
+
{{{ makeSetValue('p', '0', '1', 'i8') }}}; // non-zero ID is always 1!
|
|
488
|
+
} else {
|
|
489
|
+
throw 'Unknown object returned from WebGL getParameter';
|
|
490
|
+
}
|
|
491
|
+
break;
|
|
492
|
+
case "undefined":
|
|
493
|
+
throw 'Unknown object returned from WebGL getParameter';
|
|
494
|
+
default:
|
|
495
|
+
throw 'Why did we hit the default case?';
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
glGenTextures__sig: 'vii',
|
|
500
|
+
glGenTextures: function(n, textures) {
|
|
501
|
+
for (var i = 0; i < n; i++) {
|
|
502
|
+
var id = GL.getNewId(GL.textures);
|
|
503
|
+
var texture = Module.ctx.createTexture();
|
|
504
|
+
texture.name = id;
|
|
505
|
+
GL.textures[id] = texture;
|
|
506
|
+
{{{ makeSetValue('textures', 'i*4', 'id', 'i32') }}};
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
|
|
510
|
+
glDeleteTextures__sig: 'vii',
|
|
511
|
+
glDeleteTextures: function(n, textures) {
|
|
512
|
+
for (var i = 0; i < n; i++) {
|
|
513
|
+
var id = {{{ makeGetValue('textures', 'i*4', 'i32') }}};
|
|
514
|
+
var texture = GL.textures[id];
|
|
515
|
+
Module.ctx.deleteTexture(texture);
|
|
516
|
+
texture.name = 0;
|
|
517
|
+
GL.textures[id] = null;
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
glCompressedTexImage2D__sig: 'viiiiiiii',
|
|
522
|
+
glCompressedTexImage2D: function(target, level, internalFormat, width, height, border, imageSize, data) {
|
|
523
|
+
assert(GL.compressionExt);
|
|
524
|
+
if (data) {
|
|
525
|
+
data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}};
|
|
526
|
+
} else {
|
|
527
|
+
data = null;
|
|
528
|
+
}
|
|
529
|
+
Module.ctx['compressedTexImage2D'](target, level, internalFormat, width, height, border, data);
|
|
530
|
+
},
|
|
531
|
+
|
|
532
|
+
glCompressedTexSubImage2D__sig: 'viiiiiiiii',
|
|
533
|
+
glCompressedTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, imageSize, data) {
|
|
534
|
+
assert(GL.compressionExt);
|
|
535
|
+
if (data) {
|
|
536
|
+
data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}};
|
|
537
|
+
} else {
|
|
538
|
+
data = null;
|
|
539
|
+
}
|
|
540
|
+
Module.ctx['compressedTexSubImage2D'](target, level, xoffset, yoffset, width, height, data);
|
|
541
|
+
},
|
|
542
|
+
|
|
543
|
+
glTexImage2D__sig: 'viiiiiiiii',
|
|
544
|
+
glTexImage2D: function(target, level, internalFormat, width, height, border, format, type, pixels) {
|
|
545
|
+
if (pixels) {
|
|
546
|
+
var data = GL.getTexPixelData(type, format, width, height, pixels, internalFormat);
|
|
547
|
+
pixels = data.pixels;
|
|
548
|
+
internalFormat = data.internalFormat;
|
|
549
|
+
} else {
|
|
550
|
+
pixels = null;
|
|
551
|
+
}
|
|
552
|
+
Module.ctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
|
|
553
|
+
},
|
|
554
|
+
|
|
555
|
+
glTexSubImage2D__sig: 'viiiiiiiii',
|
|
556
|
+
glTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, type, pixels) {
|
|
557
|
+
if (pixels) {
|
|
558
|
+
var data = GL.getTexPixelData(type, format, width, height, pixels, -1);
|
|
559
|
+
pixels = data.pixels;
|
|
560
|
+
} else {
|
|
561
|
+
pixels = null;
|
|
562
|
+
}
|
|
563
|
+
Module.ctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
glReadPixels__sig: 'viiiiiii',
|
|
567
|
+
glReadPixels: function(x, y, width, height, format, type, pixels) {
|
|
568
|
+
assert(type == 0x1401 /* GL_UNSIGNED_BYTE */);
|
|
569
|
+
var sizePerPixel;
|
|
570
|
+
switch (format) {
|
|
571
|
+
case 0x1907 /* GL_RGB */:
|
|
572
|
+
sizePerPixel = 3;
|
|
573
|
+
break;
|
|
574
|
+
case 0x1908 /* GL_RGBA */:
|
|
575
|
+
sizePerPixel = 4;
|
|
576
|
+
break;
|
|
577
|
+
default: throw 'unsupported glReadPixels format';
|
|
578
|
+
}
|
|
579
|
+
var totalSize = width*height*sizePerPixel;
|
|
580
|
+
Module.ctx.readPixels(x, y, width, height, format, type, HEAPU8.subarray(pixels, pixels + totalSize));
|
|
581
|
+
},
|
|
582
|
+
|
|
583
|
+
glBindTexture__sig: 'vii',
|
|
584
|
+
glBindTexture: function(target, texture) {
|
|
585
|
+
Module.ctx.bindTexture(target, texture ? GL.textures[texture] : null);
|
|
586
|
+
},
|
|
587
|
+
|
|
588
|
+
glGetTexParameterfv__sig: 'viii',
|
|
589
|
+
glGetTexParameterfv: function(target, pname, params) {
|
|
590
|
+
{{{ makeSetValue('params', '0', 'Module.getTexParameter(target, pname)', 'float') }}};
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
glGetTexParameteriv__sig: 'viii',
|
|
594
|
+
glGetTexParameteriv: function(target, pname, params) {
|
|
595
|
+
{{{ makeSetValue('params', '0', 'Module.getTexParameter(target, pname)', 'i32') }}};
|
|
596
|
+
},
|
|
597
|
+
|
|
598
|
+
glTexParameterfv__sig: 'viii',
|
|
599
|
+
glTexParameterfv: function(target, pname, params) {
|
|
600
|
+
var param = {{{ makeGetValue('params', '0', 'float') }}};
|
|
601
|
+
Module.ctx.texParameterf(target, pname, param);
|
|
602
|
+
},
|
|
603
|
+
|
|
604
|
+
glTexParameteriv__sig: 'viii',
|
|
605
|
+
glTexParameteriv: function(target, pname, params) {
|
|
606
|
+
var param = {{{ makeGetValue('params', '0', 'i32') }}};
|
|
607
|
+
Module.ctx.texParameteri(target, pname, param);
|
|
608
|
+
},
|
|
609
|
+
|
|
610
|
+
glIsTexture__sig: 'ii',
|
|
611
|
+
glIsTexture: function(texture) {
|
|
612
|
+
var texture = GL.textures[texture];
|
|
613
|
+
if (!texture) return 0;
|
|
614
|
+
return Module.ctx.isTexture(texture);
|
|
615
|
+
},
|
|
616
|
+
|
|
617
|
+
glGenBuffers__sig: 'vii',
|
|
618
|
+
glGenBuffers: function(n, buffers) {
|
|
619
|
+
for (var i = 0; i < n; i++) {
|
|
620
|
+
var id = GL.getNewId(GL.buffers);
|
|
621
|
+
var buffer = Module.ctx.createBuffer();
|
|
622
|
+
buffer.name = id;
|
|
623
|
+
GL.buffers[id] = buffer;
|
|
624
|
+
{{{ makeSetValue('buffers', 'i*4', 'id', 'i32') }}};
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
|
|
628
|
+
glDeleteBuffers__sig: 'vii',
|
|
629
|
+
glDeleteBuffers: function(n, buffers) {
|
|
630
|
+
for (var i = 0; i < n; i++) {
|
|
631
|
+
var id = {{{ makeGetValue('buffers', 'i*4', 'i32') }}};
|
|
632
|
+
var buffer = GL.buffers[id];
|
|
633
|
+
Module.ctx.deleteBuffer(buffer);
|
|
634
|
+
buffer.name = 0;
|
|
635
|
+
GL.buffers[id] = null;
|
|
636
|
+
|
|
637
|
+
if (id == GL.currArrayBuffer) GL.currArrayBuffer = 0;
|
|
638
|
+
if (id == GL.currElementArrayBuffer) GL.currElementArrayBuffer = 0;
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
|
|
642
|
+
glGetBufferParameteriv__sig: 'viii',
|
|
643
|
+
glGetBufferParameteriv: function(target, value, data) {
|
|
644
|
+
{{{ makeSetValue('data', '0', 'Module.ctx.getBufferParameter(target, value)', 'i32') }}};
|
|
645
|
+
},
|
|
646
|
+
|
|
647
|
+
glBufferData__sig: 'viiii',
|
|
648
|
+
glBufferData: function(target, size, data, usage) {
|
|
649
|
+
Module.ctx.bufferData(target, HEAPU8.subarray(data, data+size), usage);
|
|
650
|
+
},
|
|
651
|
+
|
|
652
|
+
glBufferSubData__sig: 'viiii',
|
|
653
|
+
glBufferSubData: function(target, offset, size, data) {
|
|
654
|
+
Module.ctx.bufferSubData(target, offset, HEAPU8.subarray(data, data+size));
|
|
655
|
+
},
|
|
656
|
+
|
|
657
|
+
glIsBuffer__sig: 'ii',
|
|
658
|
+
glIsBuffer: function(buffer) {
|
|
659
|
+
var b = GL.buffers[buffer];
|
|
660
|
+
if (!b) return 0;
|
|
661
|
+
return Module.ctx.isBuffer(b);
|
|
662
|
+
},
|
|
663
|
+
|
|
664
|
+
glGenRenderbuffers__sig: 'vii',
|
|
665
|
+
glGenRenderbuffers: function(n, renderbuffers) {
|
|
666
|
+
for (var i = 0; i < n; i++) {
|
|
667
|
+
var id = GL.getNewId(GL.renderbuffers);
|
|
668
|
+
var renderbuffer = Module.ctx.createRenderbuffer();
|
|
669
|
+
renderbuffer.name = id;
|
|
670
|
+
GL.renderbuffers[id] = renderbuffer;
|
|
671
|
+
{{{ makeSetValue('renderbuffers', 'i*4', 'id', 'i32') }}};
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
|
|
675
|
+
glDeleteRenderbuffers__sig: 'vii',
|
|
676
|
+
glDeleteRenderbuffers: function(n, renderbuffers) {
|
|
677
|
+
for (var i = 0; i < n; i++) {
|
|
678
|
+
var id = {{{ makeGetValue('renderbuffers', 'i*4', 'i32') }}};
|
|
679
|
+
var renderbuffer = GL.renderbuffers[id];
|
|
680
|
+
Module.ctx.deleteRenderbuffer(renderbuffer);
|
|
681
|
+
renderbuffer.name = 0;
|
|
682
|
+
GL.renderbuffers[id] = null;
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
|
|
686
|
+
glBindRenderbuffer__sig: 'vii',
|
|
687
|
+
glBindRenderbuffer: function(target, renderbuffer) {
|
|
688
|
+
Module.ctx.bindRenderbuffer(target, renderbuffer ? GL.renderbuffers[renderbuffer] : null);
|
|
689
|
+
},
|
|
690
|
+
|
|
691
|
+
glGetRenderbufferParameteriv__sig: 'viii',
|
|
692
|
+
glGetRenderbufferParameteriv: function(target, pname, params) {
|
|
693
|
+
{{{ makeSetValue('params', '0', 'Module.ctx.getRenderbufferParameter(target, pname)', 'i32') }}};
|
|
694
|
+
},
|
|
695
|
+
|
|
696
|
+
glIsRenderbuffer__sig: 'ii',
|
|
697
|
+
glIsRenderbuffer: function(renderbuffer) {
|
|
698
|
+
var rb = GL.renderbuffers[renderbuffer];
|
|
699
|
+
if (!rb) return 0;
|
|
700
|
+
return Module.ctx.isRenderbuffer(rb);
|
|
701
|
+
},
|
|
702
|
+
|
|
703
|
+
glGetUniformfv__sig: 'viii',
|
|
704
|
+
glGetUniformfv: function(program, location, params) {
|
|
705
|
+
var data = Module.ctx.getUniform(GL.programs[program], GL.uniforms[location]);
|
|
706
|
+
if (typeof data == 'number') {
|
|
707
|
+
{{{ makeSetValue('params', '0', 'data', 'float') }}};
|
|
708
|
+
} else {
|
|
709
|
+
for (var i = 0; i < data.length; i++) {
|
|
710
|
+
{{{ makeSetValue('params', 'i', 'data[i]', 'float') }}};
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
|
|
715
|
+
glGetUniformiv__sig: 'viii',
|
|
716
|
+
glGetUniformiv: function(program, location, params) {
|
|
717
|
+
var data = Module.ctx.getUniform(GL.programs[program], GL.uniforms[location]);
|
|
718
|
+
if (typeof data == 'number' || typeof data == 'boolean') {
|
|
719
|
+
{{{ makeSetValue('params', '0', 'data', 'i32') }}};
|
|
720
|
+
} else {
|
|
721
|
+
for (var i = 0; i < data.length; i++) {
|
|
722
|
+
{{{ makeSetValue('params', 'i', 'data[i]', 'i32') }}};
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
|
|
727
|
+
glGetUniformLocation__sig: 'iii',
|
|
728
|
+
glGetUniformLocation: function(program, name) {
|
|
729
|
+
name = Pointer_stringify(name);
|
|
730
|
+
var ptable = GL.uniformTable[program];
|
|
731
|
+
if (!ptable) ptable = GL.uniformTable[program] = {};
|
|
732
|
+
var id = ptable[name];
|
|
733
|
+
if (id) return id;
|
|
734
|
+
var loc = Module.ctx.getUniformLocation(GL.programs[program], name);
|
|
735
|
+
if (!loc) return -1;
|
|
736
|
+
id = GL.getNewId(GL.uniforms);
|
|
737
|
+
GL.uniforms[id] = loc;
|
|
738
|
+
ptable[name] = id;
|
|
739
|
+
return id;
|
|
740
|
+
},
|
|
741
|
+
|
|
742
|
+
glGetVertexAttribfv__sig: 'viii',
|
|
743
|
+
glGetVertexAttribfv: function(index, pname, params) {
|
|
744
|
+
#if FULL_ES2
|
|
745
|
+
if (GL.clientBuffers[index].enabled) {
|
|
746
|
+
Module.printErr("glGetVertexAttribfv on client-side array: not supported, bad data returned");
|
|
747
|
+
}
|
|
748
|
+
#endif
|
|
749
|
+
var data = Module.ctx.getVertexAttrib(index, pname);
|
|
750
|
+
if (typeof data == 'number') {
|
|
751
|
+
{{{ makeSetValue('params', '0', 'data', 'float') }}};
|
|
752
|
+
} else {
|
|
753
|
+
for (var i = 0; i < data.length; i++) {
|
|
754
|
+
{{{ makeSetValue('params', 'i', 'data[i]', 'float') }}};
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
|
|
759
|
+
glGetVertexAttribiv__sig: 'viii',
|
|
760
|
+
glGetVertexAttribiv: function(index, pname, params) {
|
|
761
|
+
#if FULL_ES2
|
|
762
|
+
if (GL.clientBuffers[index].enabled) {
|
|
763
|
+
Module.printErr("glGetVertexAttribiv on client-side array: not supported, bad data returned");
|
|
764
|
+
}
|
|
765
|
+
#endif
|
|
766
|
+
var data = Module.ctx.getVertexAttrib(index, pname);
|
|
767
|
+
if (typeof data == 'number' || typeof data == 'boolean') {
|
|
768
|
+
{{{ makeSetValue('params', '0', 'data', 'i32') }}};
|
|
769
|
+
} else {
|
|
770
|
+
for (var i = 0; i < data.length; i++) {
|
|
771
|
+
{{{ makeSetValue('params', 'i', 'data[i]', 'i32') }}};
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
|
|
776
|
+
glGetVertexAttribPointerv__sig: 'viii',
|
|
777
|
+
glGetVertexAttribPointerv: function(index, pname, pointer) {
|
|
778
|
+
#if FULL_ES2
|
|
779
|
+
if (GL.clientBuffers[index].enabled) {
|
|
780
|
+
Module.printErr("glGetVertexAttribPointer on client-side array: not supported, bad data returned");
|
|
781
|
+
}
|
|
782
|
+
#endif
|
|
783
|
+
{{{ makeSetValue('pointer', '0', 'Module.ctx.getVertexAttribOffset(index, pname)', 'i32') }}};
|
|
784
|
+
},
|
|
785
|
+
|
|
786
|
+
glGetActiveUniform__sig: 'viiiiiii',
|
|
787
|
+
glGetActiveUniform: function(program, index, bufSize, length, size, type, name) {
|
|
788
|
+
program = GL.programs[program];
|
|
789
|
+
var info = Module.ctx.getActiveUniform(program, index);
|
|
790
|
+
|
|
791
|
+
var infoname = info.name.slice(0, Math.max(0, bufSize - 1));
|
|
792
|
+
writeStringToMemory(infoname, name);
|
|
793
|
+
|
|
794
|
+
if (length) {
|
|
795
|
+
{{{ makeSetValue('length', '0', 'infoname.length', 'i32') }}};
|
|
796
|
+
}
|
|
797
|
+
if (size) {
|
|
798
|
+
{{{ makeSetValue('size', '0', 'info.size', 'i32') }}};
|
|
799
|
+
}
|
|
800
|
+
if (type) {
|
|
801
|
+
{{{ makeSetValue('type', '0', 'info.type', 'i32') }}};
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
|
|
805
|
+
glUniform1f__sig: 'vif',
|
|
806
|
+
glUniform1f: function(location, v0) {
|
|
807
|
+
location = GL.uniforms[location];
|
|
808
|
+
Module.ctx.uniform1f(location, v0);
|
|
809
|
+
},
|
|
810
|
+
|
|
811
|
+
glUniform2f__sig: 'viff',
|
|
812
|
+
glUniform2f: function(location, v0, v1) {
|
|
813
|
+
location = GL.uniforms[location];
|
|
814
|
+
Module.ctx.uniform2f(location, v0, v1);
|
|
815
|
+
},
|
|
816
|
+
|
|
817
|
+
glUniform3f__sig: 'vifff',
|
|
818
|
+
glUniform3f: function(location, v0, v1, v2) {
|
|
819
|
+
location = GL.uniforms[location];
|
|
820
|
+
Module.ctx.uniform3f(location, v0, v1, v2);
|
|
821
|
+
},
|
|
822
|
+
|
|
823
|
+
glUniform4f__sig: 'viffff',
|
|
824
|
+
glUniform4f: function(location, v0, v1, v2, v3) {
|
|
825
|
+
location = GL.uniforms[location];
|
|
826
|
+
Module.ctx.uniform4f(location, v0, v1, v2, v3);
|
|
827
|
+
},
|
|
828
|
+
|
|
829
|
+
glUniform1i__sig: 'vii',
|
|
830
|
+
glUniform1i: function(location, v0) {
|
|
831
|
+
location = GL.uniforms[location];
|
|
832
|
+
Module.ctx.uniform1i(location, v0);
|
|
833
|
+
},
|
|
834
|
+
|
|
835
|
+
glUniform2i__sig: 'viii',
|
|
836
|
+
glUniform2i: function(location, v0, v1) {
|
|
837
|
+
location = GL.uniforms[location];
|
|
838
|
+
Module.ctx.uniform2i(location, v0, v1);
|
|
839
|
+
},
|
|
840
|
+
|
|
841
|
+
glUniform3i__sig: 'viiii',
|
|
842
|
+
glUniform3i: function(location, v0, v1, v2) {
|
|
843
|
+
location = GL.uniforms[location];
|
|
844
|
+
Module.ctx.uniform3i(location, v0, v1, v2);
|
|
845
|
+
},
|
|
846
|
+
|
|
847
|
+
glUniform4i__sig: 'viiiii',
|
|
848
|
+
glUniform4i: function(location, v0, v1, v2, v3) {
|
|
849
|
+
location = GL.uniforms[location];
|
|
850
|
+
Module.ctx.uniform4i(location, v0, v1, v2, v3);
|
|
851
|
+
},
|
|
852
|
+
|
|
853
|
+
glUniform1iv__sig: 'viii',
|
|
854
|
+
glUniform1iv: function(location, count, value) {
|
|
855
|
+
location = GL.uniforms[location];
|
|
856
|
+
value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}};
|
|
857
|
+
Module.ctx.uniform1iv(location, value);
|
|
858
|
+
},
|
|
859
|
+
|
|
860
|
+
glUniform2iv__sig: 'viii',
|
|
861
|
+
glUniform2iv: function(location, count, value) {
|
|
862
|
+
location = GL.uniforms[location];
|
|
863
|
+
count *= 2;
|
|
864
|
+
value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}};
|
|
865
|
+
Module.ctx.uniform2iv(location, value);
|
|
866
|
+
},
|
|
867
|
+
|
|
868
|
+
glUniform3iv__sig: 'viii',
|
|
869
|
+
glUniform3iv: function(location, count, value) {
|
|
870
|
+
location = GL.uniforms[location];
|
|
871
|
+
count *= 3;
|
|
872
|
+
value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}};
|
|
873
|
+
Module.ctx.uniform3iv(location, value);
|
|
874
|
+
},
|
|
875
|
+
|
|
876
|
+
glUniform4iv__sig: 'viii',
|
|
877
|
+
glUniform4iv: function(location, count, value) {
|
|
878
|
+
location = GL.uniforms[location];
|
|
879
|
+
count *= 4;
|
|
880
|
+
value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}};
|
|
881
|
+
Module.ctx.uniform4iv(location, value);
|
|
882
|
+
},
|
|
883
|
+
|
|
884
|
+
glUniform1fv__sig: 'viii',
|
|
885
|
+
glUniform1fv: function(location, count, value) {
|
|
886
|
+
location = GL.uniforms[location];
|
|
887
|
+
var view;
|
|
888
|
+
if (count == 1) {
|
|
889
|
+
// avoid allocation for the common case of uploading one uniform
|
|
890
|
+
view = GL.miniTempBufferViews[0];
|
|
891
|
+
view[0] = {{{ makeGetValue('value', '0', 'float') }}};
|
|
892
|
+
} else {
|
|
893
|
+
view = {{{ makeHEAPView('F32', 'value', 'value+count*4') }}};
|
|
894
|
+
}
|
|
895
|
+
Module.ctx.uniform1fv(location, view);
|
|
896
|
+
},
|
|
897
|
+
|
|
898
|
+
glUniform2fv__sig: 'viii',
|
|
899
|
+
glUniform2fv: function(location, count, value) {
|
|
900
|
+
location = GL.uniforms[location];
|
|
901
|
+
var view;
|
|
902
|
+
if (count == 1) {
|
|
903
|
+
// avoid allocation for the common case of uploading one uniform
|
|
904
|
+
view = GL.miniTempBufferViews[1];
|
|
905
|
+
view[0] = {{{ makeGetValue('value', '0', 'float') }}};
|
|
906
|
+
view[1] = {{{ makeGetValue('value', '4', 'float') }}};
|
|
907
|
+
} else {
|
|
908
|
+
view = {{{ makeHEAPView('F32', 'value', 'value+count*8') }}};
|
|
909
|
+
}
|
|
910
|
+
Module.ctx.uniform2fv(location, view);
|
|
911
|
+
},
|
|
912
|
+
|
|
913
|
+
glUniform3fv__sig: 'viii',
|
|
914
|
+
glUniform3fv: function(location, count, value) {
|
|
915
|
+
location = GL.uniforms[location];
|
|
916
|
+
var view;
|
|
917
|
+
if (count == 1) {
|
|
918
|
+
// avoid allocation for the common case of uploading one uniform
|
|
919
|
+
view = GL.miniTempBufferViews[2];
|
|
920
|
+
view[0] = {{{ makeGetValue('value', '0', 'float') }}};
|
|
921
|
+
view[1] = {{{ makeGetValue('value', '4', 'float') }}};
|
|
922
|
+
view[2] = {{{ makeGetValue('value', '8', 'float') }}};
|
|
923
|
+
} else {
|
|
924
|
+
view = {{{ makeHEAPView('F32', 'value', 'value+count*12') }}};
|
|
925
|
+
}
|
|
926
|
+
Module.ctx.uniform3fv(location, view);
|
|
927
|
+
},
|
|
928
|
+
|
|
929
|
+
glUniform4fv__sig: 'viii',
|
|
930
|
+
glUniform4fv: function(location, count, value) {
|
|
931
|
+
location = GL.uniforms[location];
|
|
932
|
+
var view;
|
|
933
|
+
if (count == 1) {
|
|
934
|
+
// avoid allocation for the common case of uploading one uniform
|
|
935
|
+
view = GL.miniTempBufferViews[3];
|
|
936
|
+
view[0] = {{{ makeGetValue('value', '0', 'float') }}};
|
|
937
|
+
view[1] = {{{ makeGetValue('value', '4', 'float') }}};
|
|
938
|
+
view[2] = {{{ makeGetValue('value', '8', 'float') }}};
|
|
939
|
+
view[3] = {{{ makeGetValue('value', '12', 'float') }}};
|
|
940
|
+
} else {
|
|
941
|
+
view = {{{ makeHEAPView('F32', 'value', 'value+count*16') }}};
|
|
942
|
+
}
|
|
943
|
+
Module.ctx.uniform4fv(location, view);
|
|
944
|
+
},
|
|
945
|
+
|
|
946
|
+
glUniformMatrix2fv__sig: 'viiii',
|
|
947
|
+
glUniformMatrix2fv: function(location, count, transpose, value) {
|
|
948
|
+
location = GL.uniforms[location];
|
|
949
|
+
var view;
|
|
950
|
+
if (count == 1) {
|
|
951
|
+
// avoid allocation for the common case of uploading one uniform matrix
|
|
952
|
+
view = GL.miniTempBufferViews[3];
|
|
953
|
+
for (var i = 0; i < 4; i++) {
|
|
954
|
+
view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}};
|
|
955
|
+
}
|
|
956
|
+
} else {
|
|
957
|
+
view = {{{ makeHEAPView('F32', 'value', 'value+count*16') }}};
|
|
958
|
+
}
|
|
959
|
+
Module.ctx.uniformMatrix2fv(location, transpose, view);
|
|
960
|
+
},
|
|
961
|
+
|
|
962
|
+
glUniformMatrix3fv__sig: 'viiii',
|
|
963
|
+
glUniformMatrix3fv: function(location, count, transpose, value) {
|
|
964
|
+
location = GL.uniforms[location];
|
|
965
|
+
var view;
|
|
966
|
+
if (count == 1) {
|
|
967
|
+
// avoid allocation for the common case of uploading one uniform matrix
|
|
968
|
+
view = GL.miniTempBufferViews[8];
|
|
969
|
+
for (var i = 0; i < 9; i++) {
|
|
970
|
+
view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}};
|
|
971
|
+
}
|
|
972
|
+
} else {
|
|
973
|
+
view = {{{ makeHEAPView('F32', 'value', 'value+count*36') }}};
|
|
974
|
+
}
|
|
975
|
+
Module.ctx.uniformMatrix3fv(location, transpose, view);
|
|
976
|
+
},
|
|
977
|
+
|
|
978
|
+
glUniformMatrix4fv__sig: 'viiii',
|
|
979
|
+
glUniformMatrix4fv: function(location, count, transpose, value) {
|
|
980
|
+
location = GL.uniforms[location];
|
|
981
|
+
var view;
|
|
982
|
+
if (count == 1) {
|
|
983
|
+
// avoid allocation for the common case of uploading one uniform matrix
|
|
984
|
+
view = GL.miniTempBufferViews[15];
|
|
985
|
+
for (var i = 0; i < 16; i++) {
|
|
986
|
+
view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}};
|
|
987
|
+
}
|
|
988
|
+
} else {
|
|
989
|
+
view = {{{ makeHEAPView('F32', 'value', 'value+count*64') }}};
|
|
990
|
+
}
|
|
991
|
+
Module.ctx.uniformMatrix4fv(location, transpose, view);
|
|
992
|
+
},
|
|
993
|
+
|
|
994
|
+
glBindBuffer__sig: 'vii',
|
|
995
|
+
glBindBuffer: function(target, buffer) {
|
|
996
|
+
var bufferObj = buffer ? GL.buffers[buffer] : null;
|
|
997
|
+
|
|
998
|
+
if (target == Module.ctx.ARRAY_BUFFER) {
|
|
999
|
+
GL.currArrayBuffer = buffer;
|
|
1000
|
+
} else if (target == Module.ctx.ELEMENT_ARRAY_BUFFER) {
|
|
1001
|
+
GL.currElementArrayBuffer = buffer;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
Module.ctx.bindBuffer(target, bufferObj);
|
|
1005
|
+
},
|
|
1006
|
+
|
|
1007
|
+
glVertexAttrib1fv__sig: 'vii',
|
|
1008
|
+
glVertexAttrib1fv: function(index, v) {
|
|
1009
|
+
v = {{{ makeHEAPView('F32', 'v', 'v+' + (1*4)) }}};
|
|
1010
|
+
Module.ctx.vertexAttrib1fv(index, v);
|
|
1011
|
+
},
|
|
1012
|
+
|
|
1013
|
+
glVertexAttrib2fv__sig: 'vii',
|
|
1014
|
+
glVertexAttrib2fv: function(index, v) {
|
|
1015
|
+
v = {{{ makeHEAPView('F32', 'v', 'v+' + (2*4)) }}};
|
|
1016
|
+
Module.ctx.vertexAttrib2fv(index, v);
|
|
1017
|
+
},
|
|
1018
|
+
|
|
1019
|
+
glVertexAttrib3fv__sig: 'vii',
|
|
1020
|
+
glVertexAttrib3fv: function(index, v) {
|
|
1021
|
+
v = {{{ makeHEAPView('F32', 'v', 'v+' + (3*4)) }}};
|
|
1022
|
+
Module.ctx.vertexAttrib3fv(index, v);
|
|
1023
|
+
},
|
|
1024
|
+
|
|
1025
|
+
glVertexAttrib4fv__sig: 'vii',
|
|
1026
|
+
glVertexAttrib4fv: function(index, v) {
|
|
1027
|
+
v = {{{ makeHEAPView('F32', 'v', 'v+' + (4*4)) }}};
|
|
1028
|
+
Module.ctx.vertexAttrib4fv(index, v);
|
|
1029
|
+
},
|
|
1030
|
+
|
|
1031
|
+
glGetAttribLocation__sig: 'vii',
|
|
1032
|
+
glGetAttribLocation: function(program, name) {
|
|
1033
|
+
program = GL.programs[program];
|
|
1034
|
+
name = Pointer_stringify(name);
|
|
1035
|
+
return Module.ctx.getAttribLocation(program, name);
|
|
1036
|
+
},
|
|
1037
|
+
|
|
1038
|
+
glGetActiveAttrib__sig: 'viiiiiii',
|
|
1039
|
+
glGetActiveAttrib: function(program, index, bufSize, length, size, type, name) {
|
|
1040
|
+
program = GL.programs[program];
|
|
1041
|
+
var info = Module.ctx.getActiveAttrib(program, index);
|
|
1042
|
+
|
|
1043
|
+
var infoname = info.name.slice(0, Math.max(0, bufSize - 1));
|
|
1044
|
+
writeStringToMemory(infoname, name);
|
|
1045
|
+
|
|
1046
|
+
if (length) {
|
|
1047
|
+
{{{ makeSetValue('length', '0', 'infoname.length', 'i32') }}};
|
|
1048
|
+
}
|
|
1049
|
+
if (size) {
|
|
1050
|
+
{{{ makeSetValue('size', '0', 'info.size', 'i32') }}};
|
|
1051
|
+
}
|
|
1052
|
+
if (type) {
|
|
1053
|
+
{{{ makeSetValue('type', '0', 'info.type', 'i32') }}};
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
|
|
1057
|
+
glCreateShader__sig: 'ii',
|
|
1058
|
+
glCreateShader: function(shaderType) {
|
|
1059
|
+
var id = GL.getNewId(GL.shaders);
|
|
1060
|
+
GL.shaders[id] = Module.ctx.createShader(shaderType);
|
|
1061
|
+
return id;
|
|
1062
|
+
},
|
|
1063
|
+
|
|
1064
|
+
glDeleteShader__sig: 'vi',
|
|
1065
|
+
glDeleteShader: function(shader) {
|
|
1066
|
+
Module.ctx.deleteShader(GL.shaders[shader]);
|
|
1067
|
+
GL.shaders[shader] = null;
|
|
1068
|
+
},
|
|
1069
|
+
|
|
1070
|
+
glGetAttachedShaders__sig: 'viiii',
|
|
1071
|
+
glGetAttachedShaders: function(program, maxCount, count, shaders) {
|
|
1072
|
+
var result = Module.ctx.getAttachedShaders(GL.programs[program]);
|
|
1073
|
+
var len = result.length;
|
|
1074
|
+
if (len > maxCount) {
|
|
1075
|
+
len = maxCount;
|
|
1076
|
+
}
|
|
1077
|
+
{{{ makeSetValue('count', '0', 'len', 'i32') }}};
|
|
1078
|
+
for (var i = 0; i < len; ++i) {
|
|
1079
|
+
{{{ makeSetValue('shaders', 'i*4', 'GL.shaders[result[i]]', 'i32') }}};
|
|
1080
|
+
}
|
|
1081
|
+
},
|
|
1082
|
+
|
|
1083
|
+
glShaderSource__sig: 'viiii',
|
|
1084
|
+
glShaderSource: function(shader, count, string, length) {
|
|
1085
|
+
var source = GL.getSource(shader, count, string, length);
|
|
1086
|
+
Module.ctx.shaderSource(GL.shaders[shader], source);
|
|
1087
|
+
},
|
|
1088
|
+
|
|
1089
|
+
glGetShaderSource__sig: 'viiii',
|
|
1090
|
+
glGetShaderSource: function(shader, bufSize, length, source) {
|
|
1091
|
+
var result = Module.ctx.getShaderSource(GL.shaders[shader]);
|
|
1092
|
+
result = result.slice(0, Math.max(0, bufSize - 1));
|
|
1093
|
+
writeStringToMemory(result, source);
|
|
1094
|
+
if (length) {
|
|
1095
|
+
{{{ makeSetValue('length', '0', 'result.length', 'i32') }}};
|
|
1096
|
+
}
|
|
1097
|
+
},
|
|
1098
|
+
|
|
1099
|
+
glCompileShader__sig: 'vi',
|
|
1100
|
+
glCompileShader: function(shader) {
|
|
1101
|
+
Module.ctx.compileShader(GL.shaders[shader]);
|
|
1102
|
+
},
|
|
1103
|
+
|
|
1104
|
+
glGetShaderInfoLog__sig: 'viiii',
|
|
1105
|
+
glGetShaderInfoLog: function(shader, maxLength, length, infoLog) {
|
|
1106
|
+
var log = Module.ctx.getShaderInfoLog(GL.shaders[shader]);
|
|
1107
|
+
// Work around a bug in Chromium which causes getShaderInfoLog to return null
|
|
1108
|
+
if (!log) {
|
|
1109
|
+
log = "";
|
|
1110
|
+
}
|
|
1111
|
+
log = log.substr(0, maxLength - 1);
|
|
1112
|
+
writeStringToMemory(log, infoLog);
|
|
1113
|
+
if (length) {
|
|
1114
|
+
{{{ makeSetValue('length', '0', 'log.length', 'i32') }}}
|
|
1115
|
+
}
|
|
1116
|
+
},
|
|
1117
|
+
|
|
1118
|
+
glGetShaderiv__sig: 'viii',
|
|
1119
|
+
glGetShaderiv : function(shader, pname, p) {
|
|
1120
|
+
if (pname == 0x8B84) { // GL_INFO_LOG_LENGTH
|
|
1121
|
+
{{{ makeSetValue('p', '0', 'Module.ctx.getShaderInfoLog(GL.shaders[shader]).length + 1', 'i32') }}};
|
|
1122
|
+
} else {
|
|
1123
|
+
{{{ makeSetValue('p', '0', 'Module.ctx.getShaderParameter(GL.shaders[shader], pname)', 'i32') }}};
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
|
|
1127
|
+
glGetProgramiv__sig: 'viii',
|
|
1128
|
+
glGetProgramiv : function(program, pname, p) {
|
|
1129
|
+
if (pname == 0x8B84) { // GL_INFO_LOG_LENGTH
|
|
1130
|
+
{{{ makeSetValue('p', '0', 'Module.ctx.getProgramInfoLog(GL.programs[program]).length + 1', 'i32') }}};
|
|
1131
|
+
} else {
|
|
1132
|
+
{{{ makeSetValue('p', '0', 'Module.ctx.getProgramParameter(GL.programs[program], pname)', 'i32') }}};
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
|
|
1136
|
+
glIsShader__sig: 'ii',
|
|
1137
|
+
glIsShader: function(shader) {
|
|
1138
|
+
var s = GL.shaders[shader];
|
|
1139
|
+
if (!s) return 0;
|
|
1140
|
+
return Module.ctx.isShader(s);
|
|
1141
|
+
},
|
|
1142
|
+
|
|
1143
|
+
glCreateProgram__sig: 'i',
|
|
1144
|
+
glCreateProgram: function() {
|
|
1145
|
+
var id = GL.getNewId(GL.programs);
|
|
1146
|
+
var program = Module.ctx.createProgram();
|
|
1147
|
+
program.name = id;
|
|
1148
|
+
GL.programs[id] = program;
|
|
1149
|
+
return id;
|
|
1150
|
+
},
|
|
1151
|
+
|
|
1152
|
+
glDeleteProgram__sig: 'vi',
|
|
1153
|
+
glDeleteProgram: function(program) {
|
|
1154
|
+
var program = GL.programs[program];
|
|
1155
|
+
Module.ctx.deleteProgram(program);
|
|
1156
|
+
program.name = 0;
|
|
1157
|
+
GL.programs[program] = null;
|
|
1158
|
+
GL.uniformTable[program] = null;
|
|
1159
|
+
},
|
|
1160
|
+
|
|
1161
|
+
glAttachShader__sig: 'vii',
|
|
1162
|
+
glAttachShader: function(program, shader) {
|
|
1163
|
+
Module.ctx.attachShader(GL.programs[program],
|
|
1164
|
+
GL.shaders[shader]);
|
|
1165
|
+
},
|
|
1166
|
+
|
|
1167
|
+
glDetachShader__sig: 'vii',
|
|
1168
|
+
glDetachShader: function(program, shader) {
|
|
1169
|
+
Module.ctx.detachShader(GL.programs[program],
|
|
1170
|
+
GL.shaders[shader]);
|
|
1171
|
+
},
|
|
1172
|
+
|
|
1173
|
+
glGetShaderPrecisionFormat: function(shaderType, precisionType, range, precision) {
|
|
1174
|
+
var result = Module.ctx.getShaderPrecisionFormat(shaderType, precisionType);
|
|
1175
|
+
{{{ makeSetValue('range', '0', 'result.rangeMin', 'i32') }}};
|
|
1176
|
+
{{{ makeSetValue('range', '4', 'result.rangeMax', 'i32') }}};
|
|
1177
|
+
{{{ makeSetValue('precision', '0', 'result.precision', 'i32') }}};
|
|
1178
|
+
},
|
|
1179
|
+
|
|
1180
|
+
glLinkProgram__sig: 'vi',
|
|
1181
|
+
glLinkProgram: function(program) {
|
|
1182
|
+
Module.ctx.linkProgram(GL.programs[program]);
|
|
1183
|
+
GL.uniformTable[program] = {}; // uniforms no longer keep the same names after linking
|
|
1184
|
+
},
|
|
1185
|
+
|
|
1186
|
+
glGetProgramInfoLog__sig: 'viiii',
|
|
1187
|
+
glGetProgramInfoLog: function(program, maxLength, length, infoLog) {
|
|
1188
|
+
var log = Module.ctx.getProgramInfoLog(GL.programs[program]);
|
|
1189
|
+
// Work around a bug in Chromium which causes getProgramInfoLog to return null
|
|
1190
|
+
if (!log) {
|
|
1191
|
+
log = "";
|
|
1192
|
+
}
|
|
1193
|
+
log = log.substr(0, maxLength - 1);
|
|
1194
|
+
writeStringToMemory(log, infoLog);
|
|
1195
|
+
if (length) {
|
|
1196
|
+
{{{ makeSetValue('length', '0', 'log.length', 'i32') }}}
|
|
1197
|
+
}
|
|
1198
|
+
},
|
|
1199
|
+
|
|
1200
|
+
glUseProgram__sig: 'vi',
|
|
1201
|
+
glUseProgram: function(program) {
|
|
1202
|
+
Module.ctx.useProgram(program ? GL.programs[program] : null);
|
|
1203
|
+
},
|
|
1204
|
+
|
|
1205
|
+
glValidateProgram__sig: 'vi',
|
|
1206
|
+
glValidateProgram: function(program) {
|
|
1207
|
+
Module.ctx.validateProgram(GL.programs[program]);
|
|
1208
|
+
},
|
|
1209
|
+
|
|
1210
|
+
glIsProgram__sig: 'ii',
|
|
1211
|
+
glIsProgram: function(program) {
|
|
1212
|
+
var program = GL.programs[program];
|
|
1213
|
+
if (!program) return 0;
|
|
1214
|
+
return Module.ctx.isProgram(program);
|
|
1215
|
+
},
|
|
1216
|
+
|
|
1217
|
+
glBindAttribLocation__sig: 'viii',
|
|
1218
|
+
glBindAttribLocation: function(program, index, name) {
|
|
1219
|
+
name = Pointer_stringify(name);
|
|
1220
|
+
Module.ctx.bindAttribLocation(GL.programs[program], index, name);
|
|
1221
|
+
},
|
|
1222
|
+
|
|
1223
|
+
glBindFramebuffer__sig: 'vii',
|
|
1224
|
+
glBindFramebuffer: function(target, framebuffer) {
|
|
1225
|
+
Module.ctx.bindFramebuffer(target, framebuffer ? GL.framebuffers[framebuffer] : null);
|
|
1226
|
+
},
|
|
1227
|
+
|
|
1228
|
+
glGenFramebuffers__sig: 'vii',
|
|
1229
|
+
glGenFramebuffers: function(n, ids) {
|
|
1230
|
+
for (var i = 0; i < n; ++i) {
|
|
1231
|
+
var id = GL.getNewId(GL.framebuffers);
|
|
1232
|
+
var framebuffer = Module.ctx.createFramebuffer();
|
|
1233
|
+
framebuffer.name = id;
|
|
1234
|
+
GL.framebuffers[id] = framebuffer;
|
|
1235
|
+
{{{ makeSetValue('ids', 'i*4', 'id', 'i32') }}};
|
|
1236
|
+
}
|
|
1237
|
+
},
|
|
1238
|
+
|
|
1239
|
+
glDeleteFramebuffers__sig: 'vii',
|
|
1240
|
+
glDeleteFramebuffers: function(n, framebuffers) {
|
|
1241
|
+
for (var i = 0; i < n; ++i) {
|
|
1242
|
+
var id = {{{ makeGetValue('framebuffers', 'i*4', 'i32') }}};
|
|
1243
|
+
var framebuffer = GL.framebuffers[id];
|
|
1244
|
+
Module.ctx.deleteFramebuffer(framebuffer);
|
|
1245
|
+
framebuffer.name = 0;
|
|
1246
|
+
GL.framebuffers[id] = null;
|
|
1247
|
+
}
|
|
1248
|
+
},
|
|
1249
|
+
|
|
1250
|
+
glFramebufferRenderbuffer__sig: 'viiii',
|
|
1251
|
+
glFramebufferRenderbuffer: function(target, attachment, renderbuffertarget, renderbuffer) {
|
|
1252
|
+
Module.ctx.framebufferRenderbuffer(target, attachment, renderbuffertarget,
|
|
1253
|
+
GL.renderbuffers[renderbuffer]);
|
|
1254
|
+
},
|
|
1255
|
+
|
|
1256
|
+
glFramebufferTexture2D__sig: 'viiiii',
|
|
1257
|
+
glFramebufferTexture2D: function(target, attachment, textarget, texture, level) {
|
|
1258
|
+
Module.ctx.framebufferTexture2D(target, attachment, textarget,
|
|
1259
|
+
GL.textures[texture], level);
|
|
1260
|
+
},
|
|
1261
|
+
|
|
1262
|
+
glGetFramebufferAttachmentParameteriv__sig: 'viiii',
|
|
1263
|
+
glGetFramebufferAttachmentParameteriv: function(target, attachment, pname, params) {
|
|
1264
|
+
var result = Module.ctx.getFramebufferAttachmentParameter(target, attachment, pname);
|
|
1265
|
+
{{{ makeSetValue('params', '0', 'params', 'i32') }}};
|
|
1266
|
+
},
|
|
1267
|
+
|
|
1268
|
+
glIsFramebuffer__sig: 'ii',
|
|
1269
|
+
glIsFramebuffer: function(framebuffer) {
|
|
1270
|
+
var fb = GL.framebuffers[framebuffer];
|
|
1271
|
+
if (!fb) return 0;
|
|
1272
|
+
return Module.ctx.isFramebuffer(fb);
|
|
1273
|
+
},
|
|
1274
|
+
|
|
1275
|
+
#if DISABLE_GL_EMULATION == 0
|
|
1276
|
+
|
|
1277
|
+
// GL emulation: provides misc. functionality not present in OpenGL ES 2.0 or WebGL
|
|
1278
|
+
|
|
1279
|
+
$GLEmulation__postset: 'GLEmulation.init();',
|
|
1280
|
+
$GLEmulation: {
|
|
1281
|
+
// Fog support. Partial, we assume shaders are used that implement fog. We just pass them uniforms
|
|
1282
|
+
fogStart: 0,
|
|
1283
|
+
fogEnd: 1,
|
|
1284
|
+
fogDensity: 1.0,
|
|
1285
|
+
fogColor: null,
|
|
1286
|
+
fogMode: 0x0800, // GL_EXP
|
|
1287
|
+
fogEnabled: false,
|
|
1288
|
+
|
|
1289
|
+
// VAO support
|
|
1290
|
+
vaos: [],
|
|
1291
|
+
currentVao: null,
|
|
1292
|
+
enabledVertexAttribArrays: {}, // helps with vao cleanups
|
|
1293
|
+
|
|
1294
|
+
hasRunInit: false,
|
|
1295
|
+
|
|
1296
|
+
init: function() {
|
|
1297
|
+
// Do not activate immediate/emulation code (e.g. replace glDrawElements) when in FULL_ES2 mode.
|
|
1298
|
+
// We do not need full emulation, we instead emulate client-side arrays etc. in FULL_ES2 code in
|
|
1299
|
+
// a straightforward manner, and avoid not having a bound buffer be ambiguous between es2 emulation
|
|
1300
|
+
// code and legacy gl emulation code.
|
|
1301
|
+
#if FULL_ES2
|
|
1302
|
+
return;
|
|
1303
|
+
#endif
|
|
1304
|
+
|
|
1305
|
+
if (GLEmulation.hasRunInit) {
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
GLEmulation.hasRunInit = true;
|
|
1309
|
+
|
|
1310
|
+
GLEmulation.fogColor = new Float32Array(4);
|
|
1311
|
+
|
|
1312
|
+
// Add some emulation workarounds
|
|
1313
|
+
Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work');
|
|
1314
|
+
#if GL_UNSAFE_OPTS == 0
|
|
1315
|
+
Module.printErr('WARNING: using emscripten GL emulation unsafe opts. If weirdness happens, try -s GL_UNSAFE_OPTS=0');
|
|
1316
|
+
#endif
|
|
1317
|
+
|
|
1318
|
+
// XXX some of the capabilities we don't support may lead to incorrect rendering, if we do not emulate them in shaders
|
|
1319
|
+
var validCapabilities = {
|
|
1320
|
+
0x0B44: 1, // GL_CULL_FACE
|
|
1321
|
+
0x0BE2: 1, // GL_BLEND
|
|
1322
|
+
0x0BD0: 1, // GL_DITHER,
|
|
1323
|
+
0x0B90: 1, // GL_STENCIL_TEST
|
|
1324
|
+
0x0B71: 1, // GL_DEPTH_TEST
|
|
1325
|
+
0x0C11: 1, // GL_SCISSOR_TEST
|
|
1326
|
+
0x8037: 1, // GL_POLYGON_OFFSET_FILL
|
|
1327
|
+
0x809E: 1, // GL_SAMPLE_ALPHA_TO_COVERAGE
|
|
1328
|
+
0x80A0: 1 // GL_SAMPLE_COVERAGE
|
|
1329
|
+
};
|
|
1330
|
+
|
|
1331
|
+
var glEnable = _glEnable;
|
|
1332
|
+
_glEnable = function(cap) {
|
|
1333
|
+
// Clean up the renderer on any change to the rendering state. The optimization of
|
|
1334
|
+
// skipping renderer setup is aimed at the case of multiple glDraw* right after each other
|
|
1335
|
+
if (GL.immediate.lastRenderer) GL.immediate.lastRenderer.cleanup();
|
|
1336
|
+
if (cap == 0x0B60 /* GL_FOG */) {
|
|
1337
|
+
GLEmulation.fogEnabled = true;
|
|
1338
|
+
return;
|
|
1339
|
+
} else if (cap == 0x0de1 /* GL_TEXTURE_2D */) {
|
|
1340
|
+
// XXX not according to spec, and not in desktop GL, but works in some GLES1.x apparently, so support
|
|
1341
|
+
// it by forwarding to glEnableClientState
|
|
1342
|
+
/* Actually, let's not, for now. (This sounds exceedingly broken)
|
|
1343
|
+
* This is in gl_ps_workaround2.c.
|
|
1344
|
+
_glEnableClientState(cap);
|
|
1345
|
+
*/
|
|
1346
|
+
return;
|
|
1347
|
+
} else if (!(cap in validCapabilities)) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
glEnable(cap);
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1353
|
+
var glDisable = _glDisable;
|
|
1354
|
+
_glDisable = function(cap) {
|
|
1355
|
+
if (GL.immediate.lastRenderer) GL.immediate.lastRenderer.cleanup();
|
|
1356
|
+
if (cap == 0x0B60 /* GL_FOG */) {
|
|
1357
|
+
GLEmulation.fogEnabled = false;
|
|
1358
|
+
return;
|
|
1359
|
+
} else if (cap == 0x0de1 /* GL_TEXTURE_2D */) {
|
|
1360
|
+
// XXX not according to spec, and not in desktop GL, but works in some GLES1.x apparently, so support
|
|
1361
|
+
// it by forwarding to glDisableClientState
|
|
1362
|
+
/* Actually, let's not, for now. (This sounds exceedingly broken)
|
|
1363
|
+
* This is in gl_ps_workaround2.c.
|
|
1364
|
+
_glDisableClientState(cap);
|
|
1365
|
+
*/
|
|
1366
|
+
return;
|
|
1367
|
+
} else if (!(cap in validCapabilities)) {
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
glDisable(cap);
|
|
1371
|
+
};
|
|
1372
|
+
_glIsEnabled = function(cap) {
|
|
1373
|
+
if (cap == 0x0B60 /* GL_FOG */) {
|
|
1374
|
+
return GLEmulation.fogEnabled ? 1 : 0;
|
|
1375
|
+
} else if (!(cap in validCapabilities)) {
|
|
1376
|
+
return 0;
|
|
1377
|
+
}
|
|
1378
|
+
return Module.ctx.isEnabled(cap);
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
var glGetBooleanv = _glGetBooleanv;
|
|
1382
|
+
_glGetBooleanv = function(pname, p) {
|
|
1383
|
+
var attrib = GLEmulation.getAttributeFromCapability(pname);
|
|
1384
|
+
if (attrib !== null) {
|
|
1385
|
+
var result = GL.immediate.enabledClientAttributes[attrib];
|
|
1386
|
+
{{{ makeSetValue('p', '0', 'result === true ? 1 : 0', 'i8') }}};
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
glGetBooleanv(pname, p);
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
var glGetIntegerv = _glGetIntegerv;
|
|
1393
|
+
_glGetIntegerv = function(pname, params) {
|
|
1394
|
+
switch (pname) {
|
|
1395
|
+
case 0x84E2: pname = Module.ctx.MAX_TEXTURE_IMAGE_UNITS /* fake it */; break; // GL_MAX_TEXTURE_UNITS
|
|
1396
|
+
case 0x8B4A: { // GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
|
|
1397
|
+
var result = Module.ctx.getParameter(Module.ctx.MAX_VERTEX_UNIFORM_VECTORS);
|
|
1398
|
+
{{{ makeSetValue('params', '0', 'result*4', 'i32') }}}; // GLES gives num of 4-element vectors, GL wants individual components, so multiply
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
case 0x8B49: { // GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
|
|
1402
|
+
var result = Module.ctx.getParameter(Module.ctx.MAX_FRAGMENT_UNIFORM_VECTORS);
|
|
1403
|
+
{{{ makeSetValue('params', '0', 'result*4', 'i32') }}}; // GLES gives num of 4-element vectors, GL wants individual components, so multiply
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
case 0x8B4B: { // GL_MAX_VARYING_FLOATS_ARB
|
|
1407
|
+
var result = Module.ctx.getParameter(Module.ctx.MAX_VARYING_VECTORS);
|
|
1408
|
+
{{{ makeSetValue('params', '0', 'result*4', 'i32') }}}; // GLES gives num of 4-element vectors, GL wants individual components, so multiply
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
case 0x8871: pname = Module.ctx.MAX_COMBINED_TEXTURE_IMAGE_UNITS /* close enough */; break; // GL_MAX_TEXTURE_COORDS
|
|
1412
|
+
case 0x807A: { // GL_VERTEX_ARRAY_SIZE
|
|
1413
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.VERTEX];
|
|
1414
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.size : 0', 'i32') }}};
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
case 0x807B: { // GL_VERTEX_ARRAY_TYPE
|
|
1418
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.VERTEX];
|
|
1419
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.type : 0', 'i32') }}};
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
case 0x807C: { // GL_VERTEX_ARRAY_STRIDE
|
|
1423
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.VERTEX];
|
|
1424
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.stride : 0', 'i32') }}};
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
case 0x8081: { // GL_COLOR_ARRAY_SIZE
|
|
1428
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.COLOR];
|
|
1429
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.size : 0', 'i32') }}};
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
case 0x8082: { // GL_COLOR_ARRAY_TYPE
|
|
1433
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.COLOR];
|
|
1434
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.type : 0', 'i32') }}};
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
case 0x8083: { // GL_COLOR_ARRAY_STRIDE
|
|
1438
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.COLOR];
|
|
1439
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.stride : 0', 'i32') }}};
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
case 0x8088: { // GL_TEXTURE_COORD_ARRAY_SIZE
|
|
1443
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0];
|
|
1444
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.size : 0', 'i32') }}};
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
case 0x8089: { // GL_TEXTURE_COORD_ARRAY_TYPE
|
|
1448
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0];
|
|
1449
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.type : 0', 'i32') }}};
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
case 0x808A: { // GL_TEXTURE_COORD_ARRAY_STRIDE
|
|
1453
|
+
var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0];
|
|
1454
|
+
{{{ makeSetValue('params', '0', 'attribute ? attribute.stride : 0', 'i32') }}};
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
glGetIntegerv(pname, params);
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
var glGetString = _glGetString;
|
|
1462
|
+
_glGetString = function(name_) {
|
|
1463
|
+
switch(name_) {
|
|
1464
|
+
case 0x1F03 /* GL_EXTENSIONS */: // Add various extensions that we can support
|
|
1465
|
+
return allocate(intArrayFromString(Module.ctx.getSupportedExtensions().join(' ') +
|
|
1466
|
+
' GL_EXT_texture_env_combine GL_ARB_texture_env_crossbar GL_ATI_texture_env_combine3 GL_NV_texture_env_combine4 GL_EXT_texture_env_dot3 GL_ARB_multitexture GL_ARB_vertex_buffer_object GL_EXT_framebuffer_object GL_ARB_vertex_program GL_ARB_fragment_program GL_ARB_shading_language_100 GL_ARB_shader_objects GL_ARB_vertex_shader GL_ARB_fragment_shader GL_ARB_texture_cube_map GL_EXT_draw_range_elements' +
|
|
1467
|
+
(GL.compressionExt ? ' GL_ARB_texture_compression GL_EXT_texture_compression_s3tc' : '') +
|
|
1468
|
+
(GL.anisotropicExt ? ' GL_EXT_texture_filter_anisotropic' : '')
|
|
1469
|
+
), 'i8', ALLOC_NORMAL);
|
|
1470
|
+
}
|
|
1471
|
+
return glGetString(name_);
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1474
|
+
// Do some automatic rewriting to work around GLSL differences. Note that this must be done in
|
|
1475
|
+
// tandem with the rest of the program, by itself it cannot suffice.
|
|
1476
|
+
// Note that we need to remember shader types for this rewriting, saving sources makes it easier to debug.
|
|
1477
|
+
GL.shaderInfos = {};
|
|
1478
|
+
#if GL_DEBUG
|
|
1479
|
+
GL.shaderSources = {};
|
|
1480
|
+
GL.shaderOriginalSources = {};
|
|
1481
|
+
#endif
|
|
1482
|
+
var glCreateShader = _glCreateShader;
|
|
1483
|
+
_glCreateShader = function(shaderType) {
|
|
1484
|
+
var id = glCreateShader(shaderType);
|
|
1485
|
+
GL.shaderInfos[id] = {
|
|
1486
|
+
type: shaderType,
|
|
1487
|
+
ftransform: false
|
|
1488
|
+
};
|
|
1489
|
+
return id;
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
var glShaderSource = _glShaderSource;
|
|
1493
|
+
_glShaderSource = function(shader, count, string, length) {
|
|
1494
|
+
var source = GL.getSource(shader, count, string, length);
|
|
1495
|
+
#if GL_DEBUG
|
|
1496
|
+
console.log("glShaderSource: Input: \n" + source);
|
|
1497
|
+
GL.shaderOriginalSources[shader] = source;
|
|
1498
|
+
#endif
|
|
1499
|
+
// XXX We add attributes and uniforms to shaders. The program can ask for the # of them, and see the
|
|
1500
|
+
// ones we generated, potentially confusing it? Perhaps we should hide them.
|
|
1501
|
+
if (GL.shaderInfos[shader].type == Module.ctx.VERTEX_SHADER) {
|
|
1502
|
+
// Replace ftransform() with explicit project/modelview transforms, and add position and matrix info.
|
|
1503
|
+
var has_pm = source.search(/u_projection/) >= 0;
|
|
1504
|
+
var has_mm = source.search(/u_modelView/) >= 0;
|
|
1505
|
+
var has_pv = source.search(/a_position/) >= 0;
|
|
1506
|
+
var need_pm = 0, need_mm = 0, need_pv = 0;
|
|
1507
|
+
var old = source;
|
|
1508
|
+
source = source.replace(/ftransform\(\)/g, '(u_projection * u_modelView * a_position)');
|
|
1509
|
+
if (old != source) need_pm = need_mm = need_pv = 1;
|
|
1510
|
+
old = source;
|
|
1511
|
+
source = source.replace(/gl_ProjectionMatrix/g, 'u_projection');
|
|
1512
|
+
if (old != source) need_pm = 1;
|
|
1513
|
+
old = source;
|
|
1514
|
+
source = source.replace(/gl_ModelViewMatrixTranspose\[2\]/g, 'vec4(u_modelView[0][2], u_modelView[1][2], u_modelView[2][2], u_modelView[3][2])'); // XXX extremely inefficient
|
|
1515
|
+
if (old != source) need_mm = 1;
|
|
1516
|
+
old = source;
|
|
1517
|
+
source = source.replace(/gl_ModelViewMatrix/g, 'u_modelView');
|
|
1518
|
+
if (old != source) need_mm = 1;
|
|
1519
|
+
old = source;
|
|
1520
|
+
source = source.replace(/gl_Vertex/g, 'a_position');
|
|
1521
|
+
if (old != source) need_pv = 1;
|
|
1522
|
+
old = source;
|
|
1523
|
+
source = source.replace(/gl_ModelViewProjectionMatrix/g, '(u_projection * u_modelView)');
|
|
1524
|
+
if (old != source) need_pm = need_mm = 1;
|
|
1525
|
+
if (need_pv && !has_pv) source = 'attribute vec4 a_position; \n' + source;
|
|
1526
|
+
if (need_mm && !has_mm) source = 'uniform mat4 u_modelView; \n' + source;
|
|
1527
|
+
if (need_pm && !has_pm) source = 'uniform mat4 u_projection; \n' + source;
|
|
1528
|
+
GL.shaderInfos[shader].ftransform = need_pm || need_mm || need_pv; // we will need to provide the fixed function stuff as attributes and uniforms
|
|
1529
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
1530
|
+
// XXX To handle both regular texture mapping and cube mapping, we use vec4 for tex coordinates.
|
|
1531
|
+
var old = source;
|
|
1532
|
+
var need_vtc = source.search('v_texCoord' + i) == -1;
|
|
1533
|
+
source = source.replace(new RegExp('gl_TexCoord\\[' + i + '\\]', 'g'), 'v_texCoord' + i)
|
|
1534
|
+
.replace(new RegExp('gl_MultiTexCoord' + i, 'g'), 'a_texCoord' + i);
|
|
1535
|
+
if (source != old) {
|
|
1536
|
+
source = 'attribute vec4 a_texCoord' + i + '; \n' + source;
|
|
1537
|
+
if (need_vtc) {
|
|
1538
|
+
source = 'varying vec4 v_texCoord' + i + '; \n' + source;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
old = source;
|
|
1543
|
+
source = source.replace(new RegExp('gl_TextureMatrix\\[' + i + '\\]', 'g'), 'u_textureMatrix' + i);
|
|
1544
|
+
if (source != old) {
|
|
1545
|
+
source = 'uniform mat4 u_textureMatrix' + i + '; \n' + source;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
if (source.indexOf('gl_FrontColor') >= 0) {
|
|
1549
|
+
source = 'varying vec4 v_color; \n' +
|
|
1550
|
+
source.replace(/gl_FrontColor/g, 'v_color');
|
|
1551
|
+
}
|
|
1552
|
+
if (source.indexOf('gl_Color') >= 0) {
|
|
1553
|
+
source = 'attribute vec4 a_color; \n' +
|
|
1554
|
+
source.replace(/gl_Color/g, 'a_color');
|
|
1555
|
+
}
|
|
1556
|
+
if (source.indexOf('gl_Normal') >= 0) {
|
|
1557
|
+
source = 'attribute vec3 a_normal; \n' +
|
|
1558
|
+
source.replace(/gl_Normal/g, 'a_normal');
|
|
1559
|
+
}
|
|
1560
|
+
// fog
|
|
1561
|
+
if (source.indexOf('gl_FogFragCoord') >= 0) {
|
|
1562
|
+
source = 'varying float v_fogFragCoord; \n' +
|
|
1563
|
+
source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
|
|
1564
|
+
}
|
|
1565
|
+
} else { // Fragment shader
|
|
1566
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
1567
|
+
var old = source;
|
|
1568
|
+
source = source.replace(new RegExp('gl_TexCoord\\[' + i + '\\]', 'g'), 'v_texCoord' + i);
|
|
1569
|
+
if (source != old) {
|
|
1570
|
+
source = 'varying vec4 v_texCoord' + i + '; \n' + source;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
if (source.indexOf('gl_Color') >= 0) {
|
|
1574
|
+
source = 'varying vec4 v_color; \n' + source.replace(/gl_Color/g, 'v_color');
|
|
1575
|
+
}
|
|
1576
|
+
if (source.indexOf('gl_Fog.color') >= 0) {
|
|
1577
|
+
source = 'uniform vec4 u_fogColor; \n' +
|
|
1578
|
+
source.replace(/gl_Fog.color/g, 'u_fogColor');
|
|
1579
|
+
}
|
|
1580
|
+
if (source.indexOf('gl_Fog.end') >= 0) {
|
|
1581
|
+
source = 'uniform float u_fogEnd; \n' +
|
|
1582
|
+
source.replace(/gl_Fog.end/g, 'u_fogEnd');
|
|
1583
|
+
}
|
|
1584
|
+
if (source.indexOf('gl_Fog.scale') >= 0) {
|
|
1585
|
+
source = 'uniform float u_fogScale; \n' +
|
|
1586
|
+
source.replace(/gl_Fog.scale/g, 'u_fogScale');
|
|
1587
|
+
}
|
|
1588
|
+
if (source.indexOf('gl_Fog.density') >= 0) {
|
|
1589
|
+
source = 'uniform float u_fogDensity; \n' +
|
|
1590
|
+
source.replace(/gl_Fog.density/g, 'u_fogDensity');
|
|
1591
|
+
}
|
|
1592
|
+
if (source.indexOf('gl_FogFragCoord') >= 0) {
|
|
1593
|
+
source = 'varying float v_fogFragCoord; \n' +
|
|
1594
|
+
source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
|
|
1595
|
+
}
|
|
1596
|
+
source = 'precision mediump float;\n' + source;
|
|
1597
|
+
}
|
|
1598
|
+
#if GL_DEBUG
|
|
1599
|
+
GL.shaderSources[shader] = source;
|
|
1600
|
+
console.log("glShaderSource: Output: \n" + source);
|
|
1601
|
+
#endif
|
|
1602
|
+
Module.ctx.shaderSource(GL.shaders[shader], source);
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
var glCompileShader = _glCompileShader;
|
|
1606
|
+
_glCompileShader = function(shader) {
|
|
1607
|
+
Module.ctx.compileShader(GL.shaders[shader]);
|
|
1608
|
+
if (!Module.ctx.getShaderParameter(GL.shaders[shader], Module.ctx.COMPILE_STATUS)) {
|
|
1609
|
+
Module.printErr('Failed to compile shader: ' + Module.ctx.getShaderInfoLog(GL.shaders[shader]));
|
|
1610
|
+
Module.printErr('Info: ' + JSON.stringify(GL.shaderInfos[shader]));
|
|
1611
|
+
#if GL_DEBUG
|
|
1612
|
+
Module.printErr('Original source: ' + GL.shaderOriginalSources[shader]);
|
|
1613
|
+
Module.printErr('Source: ' + GL.shaderSources[shader]);
|
|
1614
|
+
throw 'Shader compilation halt';
|
|
1615
|
+
#else
|
|
1616
|
+
Module.printErr('Enable GL_DEBUG to see shader source');
|
|
1617
|
+
#endif
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
GL.programShaders = {};
|
|
1622
|
+
var glAttachShader = _glAttachShader;
|
|
1623
|
+
_glAttachShader = function(program, shader) {
|
|
1624
|
+
if (!GL.programShaders[program]) GL.programShaders[program] = [];
|
|
1625
|
+
GL.programShaders[program].push(shader);
|
|
1626
|
+
glAttachShader(program, shader);
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
var glDetachShader = _glDetachShader;
|
|
1630
|
+
_glDetachShader = function(program, shader) {
|
|
1631
|
+
var programShader = GL.programShaders[program];
|
|
1632
|
+
if (!programShader) {
|
|
1633
|
+
Module.printErr('WARNING: _glDetachShader received invalid program: ' + program);
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
var index = programShader.indexOf(shader);
|
|
1637
|
+
programShader.splice(index, 1);
|
|
1638
|
+
glDetachShader(program, shader);
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1641
|
+
var glUseProgram = _glUseProgram;
|
|
1642
|
+
_glUseProgram = function(program) {
|
|
1643
|
+
#if GL_DEBUG
|
|
1644
|
+
if (GL.debug) {
|
|
1645
|
+
Module.printErr('[using program with shaders]');
|
|
1646
|
+
if (program) {
|
|
1647
|
+
GL.programShaders[program].forEach(function(shader) {
|
|
1648
|
+
Module.printErr(' shader ' + shader + ', original source: ' + GL.shaderOriginalSources[shader]);
|
|
1649
|
+
Module.printErr(' Source: ' + GL.shaderSources[shader]);
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
#endif
|
|
1654
|
+
GL.currProgram = program;
|
|
1655
|
+
glUseProgram(program);
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
var glDeleteProgram = _glDeleteProgram;
|
|
1659
|
+
_glDeleteProgram = function(program) {
|
|
1660
|
+
glDeleteProgram(program);
|
|
1661
|
+
if (program == GL.currProgram) GL.currProgram = 0;
|
|
1662
|
+
};
|
|
1663
|
+
|
|
1664
|
+
// If attribute 0 was not bound, bind it to 0 for WebGL performance reasons. Track if 0 is free for that.
|
|
1665
|
+
var zeroUsedPrograms = {};
|
|
1666
|
+
var glBindAttribLocation = _glBindAttribLocation;
|
|
1667
|
+
_glBindAttribLocation = function(program, index, name) {
|
|
1668
|
+
if (index == 0) zeroUsedPrograms[program] = true;
|
|
1669
|
+
glBindAttribLocation(program, index, name);
|
|
1670
|
+
};
|
|
1671
|
+
var glLinkProgram = _glLinkProgram;
|
|
1672
|
+
_glLinkProgram = function(program) {
|
|
1673
|
+
if (!(program in zeroUsedPrograms)) {
|
|
1674
|
+
Module.ctx.bindAttribLocation(GL.programs[program], 0, 'a_position');
|
|
1675
|
+
}
|
|
1676
|
+
glLinkProgram(program);
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1679
|
+
var glBindBuffer = _glBindBuffer;
|
|
1680
|
+
_glBindBuffer = function(target, buffer) {
|
|
1681
|
+
glBindBuffer(target, buffer);
|
|
1682
|
+
if (target == Module.ctx.ARRAY_BUFFER) {
|
|
1683
|
+
if (GLEmulation.currentVao) {
|
|
1684
|
+
assert(GLEmulation.currentVao.arrayBuffer == buffer || GLEmulation.currentVao.arrayBuffer == 0 || buffer == 0, 'TODO: support for multiple array buffers in vao');
|
|
1685
|
+
GLEmulation.currentVao.arrayBuffer = buffer;
|
|
1686
|
+
}
|
|
1687
|
+
} else if (target == Module.ctx.ELEMENT_ARRAY_BUFFER) {
|
|
1688
|
+
if (GLEmulation.currentVao) GLEmulation.currentVao.elementArrayBuffer = buffer;
|
|
1689
|
+
}
|
|
1690
|
+
};
|
|
1691
|
+
|
|
1692
|
+
var glGetFloatv = _glGetFloatv;
|
|
1693
|
+
_glGetFloatv = function(pname, params) {
|
|
1694
|
+
if (pname == 0x0BA6) { // GL_MODELVIEW_MATRIX
|
|
1695
|
+
HEAPF32.set(GL.immediate.matrix['m'], params >> 2);
|
|
1696
|
+
} else if (pname == 0x0BA7) { // GL_PROJECTION_MATRIX
|
|
1697
|
+
HEAPF32.set(GL.immediate.matrix['p'], params >> 2);
|
|
1698
|
+
} else if (pname == 0x0BA8) { // GL_TEXTURE_MATRIX
|
|
1699
|
+
HEAPF32.set(GL.immediate.matrix['t' + GL.immediate.clientActiveTexture], params >> 2);
|
|
1700
|
+
} else if (pname == 0x0B66) { // GL_FOG_COLOR
|
|
1701
|
+
HEAPF32.set(GLEmulation.fogColor, params >> 2);
|
|
1702
|
+
} else if (pname == 0x0B63) { // GL_FOG_START
|
|
1703
|
+
{{{ makeSetValue('params', '0', 'GLEmulation.fogStart', 'float') }}};
|
|
1704
|
+
} else if (pname == 0x0B64) { // GL_FOG_END
|
|
1705
|
+
{{{ makeSetValue('params', '0', 'GLEmulation.fogEnd', 'float') }}};
|
|
1706
|
+
} else if (pname == 0x0B62) { // GL_FOG_DENSITY
|
|
1707
|
+
{{{ makeSetValue('params', '0', 'GLEmulation.fogDensity', 'float') }}};
|
|
1708
|
+
} else if (pname == 0x0B65) { // GL_FOG_MODE
|
|
1709
|
+
{{{ makeSetValue('params', '0', 'GLEmulation.fogMode', 'float') }}};
|
|
1710
|
+
} else {
|
|
1711
|
+
glGetFloatv(pname, params);
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
var glHint = _glHint;
|
|
1716
|
+
_glHint = function(target, mode) {
|
|
1717
|
+
if (target == 0x84EF) { // GL_TEXTURE_COMPRESSION_HINT
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
glHint(target, mode);
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
var glEnableVertexAttribArray = _glEnableVertexAttribArray;
|
|
1724
|
+
_glEnableVertexAttribArray = function(index) {
|
|
1725
|
+
glEnableVertexAttribArray(index);
|
|
1726
|
+
GLEmulation.enabledVertexAttribArrays[index] = 1;
|
|
1727
|
+
if (GLEmulation.currentVao) GLEmulation.currentVao.enabledVertexAttribArrays[index] = 1;
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
var glDisableVertexAttribArray = _glDisableVertexAttribArray;
|
|
1731
|
+
_glDisableVertexAttribArray = function(index) {
|
|
1732
|
+
glDisableVertexAttribArray(index);
|
|
1733
|
+
delete GLEmulation.enabledVertexAttribArrays[index];
|
|
1734
|
+
if (GLEmulation.currentVao) delete GLEmulation.currentVao.enabledVertexAttribArrays[index];
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1737
|
+
var glVertexAttribPointer = _glVertexAttribPointer;
|
|
1738
|
+
_glVertexAttribPointer = function(index, size, type, normalized, stride, pointer) {
|
|
1739
|
+
glVertexAttribPointer(index, size, type, normalized, stride, pointer);
|
|
1740
|
+
if (GLEmulation.currentVao) { // TODO: avoid object creation here? likely not hot though
|
|
1741
|
+
GLEmulation.currentVao.vertexAttribPointers[index] = [index, size, type, normalized, stride, pointer];
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
},
|
|
1745
|
+
|
|
1746
|
+
getAttributeFromCapability: function(cap) {
|
|
1747
|
+
var attrib = null;
|
|
1748
|
+
switch (cap) {
|
|
1749
|
+
case 0x0de1: // GL_TEXTURE_2D - XXX not according to spec, and not in desktop GL, but works in some GLES1.x apparently, so support it
|
|
1750
|
+
#if ASSERTIONS
|
|
1751
|
+
abort("GL_TEXTURE_2D is not a spec-defined capability for gl{Enable,Disable}ClientState.");
|
|
1752
|
+
#endif
|
|
1753
|
+
// Fall through:
|
|
1754
|
+
case 0x8078: // GL_TEXTURE_COORD_ARRAY
|
|
1755
|
+
attrib = GL.immediate.TEXTURE0 + GL.immediate.clientActiveTexture; break;
|
|
1756
|
+
case 0x8074: // GL_VERTEX_ARRAY
|
|
1757
|
+
attrib = GL.immediate.VERTEX; break;
|
|
1758
|
+
case 0x8075: // GL_NORMAL_ARRAY
|
|
1759
|
+
attrib = GL.immediate.NORMAL; break;
|
|
1760
|
+
case 0x8076: // GL_COLOR_ARRAY
|
|
1761
|
+
attrib = GL.immediate.COLOR; break;
|
|
1762
|
+
}
|
|
1763
|
+
return attrib;
|
|
1764
|
+
},
|
|
1765
|
+
|
|
1766
|
+
getProcAddress: function(name) {
|
|
1767
|
+
name = name.replace('EXT', '').replace('ARB', '');
|
|
1768
|
+
// Do the translation carefully because of closure
|
|
1769
|
+
var ret = 0;
|
|
1770
|
+
switch (name) {
|
|
1771
|
+
case 'glCreateShaderObject': case 'glCreateShader': ret = {{{ Functions.getIndex('_glCreateShader', true) }}}; break;
|
|
1772
|
+
case 'glCreateProgramObject': case 'glCreateProgram': ret = {{{ Functions.getIndex('_glCreateProgram', true) }}}; break;
|
|
1773
|
+
case 'glAttachObject': case 'glAttachShader': ret = {{{ Functions.getIndex('_glAttachShader', true) }}}; break;
|
|
1774
|
+
case 'glUseProgramObject': case 'glUseProgram': ret = {{{ Functions.getIndex('_glUseProgram', true) }}}; break;
|
|
1775
|
+
case 'glDetachObject': case 'glDetachShader': ret = {{{ Functions.getIndex('_glDetachShader', true) }}}; break;
|
|
1776
|
+
case 'glDeleteObject': ret = {{{ Functions.getIndex('_glDeleteObject', true) }}}; break;
|
|
1777
|
+
case 'glGetObjectParameteriv': ret = {{{ Functions.getIndex('_glGetObjectParameteriv', true) }}}; break;
|
|
1778
|
+
case 'glGetInfoLog': ret = {{{ Functions.getIndex('_glGetInfoLog', true) }}}; break;
|
|
1779
|
+
case 'glBindProgram': ret = {{{ Functions.getIndex('_glBindProgram', true) }}}; break;
|
|
1780
|
+
case 'glDrawRangeElements': ret = {{{ Functions.getIndex('_glDrawRangeElements', true) }}}; break;
|
|
1781
|
+
case 'glShaderSource': ret = {{{ Functions.getIndex('_glShaderSource', true) }}}; break;
|
|
1782
|
+
case 'glCompileShader': ret = {{{ Functions.getIndex('_glCompileShader', true) }}}; break;
|
|
1783
|
+
case 'glLinkProgram': ret = {{{ Functions.getIndex('_glLinkProgram', true) }}}; break;
|
|
1784
|
+
case 'glGetUniformLocation': ret = {{{ Functions.getIndex('_glGetUniformLocation', true) }}}; break;
|
|
1785
|
+
case 'glUniform1f': ret = {{{ Functions.getIndex('_glUniform1f', true) }}}; break;
|
|
1786
|
+
case 'glUniform2f': ret = {{{ Functions.getIndex('_glUniform2f', true) }}}; break;
|
|
1787
|
+
case 'glUniform3f': ret = {{{ Functions.getIndex('_glUniform3f', true) }}}; break;
|
|
1788
|
+
case 'glUniform4f': ret = {{{ Functions.getIndex('_glUniform4f', true) }}}; break;
|
|
1789
|
+
case 'glUniform1fv': ret = {{{ Functions.getIndex('_glUniform1fv', true) }}}; break;
|
|
1790
|
+
case 'glUniform2fv': ret = {{{ Functions.getIndex('_glUniform2fv', true) }}}; break;
|
|
1791
|
+
case 'glUniform3fv': ret = {{{ Functions.getIndex('_glUniform3fv', true) }}}; break;
|
|
1792
|
+
case 'glUniform4fv': ret = {{{ Functions.getIndex('_glUniform4fv', true) }}}; break;
|
|
1793
|
+
case 'glUniform1i': ret = {{{ Functions.getIndex('_glUniform1i', true) }}}; break;
|
|
1794
|
+
case 'glUniform2i': ret = {{{ Functions.getIndex('_glUniform2i', true) }}}; break;
|
|
1795
|
+
case 'glUniform3i': ret = {{{ Functions.getIndex('_glUniform3i', true) }}}; break;
|
|
1796
|
+
case 'glUniform4i': ret = {{{ Functions.getIndex('_glUniform4i', true) }}}; break;
|
|
1797
|
+
case 'glUniform1iv': ret = {{{ Functions.getIndex('_glUniform1iv', true) }}}; break;
|
|
1798
|
+
case 'glUniform2iv': ret = {{{ Functions.getIndex('_glUniform2iv', true) }}}; break;
|
|
1799
|
+
case 'glUniform3iv': ret = {{{ Functions.getIndex('_glUniform3iv', true) }}}; break;
|
|
1800
|
+
case 'glUniform4iv': ret = {{{ Functions.getIndex('_glUniform4iv', true) }}}; break;
|
|
1801
|
+
case 'glBindAttribLocation': ret = {{{ Functions.getIndex('_glBindAttribLocation', true) }}}; break;
|
|
1802
|
+
case 'glGetActiveUniform': ret = {{{ Functions.getIndex('_glGetActiveUniform', true) }}}; break;
|
|
1803
|
+
case 'glGenBuffers': ret = {{{ Functions.getIndex('_glGenBuffers', true) }}}; break;
|
|
1804
|
+
case 'glBindBuffer': ret = {{{ Functions.getIndex('_glBindBuffer', true) }}}; break;
|
|
1805
|
+
case 'glBufferData': ret = {{{ Functions.getIndex('_glBufferData', true) }}}; break;
|
|
1806
|
+
case 'glBufferSubData': ret = {{{ Functions.getIndex('_glBufferSubData', true) }}}; break;
|
|
1807
|
+
case 'glDeleteBuffers': ret = {{{ Functions.getIndex('_glDeleteBuffers', true) }}}; break;
|
|
1808
|
+
case 'glActiveTexture': ret = {{{ Functions.getIndex('_glActiveTexture', true) }}}; break;
|
|
1809
|
+
case 'glClientActiveTexture': ret = {{{ Functions.getIndex('_glClientActiveTexture', true) }}}; break;
|
|
1810
|
+
case 'glGetProgramiv': ret = {{{ Functions.getIndex('_glGetProgramiv', true) }}}; break;
|
|
1811
|
+
case 'glEnableVertexAttribArray': ret = {{{ Functions.getIndex('_glEnableVertexAttribArray', true) }}}; break;
|
|
1812
|
+
case 'glDisableVertexAttribArray': ret = {{{ Functions.getIndex('_glDisableVertexAttribArray', true) }}}; break;
|
|
1813
|
+
case 'glVertexAttribPointer': ret = {{{ Functions.getIndex('_glVertexAttribPointer', true) }}}; break;
|
|
1814
|
+
case 'glVertexAttrib1f': ret = {{{ Functions.getIndex('_glVertexAttrib1f', true) }}}; break;
|
|
1815
|
+
case 'glVertexAttrib2f': ret = {{{ Functions.getIndex('_glVertexAttrib2f', true) }}}; break;
|
|
1816
|
+
case 'glVertexAttrib3f': ret = {{{ Functions.getIndex('_glVertexAttrib3f', true) }}}; break;
|
|
1817
|
+
case 'glVertexAttrib4f': ret = {{{ Functions.getIndex('_glVertexAttrib4f', true) }}}; break;
|
|
1818
|
+
case 'glVertexAttrib1fv': ret = {{{ Functions.getIndex('_glVertexAttrib1fv', true) }}}; break;
|
|
1819
|
+
case 'glVertexAttrib2fv': ret = {{{ Functions.getIndex('_glVertexAttrib2fv', true) }}}; break;
|
|
1820
|
+
case 'glVertexAttrib3fv': ret = {{{ Functions.getIndex('_glVertexAttrib3fv', true) }}}; break;
|
|
1821
|
+
case 'glVertexAttrib4fv': ret = {{{ Functions.getIndex('_glVertexAttrib4fv', true) }}}; break;
|
|
1822
|
+
case 'glGetVertexAttribfv': ret = {{{ Functions.getIndex('_glGetVertexAttribfv', true) }}}; break;
|
|
1823
|
+
case 'glGetVertexAttribiv': ret = {{{ Functions.getIndex('_glGetVertexAttribiv', true) }}}; break;
|
|
1824
|
+
case 'glGetVertexAttribPointerv': ret = {{{ Functions.getIndex('_glGetVertexAttribPointerv', true) }}}; break;
|
|
1825
|
+
case 'glGetAttribLocation': ret = {{{ Functions.getIndex('_glGetAttribLocation', true) }}}; break;
|
|
1826
|
+
case 'glGetActiveAttrib': ret = {{{ Functions.getIndex('_glGetActiveAttrib', true) }}}; break;
|
|
1827
|
+
case 'glBindRenderbuffer': ret = {{{ Functions.getIndex('_glBindRenderbuffer', true) }}}; break;
|
|
1828
|
+
case 'glDeleteRenderbuffers': ret = {{{ Functions.getIndex('_glDeleteRenderbuffers', true) }}}; break;
|
|
1829
|
+
case 'glGenRenderbuffers': ret = {{{ Functions.getIndex('_glGenRenderbuffers', true) }}}; break;
|
|
1830
|
+
case 'glCompressedTexImage2D': ret = {{{ Functions.getIndex('_glCompressedTexImage2D', true) }}}; break;
|
|
1831
|
+
case 'glCompressedTexSubImage2D': ret = {{{ Functions.getIndex('_glCompressedTexSubImage2D', true) }}}; break;
|
|
1832
|
+
case 'glBindFramebuffer': ret = {{{ Functions.getIndex('_glBindFramebuffer', true) }}}; break;
|
|
1833
|
+
case 'glGenFramebuffers': ret = {{{ Functions.getIndex('_glGenFramebuffers', true) }}}; break;
|
|
1834
|
+
case 'glDeleteFramebuffers': ret = {{{ Functions.getIndex('_glDeleteFramebuffers', true) }}}; break;
|
|
1835
|
+
case 'glFramebufferRenderbuffer': ret = {{{ Functions.getIndex('_glFramebufferRenderbuffer', true) }}}; break;
|
|
1836
|
+
case 'glFramebufferTexture2D': ret = {{{ Functions.getIndex('_glFramebufferTexture2D', true) }}}; break;
|
|
1837
|
+
case 'glGetFramebufferAttachmentParameteriv': ret = {{{ Functions.getIndex('_glGetFramebufferAttachmentParameteriv', true) }}}; break;
|
|
1838
|
+
case 'glIsFramebuffer': ret = {{{ Functions.getIndex('_glIsFramebuffer', true) }}}; break;
|
|
1839
|
+
case 'glCheckFramebufferStatus': ret = {{{ Functions.getIndex('_glCheckFramebufferStatus', true) }}}; break;
|
|
1840
|
+
case 'glRenderbufferStorage': ret = {{{ Functions.getIndex('_glRenderbufferStorage', true) }}}; break;
|
|
1841
|
+
case 'glGenVertexArrays': ret = {{{ Functions.getIndex('_glGenVertexArrays', true) }}}; break;
|
|
1842
|
+
case 'glDeleteVertexArrays': ret = {{{ Functions.getIndex('_glDeleteVertexArrays', true) }}}; break;
|
|
1843
|
+
case 'glBindVertexArray': ret = {{{ Functions.getIndex('_glBindVertexArray', true) }}}; break;
|
|
1844
|
+
case 'glGetString': ret = {{{ Functions.getIndex('_glGetString', true) }}}; break;
|
|
1845
|
+
case 'glBindTexture': ret = {{{ Functions.getIndex('_glBindTexture', true) }}}; break;
|
|
1846
|
+
case 'glGetBufferParameteriv': ret = {{{ Functions.getIndex('_glGetBufferParameteriv', true) }}}; break;
|
|
1847
|
+
case 'glIsBuffer': ret = {{{ Functions.getIndex('_glIsBuffer', true) }}}; break;
|
|
1848
|
+
case 'glDeleteShader': ret = {{{ Functions.getIndex('_glDeleteShader', true) }}}; break;
|
|
1849
|
+
case 'glUniformMatrix2fv': ret = {{{ Functions.getIndex('_glUniformMatrix2fv', true) }}}; break;
|
|
1850
|
+
case 'glUniformMatrix3fv': ret = {{{ Functions.getIndex('_glUniformMatrix3fv', true) }}}; break;
|
|
1851
|
+
case 'glUniformMatrix4fv': ret = {{{ Functions.getIndex('_glUniformMatrix4fv', true) }}}; break;
|
|
1852
|
+
case 'glIsRenderbuffer': ret = {{{ Functions.getIndex('_glIsRenderbuffer', true) }}}; break;
|
|
1853
|
+
case 'glBlendEquation': ret = {{{ Functions.getIndex('_glBlendEquation', true) }}}; break;
|
|
1854
|
+
case 'glBlendFunc': ret = {{{ Functions.getIndex('_glBlendFunc', true) }}}; break;
|
|
1855
|
+
case 'glBlendFuncSeparate': ret = {{{ Functions.getIndex('_glBlendFuncSeparate', true) }}}; break;
|
|
1856
|
+
case 'glBlendEquationSeparate': ret = {{{ Functions.getIndex('_glBlendEquationSeparate', true) }}}; break;
|
|
1857
|
+
case 'glDepthRangef': ret = {{{ Functions.getIndex('_glDepthRangef', true) }}}; break;
|
|
1858
|
+
case 'glClear': ret = {{{ Functions.getIndex('_glClear', true) }}}; break;
|
|
1859
|
+
case 'glGenerateMipmap': ret = {{{ Functions.getIndex('_glGenerateMipmap', true) }}}; break;
|
|
1860
|
+
case 'glBlendColor': ret = {{{ Functions.getIndex('_glBlendColor', true) }}}; break;
|
|
1861
|
+
case 'glClearDepthf': ret = {{{ Functions.getIndex('_glClearDepthf', true) }}}; break;
|
|
1862
|
+
case 'glDeleteProgram': ret = {{{ Functions.getIndex('_glDeleteProgram', true) }}}; break;
|
|
1863
|
+
case 'glUniformMatrix3fv': ret = {{{ Functions.getIndex('_glUniformMatrix3fv', true) }}}; break;
|
|
1864
|
+
case 'glClearColor': ret = {{{ Functions.getIndex('_glClearColor', true) }}}; break;
|
|
1865
|
+
case 'glGetRenderbufferParameteriv': ret = {{{ Functions.getIndex('_glGetRenderbufferParameteriv', true) }}}; break;
|
|
1866
|
+
case 'glGetShaderInfoLog': ret = {{{ Functions.getIndex('_glGetShaderInfoLog', true) }}}; break;
|
|
1867
|
+
case 'glUniformMatrix4fv': ret = {{{ Functions.getIndex('_glUniformMatrix4fv', true) }}}; break;
|
|
1868
|
+
case 'glClearStencil': ret = {{{ Functions.getIndex('_glClearStencil', true) }}}; break;
|
|
1869
|
+
case 'glGetProgramInfoLog': ret = {{{ Functions.getIndex('_glGetProgramInfoLog', true) }}}; break;
|
|
1870
|
+
case 'glGetUniformfv': ret = {{{ Functions.getIndex('_glGetUniformfv', true) }}}; break;
|
|
1871
|
+
case 'glStencilFuncSeparate': ret = {{{ Functions.getIndex('_glStencilFuncSeparate', true) }}}; break;
|
|
1872
|
+
case 'glSampleCoverage': ret = {{{ Functions.getIndex('_glSampleCoverage', true) }}}; break;
|
|
1873
|
+
case 'glColorMask': ret = {{{ Functions.getIndex('_glColorMask', true) }}}; break;
|
|
1874
|
+
case 'glGetShaderiv': ret = {{{ Functions.getIndex('_glGetShaderiv', true) }}}; break;
|
|
1875
|
+
case 'glGetUniformiv': ret = {{{ Functions.getIndex('_glGetUniformiv', true) }}}; break;
|
|
1876
|
+
case 'glCopyTexSubImage2D': ret = {{{ Functions.getIndex('_glCopyTexSubImage2D', true) }}}; break;
|
|
1877
|
+
case 'glDetachShader': ret = {{{ Functions.getIndex('_glDetachShader', true) }}}; break;
|
|
1878
|
+
case 'glGetShaderSource': ret = {{{ Functions.getIndex('_glGetShaderSource', true) }}}; break;
|
|
1879
|
+
case 'glDeleteTextures': ret = {{{ Functions.getIndex('_glDeleteTextures', true) }}}; break;
|
|
1880
|
+
case 'glGetAttachedShaders': ret = {{{ Functions.getIndex('_glGetAttachedShaders', true) }}}; break;
|
|
1881
|
+
case 'glValidateProgram': ret = {{{ Functions.getIndex('_glValidateProgram', true) }}}; break;
|
|
1882
|
+
case 'glDepthFunc': ret = {{{ Functions.getIndex('_glDepthFunc', true) }}}; break;
|
|
1883
|
+
case 'glIsShader': ret = {{{ Functions.getIndex('_glIsShader', true) }}}; break;
|
|
1884
|
+
case 'glDepthMask': ret = {{{ Functions.getIndex('_glDepthMask', true) }}}; break;
|
|
1885
|
+
case 'glStencilMaskSeparate': ret = {{{ Functions.getIndex('_glStencilMaskSeparate', true) }}}; break;
|
|
1886
|
+
case 'glIsProgram': ret = {{{ Functions.getIndex('_glIsProgram', true) }}}; break;
|
|
1887
|
+
case 'glDisable': ret = {{{ Functions.getIndex('_glDisable', true) }}}; break;
|
|
1888
|
+
case 'glStencilOpSeparate': ret = {{{ Functions.getIndex('_glStencilOpSeparate', true) }}}; break;
|
|
1889
|
+
case 'glDrawArrays': ret = {{{ Functions.getIndex('_glDrawArrays', true) }}}; break;
|
|
1890
|
+
case 'glDrawElements': ret = {{{ Functions.getIndex('_glDrawElements', true) }}}; break;
|
|
1891
|
+
case 'glEnable': ret = {{{ Functions.getIndex('_glEnable', true) }}}; break;
|
|
1892
|
+
case 'glFinish': ret = {{{ Functions.getIndex('_glFinish', true) }}}; break;
|
|
1893
|
+
case 'glFlush': ret = {{{ Functions.getIndex('_glFlush', true) }}}; break;
|
|
1894
|
+
case 'glFrontFace': ret = {{{ Functions.getIndex('_glFrontFace', true) }}}; break;
|
|
1895
|
+
case 'glCullFace': ret = {{{ Functions.getIndex('_glCullFace', true) }}}; break;
|
|
1896
|
+
case 'glGenTextures': ret = {{{ Functions.getIndex('_glGenTextures', true) }}}; break;
|
|
1897
|
+
case 'glGetError': ret = {{{ Functions.getIndex('_glGetError', true) }}}; break;
|
|
1898
|
+
case 'glGetIntegerv': ret = {{{ Functions.getIndex('_glGetIntegerv', true) }}}; break;
|
|
1899
|
+
case 'glGetBooleanv': ret = {{{ Functions.getIndex('_glGetBooleanv', true) }}}; break;
|
|
1900
|
+
case 'glGetFloatv': ret = {{{ Functions.getIndex('_glGetFloatv', true) }}}; break;
|
|
1901
|
+
case 'glHint': ret = {{{ Functions.getIndex('_glHint', true) }}}; break;
|
|
1902
|
+
case 'glIsTexture': ret = {{{ Functions.getIndex('_glIsTexture', true) }}}; break;
|
|
1903
|
+
case 'glPixelStorei': ret = {{{ Functions.getIndex('_glPixelStorei', true) }}}; break;
|
|
1904
|
+
case 'glReadPixels': ret = {{{ Functions.getIndex('_glReadPixels', true) }}}; break;
|
|
1905
|
+
case 'glScissor': ret = {{{ Functions.getIndex('_glScissor', true) }}}; break;
|
|
1906
|
+
case 'glStencilFunc': ret = {{{ Functions.getIndex('_glStencilFunc', true) }}}; break;
|
|
1907
|
+
case 'glStencilMask': ret = {{{ Functions.getIndex('_glStencilMask', true) }}}; break;
|
|
1908
|
+
case 'glStencilOp': ret = {{{ Functions.getIndex('_glStencilOp', true) }}}; break;
|
|
1909
|
+
case 'glTexImage2D': ret = {{{ Functions.getIndex('_glTexImage2D', true) }}}; break;
|
|
1910
|
+
case 'glTexParameterf': ret = {{{ Functions.getIndex('_glTexParameterf', true) }}}; break;
|
|
1911
|
+
case 'glTexParameterfv': ret = {{{ Functions.getIndex('_glTexParameterfv', true) }}}; break;
|
|
1912
|
+
case 'glTexParameteri': ret = {{{ Functions.getIndex('_glTexParameteri', true) }}}; break;
|
|
1913
|
+
case 'glTexParameteriv': ret = {{{ Functions.getIndex('_glTexParameteriv', true) }}}; break;
|
|
1914
|
+
case 'glGetTexParameterfv': ret = {{{ Functions.getIndex('_glGetTexParameterfv', true) }}}; break;
|
|
1915
|
+
case 'glGetTexParameteriv': ret = {{{ Functions.getIndex('_glGetTexParameteriv', true) }}}; break;
|
|
1916
|
+
case 'glTexSubImage2D': ret = {{{ Functions.getIndex('_glTexSubImage2D', true) }}}; break;
|
|
1917
|
+
case 'glCopyTexImage2D': ret = {{{ Functions.getIndex('_glCopyTexImage2D', true) }}}; break;
|
|
1918
|
+
case 'glViewport': ret = {{{ Functions.getIndex('_glViewport', true) }}}; break;
|
|
1919
|
+
case 'glIsEnabled': ret = {{{ Functions.getIndex('_glIsEnabled', true) }}}; break;
|
|
1920
|
+
case 'glLineWidth': ret = {{{ Functions.getIndex('_glLineWidth', true) }}}; break;
|
|
1921
|
+
case 'glPolygonOffset': ret = {{{ Functions.getIndex('_glPolygonOffset', true) }}}; break;
|
|
1922
|
+
case 'glReleaseShaderCompiler': ret = {{{ Functions.getIndex('_glReleaseShaderCompiler', true) }}}; break;
|
|
1923
|
+
case 'glGetShaderPrecisionFormat': ret = {{{ Functions.getIndex('_glGetShaderPrecisionFormat', true) }}}; break;
|
|
1924
|
+
case 'glShaderBinary': ret = {{{ Functions.getIndex('_glShaderBinary', true) }}}; break;
|
|
1925
|
+
}
|
|
1926
|
+
if (!ret) Module.printErr('WARNING: getProcAddress failed for ' + name);
|
|
1927
|
+
return ret;
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1930
|
+
|
|
1931
|
+
glGetShaderPrecisionFormat__sig: 'v',
|
|
1932
|
+
glGetShaderPrecisionFormat: function() { throw 'glGetShaderPrecisionFormat: TODO' },
|
|
1933
|
+
|
|
1934
|
+
glShaderBinary__sig: 'v',
|
|
1935
|
+
glShaderBinary: function() { throw 'glShaderBinary: TODO' },
|
|
1936
|
+
|
|
1937
|
+
glDeleteObject__sig: 'vi',
|
|
1938
|
+
glDeleteObject: function(id) {
|
|
1939
|
+
if (GL.programs[id]) {
|
|
1940
|
+
_glDeleteProgram(id);
|
|
1941
|
+
} else if (GL.shaders[id]) {
|
|
1942
|
+
_glDeleteShader(id);
|
|
1943
|
+
} else {
|
|
1944
|
+
Module.printErr('WARNING: deleteObject received invalid id: ' + id);
|
|
1945
|
+
}
|
|
1946
|
+
},
|
|
1947
|
+
|
|
1948
|
+
glReleaseShaderCompiler__sig: 'v',
|
|
1949
|
+
glReleaseShaderCompiler: function() {
|
|
1950
|
+
// NOP (as allowed by GLES 2.0 spec)
|
|
1951
|
+
},
|
|
1952
|
+
|
|
1953
|
+
glGetObjectParameteriv__sig: 'viii',
|
|
1954
|
+
glGetObjectParameteriv: function(id, type, result) {
|
|
1955
|
+
if (GL.programs[id]) {
|
|
1956
|
+
if (type == 0x8B84) { // GL_OBJECT_INFO_LOG_LENGTH_ARB
|
|
1957
|
+
{{{ makeSetValue('result', '0', 'Module.ctx.getProgramInfoLog(GL.programs[id]).length', 'i32') }}};
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
_glGetProgramiv(id, type, result);
|
|
1961
|
+
} else if (GL.shaders[id]) {
|
|
1962
|
+
if (type == 0x8B84) { // GL_OBJECT_INFO_LOG_LENGTH_ARB
|
|
1963
|
+
{{{ makeSetValue('result', '0', 'Module.ctx.getShaderInfoLog(GL.shaders[id]).length', 'i32') }}};
|
|
1964
|
+
return;
|
|
1965
|
+
} else if (type == 0x8B88) { // GL_OBJECT_SHADER_SOURCE_LENGTH_ARB
|
|
1966
|
+
{{{ makeSetValue('result', '0', 'Module.ctx.getShaderSource(GL.shaders[id]).length', 'i32') }}};
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1969
|
+
_glGetShaderiv(id, type, result);
|
|
1970
|
+
} else {
|
|
1971
|
+
Module.printErr('WARNING: getObjectParameteriv received invalid id: ' + id);
|
|
1972
|
+
}
|
|
1973
|
+
},
|
|
1974
|
+
|
|
1975
|
+
glGetInfoLog__sig: 'viiii',
|
|
1976
|
+
glGetInfoLog: function(id, maxLength, length, infoLog) {
|
|
1977
|
+
if (GL.programs[id]) {
|
|
1978
|
+
_glGetProgramInfoLog(id, maxLength, length, infoLog);
|
|
1979
|
+
} else if (GL.shaders[id]) {
|
|
1980
|
+
_glGetShaderInfoLog(id, maxLength, length, infoLog);
|
|
1981
|
+
} else {
|
|
1982
|
+
Module.printErr('WARNING: getObjectParameteriv received invalid id: ' + id);
|
|
1983
|
+
}
|
|
1984
|
+
},
|
|
1985
|
+
|
|
1986
|
+
glBindProgram__sig: 'vii',
|
|
1987
|
+
glBindProgram: function(type, id) {
|
|
1988
|
+
assert(id == 0);
|
|
1989
|
+
},
|
|
1990
|
+
|
|
1991
|
+
glGetPointerv: function(name, p) {
|
|
1992
|
+
var attribute;
|
|
1993
|
+
switch(name) {
|
|
1994
|
+
case 0x808E: // GL_VERTEX_ARRAY_POINTER
|
|
1995
|
+
attribute = GLImmediate.clientAttributes[GLImmediate.VERTEX]; break;
|
|
1996
|
+
case 0x8090: // GL_COLOR_ARRAY_POINTER
|
|
1997
|
+
attribute = GLImmediate.clientAttributes[GLImmediate.COLOR]; break;
|
|
1998
|
+
case 0x8092: // GL_TEXTURE_COORD_ARRAY_POINTER
|
|
1999
|
+
attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0]; break;
|
|
2000
|
+
default: throw 'TODO: glGetPointerv for ' + name;
|
|
2001
|
+
}
|
|
2002
|
+
{{{ makeSetValue('p', '0', 'attribute ? attribute.pointer : 0', 'i32') }}};
|
|
2003
|
+
},
|
|
2004
|
+
|
|
2005
|
+
// GL Immediate mode
|
|
2006
|
+
|
|
2007
|
+
// See comment in GLEmulation.init()
|
|
2008
|
+
#if FULL_ES2 == 0
|
|
2009
|
+
$GLImmediate__postset: 'GL.immediate.setupFuncs(); Browser.moduleContextCreatedCallbacks.push(function() { GL.immediate.init() });',
|
|
2010
|
+
#endif
|
|
2011
|
+
$GLImmediate__deps: ['$Browser', '$GL', '$GLEmulation'],
|
|
2012
|
+
$GLImmediate: {
|
|
2013
|
+
MapTreeLib: null,
|
|
2014
|
+
spawnMapTreeLib: function() {
|
|
2015
|
+
/* A naive implementation of a map backed by an array, and accessed by
|
|
2016
|
+
* naive iteration along the array. (hashmap with only one bucket)
|
|
2017
|
+
*/
|
|
2018
|
+
function CNaiveListMap() {
|
|
2019
|
+
var list = [];
|
|
2020
|
+
|
|
2021
|
+
this.insert = function(key, val) {
|
|
2022
|
+
if (this.contains(key|0)) return false;
|
|
2023
|
+
list.push([key, val]);
|
|
2024
|
+
return true;
|
|
2025
|
+
};
|
|
2026
|
+
|
|
2027
|
+
var __contains_i;
|
|
2028
|
+
this.contains = function(key) {
|
|
2029
|
+
for (__contains_i = 0; __contains_i < list.length; ++__contains_i) {
|
|
2030
|
+
if (list[__contains_i][0] === key) return true;
|
|
2031
|
+
}
|
|
2032
|
+
return false;
|
|
2033
|
+
};
|
|
2034
|
+
|
|
2035
|
+
var __get_i;
|
|
2036
|
+
this.get = function(key) {
|
|
2037
|
+
for (__get_i = 0; __get_i < list.length; ++__get_i) {
|
|
2038
|
+
if (list[__get_i][0] === key) return list[__get_i][1];
|
|
2039
|
+
}
|
|
2040
|
+
return undefined;
|
|
2041
|
+
};
|
|
2042
|
+
};
|
|
2043
|
+
|
|
2044
|
+
/* A tree of map nodes.
|
|
2045
|
+
Uses `KeyView`s to allow descending the tree without garbage.
|
|
2046
|
+
Example: {
|
|
2047
|
+
// Create our map object.
|
|
2048
|
+
var map = new ObjTreeMap();
|
|
2049
|
+
|
|
2050
|
+
// Grab the static keyView for the map.
|
|
2051
|
+
var keyView = map.GetStaticKeyView();
|
|
2052
|
+
|
|
2053
|
+
// Let's make a map for:
|
|
2054
|
+
// root: <undefined>
|
|
2055
|
+
// 1: <undefined>
|
|
2056
|
+
// 2: <undefined>
|
|
2057
|
+
// 5: "Three, sir!"
|
|
2058
|
+
// 3: "Three!"
|
|
2059
|
+
|
|
2060
|
+
// Note how we can chain together `Reset` and `Next` to
|
|
2061
|
+
// easily descend based on multiple key fragments.
|
|
2062
|
+
keyView.Reset().Next(1).Next(2).Next(5).Set("Three, sir!");
|
|
2063
|
+
keyView.Reset().Next(1).Next(2).Next(3).Set("Three!");
|
|
2064
|
+
}
|
|
2065
|
+
*/
|
|
2066
|
+
function CMapTree() {
|
|
2067
|
+
function CNLNode() {
|
|
2068
|
+
var map = new CNaiveListMap();
|
|
2069
|
+
|
|
2070
|
+
this.child = function(keyFrag) {
|
|
2071
|
+
if (!map.contains(keyFrag|0)) {
|
|
2072
|
+
map.insert(keyFrag|0, new CNLNode());
|
|
2073
|
+
}
|
|
2074
|
+
return map.get(keyFrag|0);
|
|
2075
|
+
};
|
|
2076
|
+
|
|
2077
|
+
this.value = undefined;
|
|
2078
|
+
this.get = function() {
|
|
2079
|
+
return this.value;
|
|
2080
|
+
};
|
|
2081
|
+
|
|
2082
|
+
this.set = function(val) {
|
|
2083
|
+
this.value = val;
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
function CKeyView(root) {
|
|
2088
|
+
var cur;
|
|
2089
|
+
|
|
2090
|
+
this.reset = function() {
|
|
2091
|
+
cur = root;
|
|
2092
|
+
return this;
|
|
2093
|
+
};
|
|
2094
|
+
this.reset();
|
|
2095
|
+
|
|
2096
|
+
this.next = function(keyFrag) {
|
|
2097
|
+
cur = cur.child(keyFrag);
|
|
2098
|
+
return this;
|
|
2099
|
+
};
|
|
2100
|
+
|
|
2101
|
+
this.get = function() {
|
|
2102
|
+
return cur.get();
|
|
2103
|
+
};
|
|
2104
|
+
|
|
2105
|
+
this.set = function(val) {
|
|
2106
|
+
cur.set(val);
|
|
2107
|
+
};
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
var root;
|
|
2111
|
+
var staticKeyView;
|
|
2112
|
+
|
|
2113
|
+
this.createKeyView = function() {
|
|
2114
|
+
return new CKeyView(root);
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
this.clear = function() {
|
|
2118
|
+
root = new CNLNode();
|
|
2119
|
+
staticKeyView = this.createKeyView();
|
|
2120
|
+
};
|
|
2121
|
+
this.clear();
|
|
2122
|
+
|
|
2123
|
+
this.getStaticKeyView = function() {
|
|
2124
|
+
staticKeyView.reset();
|
|
2125
|
+
return staticKeyView;
|
|
2126
|
+
};
|
|
2127
|
+
};
|
|
2128
|
+
|
|
2129
|
+
// Exports:
|
|
2130
|
+
return {
|
|
2131
|
+
create: function() {
|
|
2132
|
+
return new CMapTree();
|
|
2133
|
+
},
|
|
2134
|
+
};
|
|
2135
|
+
},
|
|
2136
|
+
|
|
2137
|
+
TexEnvJIT: null,
|
|
2138
|
+
spawnTexEnvJIT: function() {
|
|
2139
|
+
// GL defs:
|
|
2140
|
+
var GL_TEXTURE0 = 0x84C0;
|
|
2141
|
+
var GL_TEXTURE_1D = 0x0DE0;
|
|
2142
|
+
var GL_TEXTURE_2D = 0x0DE1;
|
|
2143
|
+
var GL_TEXTURE_3D = 0x806f;
|
|
2144
|
+
var GL_TEXTURE_CUBE_MAP = 0x8513;
|
|
2145
|
+
var GL_TEXTURE_ENV = 0x2300;
|
|
2146
|
+
var GL_TEXTURE_ENV_MODE = 0x2200;
|
|
2147
|
+
var GL_TEXTURE_ENV_COLOR = 0x2201;
|
|
2148
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
|
|
2149
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
|
|
2150
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
|
|
2151
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
|
|
2152
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
|
|
2153
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
|
|
2154
|
+
|
|
2155
|
+
var GL_SRC0_RGB = 0x8580;
|
|
2156
|
+
var GL_SRC1_RGB = 0x8581;
|
|
2157
|
+
var GL_SRC2_RGB = 0x8582;
|
|
2158
|
+
|
|
2159
|
+
var GL_SRC0_ALPHA = 0x8588;
|
|
2160
|
+
var GL_SRC1_ALPHA = 0x8589;
|
|
2161
|
+
var GL_SRC2_ALPHA = 0x858A;
|
|
2162
|
+
|
|
2163
|
+
var GL_OPERAND0_RGB = 0x8590;
|
|
2164
|
+
var GL_OPERAND1_RGB = 0x8591;
|
|
2165
|
+
var GL_OPERAND2_RGB = 0x8592;
|
|
2166
|
+
|
|
2167
|
+
var GL_OPERAND0_ALPHA = 0x8598;
|
|
2168
|
+
var GL_OPERAND1_ALPHA = 0x8599;
|
|
2169
|
+
var GL_OPERAND2_ALPHA = 0x859A;
|
|
2170
|
+
|
|
2171
|
+
var GL_COMBINE_RGB = 0x8571;
|
|
2172
|
+
var GL_COMBINE_ALPHA = 0x8572;
|
|
2173
|
+
|
|
2174
|
+
var GL_RGB_SCALE = 0x8573;
|
|
2175
|
+
var GL_ALPHA_SCALE = 0x0D1C;
|
|
2176
|
+
|
|
2177
|
+
// env.mode
|
|
2178
|
+
var GL_ADD = 0x0104;
|
|
2179
|
+
var GL_BLEND = 0x0BE2;
|
|
2180
|
+
var GL_REPLACE = 0x1E01;
|
|
2181
|
+
var GL_MODULATE = 0x2100;
|
|
2182
|
+
var GL_DECAL = 0x2101;
|
|
2183
|
+
var GL_COMBINE = 0x8570;
|
|
2184
|
+
|
|
2185
|
+
// env.color/alphaCombiner
|
|
2186
|
+
//var GL_ADD = 0x0104;
|
|
2187
|
+
//var GL_REPLACE = 0x1E01;
|
|
2188
|
+
//var GL_MODULATE = 0x2100;
|
|
2189
|
+
var GL_SUBTRACT = 0x84E7;
|
|
2190
|
+
var GL_INTERPOLATE = 0x8575;
|
|
2191
|
+
|
|
2192
|
+
// env.color/alphaSrc
|
|
2193
|
+
var GL_TEXTURE = 0x1702;
|
|
2194
|
+
var GL_CONSTANT = 0x8576;
|
|
2195
|
+
var GL_PRIMARY_COLOR = 0x8577;
|
|
2196
|
+
var GL_PREVIOUS = 0x8578;
|
|
2197
|
+
|
|
2198
|
+
// env.color/alphaOp
|
|
2199
|
+
var GL_SRC_COLOR = 0x0300;
|
|
2200
|
+
var GL_ONE_MINUS_SRC_COLOR = 0x0301;
|
|
2201
|
+
var GL_SRC_ALPHA = 0x0302;
|
|
2202
|
+
var GL_ONE_MINUS_SRC_ALPHA = 0x0303;
|
|
2203
|
+
|
|
2204
|
+
var GL_RGB = 0x1907;
|
|
2205
|
+
var GL_RGBA = 0x1908;
|
|
2206
|
+
|
|
2207
|
+
// Our defs:
|
|
2208
|
+
var TEXENVJIT_NAMESPACE_PREFIX = "tej_";
|
|
2209
|
+
// Not actually constant, as they can be changed between JIT passes:
|
|
2210
|
+
var TEX_UNIT_UNIFORM_PREFIX = "uTexUnit";
|
|
2211
|
+
var TEX_COORD_VARYING_PREFIX = "vTexCoord";
|
|
2212
|
+
var PRIM_COLOR_VARYING = "vPrimColor";
|
|
2213
|
+
var TEX_MATRIX_UNIFORM_PREFIX = "uTexMatrix";
|
|
2214
|
+
|
|
2215
|
+
// Static vars:
|
|
2216
|
+
var s_texUnits = null; //[];
|
|
2217
|
+
var s_activeTexture = 0;
|
|
2218
|
+
|
|
2219
|
+
var s_requiredTexUnitsForPass = [];
|
|
2220
|
+
|
|
2221
|
+
// Static funcs:
|
|
2222
|
+
function abort(info) {
|
|
2223
|
+
assert(false, "[TexEnvJIT] ABORT: " + info);
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
function abort_noSupport(info) {
|
|
2227
|
+
abort("No support: " + info);
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
function abort_sanity(info) {
|
|
2231
|
+
abort("Sanity failure: " + info);
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
function genTexUnitSampleExpr(texUnitID) {
|
|
2235
|
+
var texUnit = s_texUnits[texUnitID];
|
|
2236
|
+
var texType = texUnit.getTexType();
|
|
2237
|
+
|
|
2238
|
+
var func = null;
|
|
2239
|
+
switch (texType) {
|
|
2240
|
+
case GL_TEXTURE_1D:
|
|
2241
|
+
func = "texture2D";
|
|
2242
|
+
break;
|
|
2243
|
+
case GL_TEXTURE_2D:
|
|
2244
|
+
func = "texture2D";
|
|
2245
|
+
break;
|
|
2246
|
+
case GL_TEXTURE_3D:
|
|
2247
|
+
return abort_noSupport("No support for 3D textures.");
|
|
2248
|
+
case GL_TEXTURE_CUBE_MAP:
|
|
2249
|
+
func = "textureCube";
|
|
2250
|
+
break;
|
|
2251
|
+
default:
|
|
2252
|
+
return abort_sanity("Unknown texType: 0x" + texType.toString(16));
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
var texCoordExpr = TEX_COORD_VARYING_PREFIX + texUnitID;
|
|
2256
|
+
if (TEX_MATRIX_UNIFORM_PREFIX != null) {
|
|
2257
|
+
texCoordExpr = "(" + TEX_MATRIX_UNIFORM_PREFIX + texUnitID + " * " + texCoordExpr + ")";
|
|
2258
|
+
}
|
|
2259
|
+
return func + "(" + TEX_UNIT_UNIFORM_PREFIX + texUnitID + ", " + texCoordExpr + ".xy)";
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
function getTypeFromCombineOp(op) {
|
|
2263
|
+
switch (op) {
|
|
2264
|
+
case GL_SRC_COLOR:
|
|
2265
|
+
case GL_ONE_MINUS_SRC_COLOR:
|
|
2266
|
+
return "vec3";
|
|
2267
|
+
case GL_SRC_ALPHA:
|
|
2268
|
+
case GL_ONE_MINUS_SRC_ALPHA:
|
|
2269
|
+
return "float";
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
return Abort_NoSupport("Unsupported combiner op: 0x" + op.toString(16));
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
function getCurTexUnit() {
|
|
2276
|
+
return s_texUnits[s_activeTexture];
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
function genCombinerSourceExpr(texUnitID, constantExpr, previousVar,
|
|
2280
|
+
src, op)
|
|
2281
|
+
{
|
|
2282
|
+
var srcExpr = null;
|
|
2283
|
+
switch (src) {
|
|
2284
|
+
case GL_TEXTURE:
|
|
2285
|
+
srcExpr = genTexUnitSampleExpr(texUnitID);
|
|
2286
|
+
break;
|
|
2287
|
+
case GL_CONSTANT:
|
|
2288
|
+
srcExpr = constantExpr;
|
|
2289
|
+
break;
|
|
2290
|
+
case GL_PRIMARY_COLOR:
|
|
2291
|
+
srcExpr = PRIM_COLOR_VARYING;
|
|
2292
|
+
break;
|
|
2293
|
+
case GL_PREVIOUS:
|
|
2294
|
+
srcExpr = previousVar;
|
|
2295
|
+
break;
|
|
2296
|
+
default:
|
|
2297
|
+
return abort_noSupport("Unsupported combiner src: 0x" + src.toString(16));
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
var expr = null;
|
|
2301
|
+
switch (op) {
|
|
2302
|
+
case GL_SRC_COLOR:
|
|
2303
|
+
expr = srcExpr + ".rgb";
|
|
2304
|
+
break;
|
|
2305
|
+
case GL_ONE_MINUS_SRC_COLOR:
|
|
2306
|
+
expr = "(vec3(1.0) - " + srcExpr + ".rgb)";
|
|
2307
|
+
break;
|
|
2308
|
+
case GL_SRC_ALPHA:
|
|
2309
|
+
expr = srcExpr + ".a";
|
|
2310
|
+
break;
|
|
2311
|
+
case GL_ONE_MINUS_SRC_ALPHA:
|
|
2312
|
+
expr = "(1.0 - " + srcExpr + ".a)";
|
|
2313
|
+
break;
|
|
2314
|
+
default:
|
|
2315
|
+
return abort_noSupport("Unsupported combiner op: 0x" + op.toString(16));
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
return expr;
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
function valToFloatLiteral(val) {
|
|
2322
|
+
if (val == Math.round(val)) return val + '.0';
|
|
2323
|
+
return val;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
// Classes:
|
|
2328
|
+
function CTexEnv() {
|
|
2329
|
+
this.mode = GL_MODULATE;
|
|
2330
|
+
this.colorCombiner = GL_MODULATE;
|
|
2331
|
+
this.alphaCombiner = GL_MODULATE;
|
|
2332
|
+
this.colorScale = 1;
|
|
2333
|
+
this.alphaScale = 1;
|
|
2334
|
+
this.envColor = [0, 0, 0, 0];
|
|
2335
|
+
|
|
2336
|
+
this.colorSrc = [
|
|
2337
|
+
GL_TEXTURE,
|
|
2338
|
+
GL_PREVIOUS,
|
|
2339
|
+
GL_CONSTANT
|
|
2340
|
+
];
|
|
2341
|
+
this.alphaSrc = [
|
|
2342
|
+
GL_TEXTURE,
|
|
2343
|
+
GL_PREVIOUS,
|
|
2344
|
+
GL_CONSTANT
|
|
2345
|
+
];
|
|
2346
|
+
this.colorOp = [
|
|
2347
|
+
GL_SRC_COLOR,
|
|
2348
|
+
GL_SRC_COLOR,
|
|
2349
|
+
GL_SRC_ALPHA
|
|
2350
|
+
];
|
|
2351
|
+
this.alphaOp = [
|
|
2352
|
+
GL_SRC_ALPHA,
|
|
2353
|
+
GL_SRC_ALPHA,
|
|
2354
|
+
GL_SRC_ALPHA
|
|
2355
|
+
];
|
|
2356
|
+
|
|
2357
|
+
this.traverseState = function(keyView) {
|
|
2358
|
+
keyView.next(this.mode);
|
|
2359
|
+
keyView.next(this.colorCombiner);
|
|
2360
|
+
keyView.next(this.alphaCombiner);
|
|
2361
|
+
keyView.next(this.colorCombiner);
|
|
2362
|
+
keyView.next(this.alphaScale);
|
|
2363
|
+
keyView.next(this.envColor[0]);
|
|
2364
|
+
keyView.next(this.envColor[1]);
|
|
2365
|
+
keyView.next(this.envColor[2]);
|
|
2366
|
+
keyView.next(this.envColor[3]);
|
|
2367
|
+
|
|
2368
|
+
keyView.next(this.colorSrc[0]);
|
|
2369
|
+
keyView.next(this.colorSrc[1]);
|
|
2370
|
+
keyView.next(this.colorSrc[2]);
|
|
2371
|
+
|
|
2372
|
+
keyView.next(this.alphaSrc[0]);
|
|
2373
|
+
keyView.next(this.alphaSrc[1]);
|
|
2374
|
+
keyView.next(this.alphaSrc[2]);
|
|
2375
|
+
|
|
2376
|
+
keyView.next(this.colorOp[0]);
|
|
2377
|
+
keyView.next(this.colorOp[1]);
|
|
2378
|
+
keyView.next(this.colorOp[2]);
|
|
2379
|
+
|
|
2380
|
+
keyView.next(this.alphaOp[0]);
|
|
2381
|
+
keyView.next(this.alphaOp[1]);
|
|
2382
|
+
keyView.next(this.alphaOp[2]);
|
|
2383
|
+
};
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
function CTexUnit() {
|
|
2387
|
+
this.env = new CTexEnv();
|
|
2388
|
+
this.enabled_tex1D = false;
|
|
2389
|
+
this.enabled_tex2D = false;
|
|
2390
|
+
this.enabled_tex3D = false;
|
|
2391
|
+
this.enabled_texCube = false;
|
|
2392
|
+
|
|
2393
|
+
this.traverseState = function(keyView) {
|
|
2394
|
+
var texUnitType = this.getTexType();
|
|
2395
|
+
keyView.next(texUnitType);
|
|
2396
|
+
if (!texUnitType) return;
|
|
2397
|
+
this.env.traverseState(keyView);
|
|
2398
|
+
};
|
|
2399
|
+
};
|
|
2400
|
+
|
|
2401
|
+
// Class impls:
|
|
2402
|
+
CTexUnit.prototype.enabled = function() {
|
|
2403
|
+
return this.getTexType() != 0;
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
CTexUnit.prototype.genPassLines = function(passOutputVar, passInputVar, texUnitID) {
|
|
2407
|
+
if (!this.enabled()) {
|
|
2408
|
+
return ["vec4 " + passOutputVar + " = " + passInputVar + ";"];
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
return this.env.genPassLines(passOutputVar, passInputVar, texUnitID);
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
CTexUnit.prototype.getTexType = function() {
|
|
2415
|
+
if (this.enabled_texCube) {
|
|
2416
|
+
return GL_TEXTURE_CUBE_MAP;
|
|
2417
|
+
} else if (this.enabled_tex3D) {
|
|
2418
|
+
return GL_TEXTURE_3D;
|
|
2419
|
+
} else if (this.enabled_tex2D) {
|
|
2420
|
+
return GL_TEXTURE_2D;
|
|
2421
|
+
} else if (this.enabled_tex1D) {
|
|
2422
|
+
return GL_TEXTURE_1D;
|
|
2423
|
+
}
|
|
2424
|
+
return 0;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
CTexEnv.prototype.genPassLines = function(passOutputVar, passInputVar, texUnitID) {
|
|
2428
|
+
switch (this.mode) {
|
|
2429
|
+
case GL_REPLACE: {
|
|
2430
|
+
/* RGB:
|
|
2431
|
+
* Cv = Cs
|
|
2432
|
+
* Av = Ap // Note how this is different, and that we'll
|
|
2433
|
+
* need to track the bound texture internalFormat
|
|
2434
|
+
* to get this right.
|
|
2435
|
+
*
|
|
2436
|
+
* RGBA:
|
|
2437
|
+
* Cv = Cs
|
|
2438
|
+
* Av = As
|
|
2439
|
+
*/
|
|
2440
|
+
return [
|
|
2441
|
+
"vec4 " + passOutputVar + " = " + genTexUnitSampleExpr(texUnitID) + ";",
|
|
2442
|
+
];
|
|
2443
|
+
}
|
|
2444
|
+
case GL_ADD: {
|
|
2445
|
+
/* RGBA:
|
|
2446
|
+
* Cv = Cp + Cs
|
|
2447
|
+
* Av = ApAs
|
|
2448
|
+
*/
|
|
2449
|
+
var prefix = TEXENVJIT_NAMESPACE_PREFIX + 'env' + texUnitID + "_";
|
|
2450
|
+
var texVar = prefix + "tex";
|
|
2451
|
+
var colorVar = prefix + "color";
|
|
2452
|
+
var alphaVar = prefix + "alpha";
|
|
2453
|
+
|
|
2454
|
+
return [
|
|
2455
|
+
"vec4 " + texVar + " = " + genTexUnitSampleExpr(texUnitID) + ";",
|
|
2456
|
+
"vec3 " + colorVar + " = " + passInputVar + ".rgb + " + texVar + ".rgb;",
|
|
2457
|
+
"float " + alphaVar + " = " + passInputVar + ".a * " + texVar + ".a;",
|
|
2458
|
+
"vec4 " + passOutputVar + " = vec4(" + colorVar + ", " + alphaVar + ");",
|
|
2459
|
+
];
|
|
2460
|
+
}
|
|
2461
|
+
case GL_MODULATE: {
|
|
2462
|
+
/* RGBA:
|
|
2463
|
+
* Cv = CpCs
|
|
2464
|
+
* Av = ApAs
|
|
2465
|
+
*/
|
|
2466
|
+
var line = [
|
|
2467
|
+
"vec4 " + passOutputVar,
|
|
2468
|
+
" = ",
|
|
2469
|
+
passInputVar,
|
|
2470
|
+
" * ",
|
|
2471
|
+
genTexUnitSampleExpr(texUnitID),
|
|
2472
|
+
";",
|
|
2473
|
+
];
|
|
2474
|
+
return [line.join("")];
|
|
2475
|
+
}
|
|
2476
|
+
case GL_DECAL: {
|
|
2477
|
+
/* RGBA:
|
|
2478
|
+
* Cv = Cp(1 - As) + CsAs
|
|
2479
|
+
* Av = Ap
|
|
2480
|
+
*/
|
|
2481
|
+
var prefix = TEXENVJIT_NAMESPACE_PREFIX + 'env' + texUnitID + "_";
|
|
2482
|
+
var texVar = prefix + "tex";
|
|
2483
|
+
var colorVar = prefix + "color";
|
|
2484
|
+
var alphaVar = prefix + "alpha";
|
|
2485
|
+
|
|
2486
|
+
return [
|
|
2487
|
+
"vec4 " + texVar + " = " + genTexUnitSampleExpr(texUnitID) + ";",
|
|
2488
|
+
[
|
|
2489
|
+
"vec3 " + colorVar + " = ",
|
|
2490
|
+
passInputVar + ".rgb * (1.0 - " + texVar + ".a)",
|
|
2491
|
+
" + ",
|
|
2492
|
+
texVar + ".rgb * " + texVar + ".a",
|
|
2493
|
+
";"
|
|
2494
|
+
].join(""),
|
|
2495
|
+
"float " + alphaVar + " = " + passInputVar + ".a;",
|
|
2496
|
+
"vec4 " + passOutputVar + " = vec4(" + colorVar + ", " + alphaVar + ");",
|
|
2497
|
+
];
|
|
2498
|
+
}
|
|
2499
|
+
case GL_BLEND: {
|
|
2500
|
+
/* RGBA:
|
|
2501
|
+
* Cv = Cp(1 - Cs) + CcCs
|
|
2502
|
+
* Av = As
|
|
2503
|
+
*/
|
|
2504
|
+
var prefix = TEXENVJIT_NAMESPACE_PREFIX + 'env' + texUnitID + "_";
|
|
2505
|
+
var texVar = prefix + "tex";
|
|
2506
|
+
var colorVar = prefix + "color";
|
|
2507
|
+
var alphaVar = prefix + "alpha";
|
|
2508
|
+
|
|
2509
|
+
return [
|
|
2510
|
+
"vec4 " + texVar + " = " + genTexUnitSampleExpr(texUnitID) + ";",
|
|
2511
|
+
[
|
|
2512
|
+
"vec3 " + colorVar + " = ",
|
|
2513
|
+
passInputVar + ".rgb * (1.0 - " + texVar + ".rgb)",
|
|
2514
|
+
" + ",
|
|
2515
|
+
PRIM_COLOR_VARYING + ".rgb * " + texVar + ".rgb",
|
|
2516
|
+
";"
|
|
2517
|
+
].join(""),
|
|
2518
|
+
"float " + alphaVar + " = " + texVar + ".a;",
|
|
2519
|
+
"vec4 " + passOutputVar + " = vec4(" + colorVar + ", " + alphaVar + ");",
|
|
2520
|
+
];
|
|
2521
|
+
}
|
|
2522
|
+
case GL_COMBINE: {
|
|
2523
|
+
var prefix = TEXENVJIT_NAMESPACE_PREFIX + 'env' + texUnitID + "_";
|
|
2524
|
+
var colorVar = prefix + "color";
|
|
2525
|
+
var alphaVar = prefix + "alpha";
|
|
2526
|
+
var colorLines = this.genCombinerLines(true, colorVar,
|
|
2527
|
+
passInputVar, texUnitID,
|
|
2528
|
+
this.colorCombiner, this.colorSrc, this.colorOp);
|
|
2529
|
+
var alphaLines = this.genCombinerLines(false, alphaVar,
|
|
2530
|
+
passInputVar, texUnitID,
|
|
2531
|
+
this.alphaCombiner, this.alphaSrc, this.alphaOp);
|
|
2532
|
+
var line = [
|
|
2533
|
+
"vec4 " + passOutputVar,
|
|
2534
|
+
" = ",
|
|
2535
|
+
"vec4(",
|
|
2536
|
+
colorVar + " * " + valToFloatLiteral(this.colorScale),
|
|
2537
|
+
", ",
|
|
2538
|
+
alphaVar + " * " + valToFloatLiteral(this.alphaScale),
|
|
2539
|
+
")",
|
|
2540
|
+
";",
|
|
2541
|
+
].join("");
|
|
2542
|
+
return [].concat(colorLines, alphaLines, [line]);
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
return Abort_NoSupport("Unsupported TexEnv mode: 0x" + this.mode.toString(16));
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
CTexEnv.prototype.genCombinerLines = function(isColor, outputVar,
|
|
2550
|
+
passInputVar, texUnitID,
|
|
2551
|
+
combiner, srcArr, opArr)
|
|
2552
|
+
{
|
|
2553
|
+
var argsNeeded = null;
|
|
2554
|
+
switch (combiner) {
|
|
2555
|
+
case GL_REPLACE:
|
|
2556
|
+
argsNeeded = 1;
|
|
2557
|
+
break;
|
|
2558
|
+
|
|
2559
|
+
case GL_MODULATE:
|
|
2560
|
+
case GL_ADD:
|
|
2561
|
+
case GL_SUBTRACT:
|
|
2562
|
+
argsNeeded = 2;
|
|
2563
|
+
break;
|
|
2564
|
+
|
|
2565
|
+
case GL_INTERPOLATE:
|
|
2566
|
+
argsNeeded = 3;
|
|
2567
|
+
break;
|
|
2568
|
+
|
|
2569
|
+
default:
|
|
2570
|
+
return abort_noSupport("Unsupported combiner: 0x" + combiner.toString(16));
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
var constantExpr = [
|
|
2574
|
+
"vec4(",
|
|
2575
|
+
valToFloatLiteral(this.envColor[0]),
|
|
2576
|
+
", ",
|
|
2577
|
+
valToFloatLiteral(this.envColor[1]),
|
|
2578
|
+
", ",
|
|
2579
|
+
valToFloatLiteral(this.envColor[2]),
|
|
2580
|
+
", ",
|
|
2581
|
+
valToFloatLiteral(this.envColor[3]),
|
|
2582
|
+
")",
|
|
2583
|
+
].join("");
|
|
2584
|
+
var src0Expr = (argsNeeded >= 1) ? genCombinerSourceExpr(texUnitID, constantExpr, passInputVar, srcArr[0], opArr[0])
|
|
2585
|
+
: null;
|
|
2586
|
+
var src1Expr = (argsNeeded >= 2) ? genCombinerSourceExpr(texUnitID, constantExpr, passInputVar, srcArr[1], opArr[1])
|
|
2587
|
+
: null;
|
|
2588
|
+
var src2Expr = (argsNeeded >= 3) ? genCombinerSourceExpr(texUnitID, constantExpr, passInputVar, srcArr[2], opArr[2])
|
|
2589
|
+
: null;
|
|
2590
|
+
|
|
2591
|
+
var outputType = isColor ? "vec3" : "float";
|
|
2592
|
+
var lines = null;
|
|
2593
|
+
switch (combiner) {
|
|
2594
|
+
case GL_REPLACE: {
|
|
2595
|
+
var line = [
|
|
2596
|
+
outputType + " " + outputVar,
|
|
2597
|
+
" = ",
|
|
2598
|
+
src0Expr,
|
|
2599
|
+
";",
|
|
2600
|
+
];
|
|
2601
|
+
lines = [line.join("")];
|
|
2602
|
+
break;
|
|
2603
|
+
}
|
|
2604
|
+
case GL_MODULATE: {
|
|
2605
|
+
var line = [
|
|
2606
|
+
outputType + " " + outputVar + " = ",
|
|
2607
|
+
src0Expr + " * " + src1Expr,
|
|
2608
|
+
";",
|
|
2609
|
+
];
|
|
2610
|
+
lines = [line.join("")];
|
|
2611
|
+
break;
|
|
2612
|
+
}
|
|
2613
|
+
case GL_ADD: {
|
|
2614
|
+
var line = [
|
|
2615
|
+
outputType + " " + outputVar + " = ",
|
|
2616
|
+
src0Expr + " + " + src1Expr,
|
|
2617
|
+
";",
|
|
2618
|
+
];
|
|
2619
|
+
lines = [line.join("")];
|
|
2620
|
+
break;
|
|
2621
|
+
}
|
|
2622
|
+
case GL_SUBTRACT: {
|
|
2623
|
+
var line = [
|
|
2624
|
+
outputType + " " + outputVar + " = ",
|
|
2625
|
+
src0Expr + " - " + src1Expr,
|
|
2626
|
+
";",
|
|
2627
|
+
];
|
|
2628
|
+
lines = [line.join("")];
|
|
2629
|
+
break;
|
|
2630
|
+
}
|
|
2631
|
+
case GL_INTERPOLATE: {
|
|
2632
|
+
var prefix = TEXENVJIT_NAMESPACE_PREFIX + 'env' + texUnitID + "_";
|
|
2633
|
+
var arg2Var = prefix + "colorSrc2";
|
|
2634
|
+
var arg2Line = getTypeFromCombineOp(this.colorOp[2]) + " " + arg2Var + " = " + src2Expr + ";";
|
|
2635
|
+
|
|
2636
|
+
var line = [
|
|
2637
|
+
outputType + " " + outputVar,
|
|
2638
|
+
" = ",
|
|
2639
|
+
src0Expr + " * " + arg2Var,
|
|
2640
|
+
" + ",
|
|
2641
|
+
src1Expr + " * (1.0 - " + arg2Var + ")",
|
|
2642
|
+
";",
|
|
2643
|
+
];
|
|
2644
|
+
lines = [
|
|
2645
|
+
arg2Line,
|
|
2646
|
+
line.join(""),
|
|
2647
|
+
];
|
|
2648
|
+
break;
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
default:
|
|
2652
|
+
return abort_sanity("Unmatched TexEnv.colorCombiner?");
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
return lines;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
return {
|
|
2659
|
+
// Exports:
|
|
2660
|
+
init: function(gl, specifiedMaxTextureImageUnits) {
|
|
2661
|
+
var maxTexUnits = 0;
|
|
2662
|
+
if (specifiedMaxTextureImageUnits) {
|
|
2663
|
+
maxTexUnits = specifiedMaxTextureImageUnits;
|
|
2664
|
+
} else if (gl) {
|
|
2665
|
+
maxTexUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
assert(maxTexUnits > 0);
|
|
2669
|
+
|
|
2670
|
+
s_texUnits = [];
|
|
2671
|
+
for (var i = 0; i < maxTexUnits; i++) {
|
|
2672
|
+
s_texUnits.push(new CTexUnit());
|
|
2673
|
+
}
|
|
2674
|
+
},
|
|
2675
|
+
|
|
2676
|
+
setGLSLVars: function(uTexUnitPrefix, vTexCoordPrefix, vPrimColor, uTexMatrixPrefix) {
|
|
2677
|
+
TEX_UNIT_UNIFORM_PREFIX = uTexUnitPrefix;
|
|
2678
|
+
TEX_COORD_VARYING_PREFIX = vTexCoordPrefix;
|
|
2679
|
+
PRIM_COLOR_VARYING = vPrimColor;
|
|
2680
|
+
TEX_MATRIX_UNIFORM_PREFIX = uTexMatrixPrefix;
|
|
2681
|
+
},
|
|
2682
|
+
|
|
2683
|
+
genAllPassLines: function(resultDest, indentSize) {
|
|
2684
|
+
indentSize = indentSize || 0;
|
|
2685
|
+
|
|
2686
|
+
s_requiredTexUnitsForPass.length = 0; // Clear the list.
|
|
2687
|
+
var lines = [];
|
|
2688
|
+
var lastPassVar = PRIM_COLOR_VARYING;
|
|
2689
|
+
for (var i = 0; i < s_texUnits.length; i++) {
|
|
2690
|
+
if (!s_texUnits[i].enabled()) continue;
|
|
2691
|
+
|
|
2692
|
+
s_requiredTexUnitsForPass.push(i);
|
|
2693
|
+
|
|
2694
|
+
var prefix = TEXENVJIT_NAMESPACE_PREFIX + 'env' + i + "_";
|
|
2695
|
+
var passOutputVar = prefix + "result";
|
|
2696
|
+
|
|
2697
|
+
var newLines = s_texUnits[i].genPassLines(passOutputVar, lastPassVar, i);
|
|
2698
|
+
lines = lines.concat(newLines, [""]);
|
|
2699
|
+
|
|
2700
|
+
lastPassVar = passOutputVar;
|
|
2701
|
+
}
|
|
2702
|
+
lines.push(resultDest + " = " + lastPassVar + ";");
|
|
2703
|
+
|
|
2704
|
+
var indent = "";
|
|
2705
|
+
for (var i = 0; i < indentSize; i++) indent += " ";
|
|
2706
|
+
|
|
2707
|
+
var output = indent + lines.join("\n" + indent);
|
|
2708
|
+
|
|
2709
|
+
return output;
|
|
2710
|
+
},
|
|
2711
|
+
|
|
2712
|
+
getUsedTexUnitList: function() {
|
|
2713
|
+
return s_requiredTexUnitsForPass;
|
|
2714
|
+
},
|
|
2715
|
+
|
|
2716
|
+
traverseState: function(keyView) {
|
|
2717
|
+
for (var i = 0; i < s_texUnits.length; i++) {
|
|
2718
|
+
var texUnit = s_texUnits[i];
|
|
2719
|
+
var enabled = texUnit.enabled();
|
|
2720
|
+
keyView.next(enabled);
|
|
2721
|
+
if (enabled) {
|
|
2722
|
+
texUnit.traverseState(keyView);
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
},
|
|
2726
|
+
|
|
2727
|
+
getTexUnitType: function(texUnitID) {
|
|
2728
|
+
assert(texUnitID >= 0 &&
|
|
2729
|
+
texUnitID < s_texUnits.length);
|
|
2730
|
+
|
|
2731
|
+
return s_texUnits[texUnitID].getTexType();
|
|
2732
|
+
},
|
|
2733
|
+
|
|
2734
|
+
// Hooks:
|
|
2735
|
+
hook_activeTexture: function(texture) {
|
|
2736
|
+
s_activeTexture = texture - GL_TEXTURE0;
|
|
2737
|
+
},
|
|
2738
|
+
|
|
2739
|
+
hook_enable: function(cap) {
|
|
2740
|
+
var cur = getCurTexUnit();
|
|
2741
|
+
switch (cap) {
|
|
2742
|
+
case GL_TEXTURE_1D:
|
|
2743
|
+
cur.enabled_tex1D = true;
|
|
2744
|
+
break;
|
|
2745
|
+
case GL_TEXTURE_2D:
|
|
2746
|
+
cur.enabled_tex2D = true;
|
|
2747
|
+
break;
|
|
2748
|
+
case GL_TEXTURE_3D:
|
|
2749
|
+
cur.enabled_tex3D = true;
|
|
2750
|
+
break;
|
|
2751
|
+
case GL_TEXTURE_CUBE_MAP:
|
|
2752
|
+
cur.enabled_texCube = true;
|
|
2753
|
+
break;
|
|
2754
|
+
}
|
|
2755
|
+
},
|
|
2756
|
+
|
|
2757
|
+
hook_disable: function(cap) {
|
|
2758
|
+
var cur = getCurTexUnit();
|
|
2759
|
+
switch (cap) {
|
|
2760
|
+
case GL_TEXTURE_1D:
|
|
2761
|
+
cur.enabled_tex1D = false;
|
|
2762
|
+
break;
|
|
2763
|
+
case GL_TEXTURE_2D:
|
|
2764
|
+
cur.enabled_tex2D = false;
|
|
2765
|
+
break;
|
|
2766
|
+
case GL_TEXTURE_3D:
|
|
2767
|
+
cur.enabled_tex3D = false;
|
|
2768
|
+
break;
|
|
2769
|
+
case GL_TEXTURE_CUBE_MAP:
|
|
2770
|
+
cur.enabled_texCube = false;
|
|
2771
|
+
break;
|
|
2772
|
+
}
|
|
2773
|
+
},
|
|
2774
|
+
|
|
2775
|
+
hook_texEnvf: function(target, pname, param) {
|
|
2776
|
+
if (target != GL_TEXTURE_ENV)
|
|
2777
|
+
return;
|
|
2778
|
+
|
|
2779
|
+
var env = getCurTexUnit().env;
|
|
2780
|
+
switch (pname) {
|
|
2781
|
+
case GL_RGB_SCALE:
|
|
2782
|
+
env.colorScale = param;
|
|
2783
|
+
break;
|
|
2784
|
+
case GL_ALPHA_SCALE:
|
|
2785
|
+
env.alphaScale = param;
|
|
2786
|
+
break;
|
|
2787
|
+
|
|
2788
|
+
default:
|
|
2789
|
+
Module.printErr('WARNING: Unhandled `pname` in call to `glTexEnvf`.');
|
|
2790
|
+
}
|
|
2791
|
+
},
|
|
2792
|
+
|
|
2793
|
+
hook_texEnvi: function(target, pname, param) {
|
|
2794
|
+
if (target != GL_TEXTURE_ENV)
|
|
2795
|
+
return;
|
|
2796
|
+
|
|
2797
|
+
var env = getCurTexUnit().env;
|
|
2798
|
+
switch (pname) {
|
|
2799
|
+
case GL_TEXTURE_ENV_MODE:
|
|
2800
|
+
env.mode = param;
|
|
2801
|
+
break;
|
|
2802
|
+
|
|
2803
|
+
case GL_COMBINE_RGB:
|
|
2804
|
+
env.colorCombiner = param;
|
|
2805
|
+
break;
|
|
2806
|
+
case GL_COMBINE_ALPHA:
|
|
2807
|
+
env.alphaCombiner = param;
|
|
2808
|
+
break;
|
|
2809
|
+
|
|
2810
|
+
case GL_SRC0_RGB:
|
|
2811
|
+
env.colorSrc[0] = param;
|
|
2812
|
+
break;
|
|
2813
|
+
case GL_SRC1_RGB:
|
|
2814
|
+
env.colorSrc[1] = param;
|
|
2815
|
+
break;
|
|
2816
|
+
case GL_SRC2_RGB:
|
|
2817
|
+
env.colorSrc[2] = param;
|
|
2818
|
+
break;
|
|
2819
|
+
|
|
2820
|
+
case GL_SRC0_ALPHA:
|
|
2821
|
+
env.alphaSrc[0] = param;
|
|
2822
|
+
break;
|
|
2823
|
+
case GL_SRC1_ALPHA:
|
|
2824
|
+
env.alphaSrc[1] = param;
|
|
2825
|
+
break;
|
|
2826
|
+
case GL_SRC2_ALPHA:
|
|
2827
|
+
env.alphaSrc[2] = param;
|
|
2828
|
+
break;
|
|
2829
|
+
|
|
2830
|
+
case GL_OPERAND0_RGB:
|
|
2831
|
+
env.colorOp[0] = param;
|
|
2832
|
+
break;
|
|
2833
|
+
case GL_OPERAND1_RGB:
|
|
2834
|
+
env.colorOp[1] = param;
|
|
2835
|
+
break;
|
|
2836
|
+
case GL_OPERAND2_RGB:
|
|
2837
|
+
env.colorOp[2] = param;
|
|
2838
|
+
break;
|
|
2839
|
+
|
|
2840
|
+
case GL_OPERAND0_ALPHA:
|
|
2841
|
+
env.alphaOp[0] = param;
|
|
2842
|
+
break;
|
|
2843
|
+
case GL_OPERAND1_ALPHA:
|
|
2844
|
+
env.alphaOp[1] = param;
|
|
2845
|
+
break;
|
|
2846
|
+
case GL_OPERAND2_ALPHA:
|
|
2847
|
+
env.alphaOp[2] = param;
|
|
2848
|
+
break;
|
|
2849
|
+
|
|
2850
|
+
case GL_RGB_SCALE:
|
|
2851
|
+
env.colorScale = param;
|
|
2852
|
+
break;
|
|
2853
|
+
case GL_ALPHA_SCALE:
|
|
2854
|
+
env.alphaScale = param;
|
|
2855
|
+
break;
|
|
2856
|
+
|
|
2857
|
+
default:
|
|
2858
|
+
Module.printErr('WARNING: Unhandled `pname` in call to `glTexEnvi`.');
|
|
2859
|
+
}
|
|
2860
|
+
},
|
|
2861
|
+
|
|
2862
|
+
hook_texEnvfv: function(target, pname, params) {
|
|
2863
|
+
if (target != GL_TEXTURE_ENV) return;
|
|
2864
|
+
|
|
2865
|
+
var env = getCurTexUnit().env;
|
|
2866
|
+
switch (pname) {
|
|
2867
|
+
case GL_TEXTURE_ENV_COLOR: {
|
|
2868
|
+
for (var i = 0; i < 4; i++) {
|
|
2869
|
+
var param = {{{ makeGetValue('params', 'i*4', 'float') }}};
|
|
2870
|
+
env.envColor[i] = param;
|
|
2871
|
+
}
|
|
2872
|
+
break
|
|
2873
|
+
}
|
|
2874
|
+
default:
|
|
2875
|
+
Module.printErr('WARNING: Unhandled `pname` in call to `glTexEnvfv`.');
|
|
2876
|
+
}
|
|
2877
|
+
},
|
|
2878
|
+
};
|
|
2879
|
+
},
|
|
2880
|
+
|
|
2881
|
+
// Vertex and index data
|
|
2882
|
+
vertexData: null, // current vertex data. either tempData (glBegin etc.) or a view into the heap (gl*Pointer). Default view is F32
|
|
2883
|
+
vertexDataU8: null, // U8 view
|
|
2884
|
+
tempData: null,
|
|
2885
|
+
indexData: null,
|
|
2886
|
+
vertexCounter: 0,
|
|
2887
|
+
mode: -1,
|
|
2888
|
+
|
|
2889
|
+
rendererCache: null,
|
|
2890
|
+
rendererComponents: [], // small cache for calls inside glBegin/end. counts how many times the element was seen
|
|
2891
|
+
rendererComponentPointer: 0, // next place to start a glBegin/end component
|
|
2892
|
+
lastRenderer: null, // used to avoid cleaning up and re-preparing the same renderer
|
|
2893
|
+
lastArrayBuffer: null, // used in conjunction with lastRenderer
|
|
2894
|
+
lastProgram: null, // ""
|
|
2895
|
+
lastStride: -1, // ""
|
|
2896
|
+
|
|
2897
|
+
// The following data structures are used for OpenGL Immediate Mode matrix routines.
|
|
2898
|
+
matrix: {},
|
|
2899
|
+
matrixStack: {},
|
|
2900
|
+
currentMatrix: 'm', // default is modelview
|
|
2901
|
+
tempMatrix: null,
|
|
2902
|
+
matricesModified: false,
|
|
2903
|
+
useTextureMatrix: false,
|
|
2904
|
+
|
|
2905
|
+
// Clientside attributes
|
|
2906
|
+
VERTEX: 0,
|
|
2907
|
+
NORMAL: 1,
|
|
2908
|
+
COLOR: 2,
|
|
2909
|
+
TEXTURE0: 3,
|
|
2910
|
+
TEXTURE1: 4,
|
|
2911
|
+
TEXTURE2: 5,
|
|
2912
|
+
TEXTURE3: 6,
|
|
2913
|
+
TEXTURE4: 7,
|
|
2914
|
+
TEXTURE5: 8,
|
|
2915
|
+
TEXTURE6: 9,
|
|
2916
|
+
NUM_ATTRIBUTES: 10, // Overwritten in init().
|
|
2917
|
+
MAX_TEXTURES: 7, // Overwritten in init().
|
|
2918
|
+
|
|
2919
|
+
totalEnabledClientAttributes: 0,
|
|
2920
|
+
enabledClientAttributes: [0, 0],
|
|
2921
|
+
clientAttributes: [], // raw data, including possible unneeded ones
|
|
2922
|
+
liveClientAttributes: [], // the ones actually alive in the current computation, sorted
|
|
2923
|
+
modifiedClientAttributes: false,
|
|
2924
|
+
clientActiveTexture: 0,
|
|
2925
|
+
clientColor: null,
|
|
2926
|
+
usedTexUnitList: [],
|
|
2927
|
+
fixedFunctionProgram: null,
|
|
2928
|
+
|
|
2929
|
+
setClientAttribute: function(name, size, type, stride, pointer) {
|
|
2930
|
+
var attrib = this.clientAttributes[name];
|
|
2931
|
+
if (!attrib) {
|
|
2932
|
+
for (var i = 0; i <= name; i++) { // keep flat
|
|
2933
|
+
if (!this.clientAttributes[i]) {
|
|
2934
|
+
this.clientAttributes[i] = {
|
|
2935
|
+
name: name,
|
|
2936
|
+
size: size,
|
|
2937
|
+
type: type,
|
|
2938
|
+
stride: stride,
|
|
2939
|
+
pointer: pointer,
|
|
2940
|
+
offset: 0
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
} else {
|
|
2945
|
+
attrib.name = name;
|
|
2946
|
+
attrib.size = size;
|
|
2947
|
+
attrib.type = type;
|
|
2948
|
+
attrib.stride = stride;
|
|
2949
|
+
attrib.pointer = pointer;
|
|
2950
|
+
attrib.offset = 0;
|
|
2951
|
+
}
|
|
2952
|
+
this.modifiedClientAttributes = true;
|
|
2953
|
+
},
|
|
2954
|
+
|
|
2955
|
+
// Renderers
|
|
2956
|
+
addRendererComponent: function(name, size, type) {
|
|
2957
|
+
if (!this.rendererComponents[name]) {
|
|
2958
|
+
this.rendererComponents[name] = 1;
|
|
2959
|
+
#if ASSERTIONS
|
|
2960
|
+
if (this.enabledClientAttributes[name]) {
|
|
2961
|
+
console.log("Warning: glTexCoord used after EnableClientState for TEXTURE_COORD_ARRAY for TEXTURE0. Disabling TEXTURE_COORD_ARRAY...");
|
|
2962
|
+
}
|
|
2963
|
+
#endif
|
|
2964
|
+
this.enabledClientAttributes[name] = true;
|
|
2965
|
+
this.setClientAttribute(name, size, type, 0, this.rendererComponentPointer);
|
|
2966
|
+
this.rendererComponentPointer += size * GL.byteSizeByType[type - GL.byteSizeByTypeRoot];
|
|
2967
|
+
} else {
|
|
2968
|
+
this.rendererComponents[name]++;
|
|
2969
|
+
}
|
|
2970
|
+
},
|
|
2971
|
+
|
|
2972
|
+
disableBeginEndClientAttributes: function() {
|
|
2973
|
+
for (var i = 0; i < this.NUM_ATTRIBUTES; i++) {
|
|
2974
|
+
if (this.rendererComponents[i]) this.enabledClientAttributes[i] = false;
|
|
2975
|
+
}
|
|
2976
|
+
},
|
|
2977
|
+
|
|
2978
|
+
getRenderer: function() {
|
|
2979
|
+
// return a renderer object given the liveClientAttributes
|
|
2980
|
+
// we maintain a cache of renderers, optimized to not generate garbage
|
|
2981
|
+
var attributes = GL.immediate.liveClientAttributes;
|
|
2982
|
+
var cacheMap = GL.immediate.rendererCache;
|
|
2983
|
+
var temp;
|
|
2984
|
+
var keyView = cacheMap.getStaticKeyView().reset();
|
|
2985
|
+
|
|
2986
|
+
// By attrib state:
|
|
2987
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
2988
|
+
var attribute = attributes[i];
|
|
2989
|
+
keyView.next(attribute.name).next(attribute.size).next(attribute.type);
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
// By fog state:
|
|
2993
|
+
var fogParam = 0;
|
|
2994
|
+
if (GLEmulation.fogEnabled) {
|
|
2995
|
+
switch (GLEmulation.fogMode) {
|
|
2996
|
+
case 0x0801: // GL_EXP2
|
|
2997
|
+
fogParam = 1;
|
|
2998
|
+
break;
|
|
2999
|
+
case 0x2601: // GL_LINEAR
|
|
3000
|
+
fogParam = 2;
|
|
3001
|
+
break;
|
|
3002
|
+
default: // default to GL_EXP
|
|
3003
|
+
fogParam = 3;
|
|
3004
|
+
break;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
keyView.next(fogParam);
|
|
3008
|
+
|
|
3009
|
+
// By cur program:
|
|
3010
|
+
keyView.next(GL.currProgram);
|
|
3011
|
+
if (!GL.currProgram) {
|
|
3012
|
+
GL.immediate.TexEnvJIT.traverseState(keyView);
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
// If we don't already have it, create it.
|
|
3016
|
+
if (!keyView.get()) {
|
|
3017
|
+
#if GL_DEBUG
|
|
3018
|
+
Module.printErr('generating renderer for ' + JSON.stringify(attributes));
|
|
3019
|
+
#endif
|
|
3020
|
+
keyView.set(this.createRenderer());
|
|
3021
|
+
}
|
|
3022
|
+
return keyView.get();
|
|
3023
|
+
},
|
|
3024
|
+
|
|
3025
|
+
createRenderer: function(renderer) {
|
|
3026
|
+
var useCurrProgram = !!GL.currProgram;
|
|
3027
|
+
var hasTextures = false, textureSizes = [], textureTypes = [];
|
|
3028
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
3029
|
+
var texAttribName = GL.immediate.TEXTURE0 + i;
|
|
3030
|
+
if (!GL.immediate.enabledClientAttributes[texAttribName])
|
|
3031
|
+
continue;
|
|
3032
|
+
|
|
3033
|
+
if (!useCurrProgram) {
|
|
3034
|
+
assert(GL.immediate.TexEnvJIT.getTexUnitType(i) != 0, "GL_TEXTURE" + i + " coords are supplied, but that texture unit is disabled in the fixed-function pipeline.");
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
textureSizes[i] = GL.immediate.clientAttributes[texAttribName].size;
|
|
3038
|
+
textureTypes[i] = GL.immediate.clientAttributes[texAttribName].type;
|
|
3039
|
+
hasTextures = true;
|
|
3040
|
+
}
|
|
3041
|
+
var positionSize = GL.immediate.clientAttributes[GL.immediate.VERTEX].size;
|
|
3042
|
+
var positionType = GL.immediate.clientAttributes[GL.immediate.VERTEX].type;
|
|
3043
|
+
var colorSize = 0, colorType;
|
|
3044
|
+
if (GL.immediate.enabledClientAttributes[GL.immediate.COLOR]) {
|
|
3045
|
+
colorSize = GL.immediate.clientAttributes[GL.immediate.COLOR].size;
|
|
3046
|
+
colorType = GL.immediate.clientAttributes[GL.immediate.COLOR].type;
|
|
3047
|
+
}
|
|
3048
|
+
var normalSize = 0, normalType;
|
|
3049
|
+
if (GL.immediate.enabledClientAttributes[GL.immediate.NORMAL]) {
|
|
3050
|
+
normalSize = GL.immediate.clientAttributes[GL.immediate.NORMAL].size;
|
|
3051
|
+
normalType = GL.immediate.clientAttributes[GL.immediate.NORMAL].type;
|
|
3052
|
+
}
|
|
3053
|
+
var ret = {
|
|
3054
|
+
init: function() {
|
|
3055
|
+
// For fixed-function shader generation.
|
|
3056
|
+
var uTexUnitPrefix = 'u_texUnit';
|
|
3057
|
+
var aTexCoordPrefix = 'a_texCoord';
|
|
3058
|
+
var vTexCoordPrefix = 'v_texCoord';
|
|
3059
|
+
var vPrimColor = 'v_color';
|
|
3060
|
+
var uTexMatrixPrefix = GL.immediate.useTextureMatrix ? 'u_textureMatrix' : null;
|
|
3061
|
+
|
|
3062
|
+
if (useCurrProgram) {
|
|
3063
|
+
if (GL.shaderInfos[GL.programShaders[GL.currProgram][0]].type == Module.ctx.VERTEX_SHADER) {
|
|
3064
|
+
this.vertexShader = GL.shaders[GL.programShaders[GL.currProgram][0]];
|
|
3065
|
+
this.fragmentShader = GL.shaders[GL.programShaders[GL.currProgram][1]];
|
|
3066
|
+
} else {
|
|
3067
|
+
this.vertexShader = GL.shaders[GL.programShaders[GL.currProgram][1]];
|
|
3068
|
+
this.fragmentShader = GL.shaders[GL.programShaders[GL.currProgram][0]];
|
|
3069
|
+
}
|
|
3070
|
+
this.program = GL.programs[GL.currProgram];
|
|
3071
|
+
this.usedTexUnitList = [];
|
|
3072
|
+
} else {
|
|
3073
|
+
// IMPORTANT NOTE: If you parameterize the shader source based on any runtime values
|
|
3074
|
+
// in order to create the least expensive shader possible based on the features being
|
|
3075
|
+
// used, you should also update the code in the beginning of getRenderer to make sure
|
|
3076
|
+
// that you cache the renderer based on the said parameters.
|
|
3077
|
+
if (GLEmulation.fogEnabled) {
|
|
3078
|
+
switch (GLEmulation.fogMode) {
|
|
3079
|
+
case 0x0801: // GL_EXP2
|
|
3080
|
+
// fog = exp(-(gl_Fog.density * gl_FogFragCoord)^2)
|
|
3081
|
+
var fogFormula = ' float fog = exp(-u_fogDensity * u_fogDensity * ecDistance * ecDistance); \n';
|
|
3082
|
+
break;
|
|
3083
|
+
case 0x2601: // GL_LINEAR
|
|
3084
|
+
// fog = (gl_Fog.end - gl_FogFragCoord) * gl_fog.scale
|
|
3085
|
+
var fogFormula = ' float fog = (u_fogEnd - ecDistance) * u_fogScale; \n';
|
|
3086
|
+
break;
|
|
3087
|
+
default: // default to GL_EXP
|
|
3088
|
+
// fog = exp(-gl_Fog.density * gl_FogFragCoord)
|
|
3089
|
+
var fogFormula = ' float fog = exp(-u_fogDensity * ecDistance); \n';
|
|
3090
|
+
break;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
GL.immediate.TexEnvJIT.setGLSLVars(uTexUnitPrefix, vTexCoordPrefix, vPrimColor, uTexMatrixPrefix);
|
|
3095
|
+
var fsTexEnvPass = GL.immediate.TexEnvJIT.genAllPassLines('gl_FragColor', 2);
|
|
3096
|
+
|
|
3097
|
+
var texUnitAttribList = '';
|
|
3098
|
+
var texUnitVaryingList = '';
|
|
3099
|
+
var texUnitUniformList = '';
|
|
3100
|
+
var vsTexCoordInits = '';
|
|
3101
|
+
this.usedTexUnitList = GL.immediate.TexEnvJIT.getUsedTexUnitList();
|
|
3102
|
+
for (var i = 0; i < this.usedTexUnitList.length; i++) {
|
|
3103
|
+
var texUnit = this.usedTexUnitList[i];
|
|
3104
|
+
texUnitAttribList += 'attribute vec4 ' + aTexCoordPrefix + texUnit + ';\n';
|
|
3105
|
+
texUnitVaryingList += 'varying vec4 ' + vTexCoordPrefix + texUnit + ';\n';
|
|
3106
|
+
texUnitUniformList += 'uniform sampler2D ' + uTexUnitPrefix + texUnit + ';\n';
|
|
3107
|
+
vsTexCoordInits += ' ' + vTexCoordPrefix + texUnit + ' = ' + aTexCoordPrefix + texUnit + ';\n';
|
|
3108
|
+
|
|
3109
|
+
if (GL.immediate.useTextureMatrix) {
|
|
3110
|
+
texUnitUniformList += 'uniform mat4 ' + uTexMatrixPrefix + texUnit + ';\n';
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
var vsFogVaryingInit = null;
|
|
3115
|
+
if (GLEmulation.fogEnabled) {
|
|
3116
|
+
vsFogVaryingInit = ' v_fogFragCoord = abs(ecPosition.z);\n';
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
var vsSource = [
|
|
3120
|
+
'attribute vec4 a_position;',
|
|
3121
|
+
'attribute vec4 a_color;',
|
|
3122
|
+
'varying vec4 v_color;',
|
|
3123
|
+
texUnitAttribList,
|
|
3124
|
+
texUnitVaryingList,
|
|
3125
|
+
(GLEmulation.fogEnabled ? 'varying float v_fogFragCoord;' : null),
|
|
3126
|
+
'uniform mat4 u_modelView;',
|
|
3127
|
+
'uniform mat4 u_projection;',
|
|
3128
|
+
'void main()',
|
|
3129
|
+
'{',
|
|
3130
|
+
' vec4 ecPosition = u_modelView * a_position;', // eye-coordinate position
|
|
3131
|
+
' gl_Position = u_projection * ecPosition;',
|
|
3132
|
+
' v_color = a_color;',
|
|
3133
|
+
vsTexCoordInits,
|
|
3134
|
+
vsFogVaryingInit,
|
|
3135
|
+
'}',
|
|
3136
|
+
''
|
|
3137
|
+
].join('\n').replace(/\n\n+/g, '\n');
|
|
3138
|
+
|
|
3139
|
+
this.vertexShader = Module.ctx.createShader(Module.ctx.VERTEX_SHADER);
|
|
3140
|
+
Module.ctx.shaderSource(this.vertexShader, vsSource);
|
|
3141
|
+
Module.ctx.compileShader(this.vertexShader);
|
|
3142
|
+
|
|
3143
|
+
var fogHeaderIfNeeded = null;
|
|
3144
|
+
if (GLEmulation.fogEnabled) {
|
|
3145
|
+
fogHeaderIfNeeded = [
|
|
3146
|
+
'',
|
|
3147
|
+
'varying float v_fogFragCoord; ',
|
|
3148
|
+
'uniform vec4 u_fogColor; ',
|
|
3149
|
+
'uniform float u_fogEnd; ',
|
|
3150
|
+
'uniform float u_fogScale; ',
|
|
3151
|
+
'uniform float u_fogDensity; ',
|
|
3152
|
+
'float ffog(in float ecDistance) { ',
|
|
3153
|
+
fogFormula,
|
|
3154
|
+
' fog = clamp(fog, 0.0, 1.0); ',
|
|
3155
|
+
' return fog; ',
|
|
3156
|
+
'}',
|
|
3157
|
+
'',
|
|
3158
|
+
].join("\n");
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
var fogPass = null;
|
|
3162
|
+
if (GLEmulation.fogEnabled) {
|
|
3163
|
+
fogPass = 'gl_FragColor = vec4(mix(u_fogColor.rgb, gl_FragColor.rgb, ffog(v_fogFragCoord)), gl_FragColor.a);\n';
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
var fsSource = [
|
|
3167
|
+
'precision mediump float;',
|
|
3168
|
+
texUnitVaryingList,
|
|
3169
|
+
texUnitUniformList,
|
|
3170
|
+
'varying vec4 v_color;',
|
|
3171
|
+
fogHeaderIfNeeded,
|
|
3172
|
+
'void main()',
|
|
3173
|
+
'{',
|
|
3174
|
+
fsTexEnvPass,
|
|
3175
|
+
fogPass,
|
|
3176
|
+
'}',
|
|
3177
|
+
''
|
|
3178
|
+
].join("\n").replace(/\n\n+/g, '\n');
|
|
3179
|
+
|
|
3180
|
+
this.fragmentShader = Module.ctx.createShader(Module.ctx.FRAGMENT_SHADER);
|
|
3181
|
+
Module.ctx.shaderSource(this.fragmentShader, fsSource);
|
|
3182
|
+
Module.ctx.compileShader(this.fragmentShader);
|
|
3183
|
+
|
|
3184
|
+
this.program = Module.ctx.createProgram();
|
|
3185
|
+
Module.ctx.attachShader(this.program, this.vertexShader);
|
|
3186
|
+
Module.ctx.attachShader(this.program, this.fragmentShader);
|
|
3187
|
+
Module.ctx.bindAttribLocation(this.program, 0, 'a_position');
|
|
3188
|
+
Module.ctx.linkProgram(this.program);
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
this.positionLocation = Module.ctx.getAttribLocation(this.program, 'a_position');
|
|
3192
|
+
|
|
3193
|
+
this.texCoordLocations = [];
|
|
3194
|
+
|
|
3195
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
3196
|
+
if (!GL.immediate.enabledClientAttributes[GL.immediate.TEXTURE0 + i]) {
|
|
3197
|
+
this.texCoordLocations[i] = -1;
|
|
3198
|
+
continue;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
if (useCurrProgram) {
|
|
3202
|
+
this.texCoordLocations[i] = Module.ctx.getAttribLocation(this.program, 'a_texCoord' + i);
|
|
3203
|
+
} else {
|
|
3204
|
+
this.texCoordLocations[i] = Module.ctx.getAttribLocation(this.program, aTexCoordPrefix + i);
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
if (!useCurrProgram) {
|
|
3209
|
+
// Temporarily switch to the program so we can set our sampler uniforms early.
|
|
3210
|
+
var prevBoundProg = Module.ctx.getParameter(Module.ctx.CURRENT_PROGRAM);
|
|
3211
|
+
Module.ctx.useProgram(this.program);
|
|
3212
|
+
{
|
|
3213
|
+
for (var i = 0; i < this.usedTexUnitList.length; i++) {
|
|
3214
|
+
var texUnitID = this.usedTexUnitList[i];
|
|
3215
|
+
var texSamplerLoc = Module.ctx.getUniformLocation(this.program, uTexUnitPrefix + texUnitID);
|
|
3216
|
+
Module.ctx.uniform1i(texSamplerLoc, texUnitID);
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
Module.ctx.useProgram(prevBoundProg);
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
this.textureMatrixLocations = [];
|
|
3223
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
3224
|
+
this.textureMatrixLocations[i] = Module.ctx.getUniformLocation(this.program, 'u_textureMatrix' + i);
|
|
3225
|
+
}
|
|
3226
|
+
this.colorLocation = Module.ctx.getAttribLocation(this.program, 'a_color');
|
|
3227
|
+
this.normalLocation = Module.ctx.getAttribLocation(this.program, 'a_normal');
|
|
3228
|
+
|
|
3229
|
+
this.modelViewLocation = Module.ctx.getUniformLocation(this.program, 'u_modelView');
|
|
3230
|
+
this.projectionLocation = Module.ctx.getUniformLocation(this.program, 'u_projection');
|
|
3231
|
+
|
|
3232
|
+
this.hasTextures = hasTextures;
|
|
3233
|
+
this.hasNormal = normalSize > 0 && this.normalLocation >= 0;
|
|
3234
|
+
this.hasColor = (this.colorLocation === 0) || this.colorLocation > 0;
|
|
3235
|
+
|
|
3236
|
+
this.floatType = Module.ctx.FLOAT; // minor optimization
|
|
3237
|
+
|
|
3238
|
+
this.fogColorLocation = Module.ctx.getUniformLocation(this.program, 'u_fogColor');
|
|
3239
|
+
this.fogEndLocation = Module.ctx.getUniformLocation(this.program, 'u_fogEnd');
|
|
3240
|
+
this.fogScaleLocation = Module.ctx.getUniformLocation(this.program, 'u_fogScale');
|
|
3241
|
+
this.fogDensityLocation = Module.ctx.getUniformLocation(this.program, 'u_fogDensity');
|
|
3242
|
+
this.hasFog = !!(this.fogColorLocation || this.fogEndLocation ||
|
|
3243
|
+
this.fogScaleLocation || this.fogDensityLocation);
|
|
3244
|
+
},
|
|
3245
|
+
|
|
3246
|
+
prepare: function() {
|
|
3247
|
+
// Calculate the array buffer
|
|
3248
|
+
var arrayBuffer;
|
|
3249
|
+
if (!GL.currArrayBuffer) {
|
|
3250
|
+
var start = GL.immediate.firstVertex*GL.immediate.stride;
|
|
3251
|
+
var end = GL.immediate.lastVertex*GL.immediate.stride;
|
|
3252
|
+
assert(end <= GL.MAX_TEMP_BUFFER_SIZE, 'too much vertex data');
|
|
3253
|
+
arrayBuffer = GL.tempVertexBuffers[GL.tempBufferIndexLookup[end]];
|
|
3254
|
+
// TODO: consider using the last buffer we bound, if it was larger. downside is larger buffer, but we might avoid rebinding and preparing
|
|
3255
|
+
} else {
|
|
3256
|
+
arrayBuffer = GL.currArrayBuffer;
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
// If the array buffer is unchanged and the renderer as well, then we can avoid all the work here
|
|
3260
|
+
// XXX We use some heuristics here, and this may not work in all cases. Try disabling GL_UNSAFE_OPTS if you
|
|
3261
|
+
// have odd glitches
|
|
3262
|
+
#if GL_UNSAFE_OPTS
|
|
3263
|
+
var lastRenderer = GL.immediate.lastRenderer;
|
|
3264
|
+
var canSkip = this == lastRenderer &&
|
|
3265
|
+
arrayBuffer == GL.immediate.lastArrayBuffer &&
|
|
3266
|
+
(GL.currProgram || this.program) == GL.immediate.lastProgram &&
|
|
3267
|
+
GL.immediate.stride == GL.immediate.lastStride &&
|
|
3268
|
+
!GL.immediate.matricesModified;
|
|
3269
|
+
if (!canSkip && lastRenderer) lastRenderer.cleanup();
|
|
3270
|
+
#endif
|
|
3271
|
+
if (!GL.currArrayBuffer) {
|
|
3272
|
+
// Bind the array buffer and upload data after cleaning up the previous renderer
|
|
3273
|
+
#if GL_UNSAFE_OPTS
|
|
3274
|
+
// Potentially unsafe, since lastArrayBuffer might not reflect the true array buffer in code that mixes immediate/non-immediate
|
|
3275
|
+
if (arrayBuffer != GL.immediate.lastArrayBuffer) {
|
|
3276
|
+
#endif
|
|
3277
|
+
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, arrayBuffer);
|
|
3278
|
+
#if GL_UNSAFE_OPTS
|
|
3279
|
+
}
|
|
3280
|
+
#endif
|
|
3281
|
+
Module.ctx.bufferSubData(Module.ctx.ARRAY_BUFFER, start, GL.immediate.vertexData.subarray(start >> 2, end >> 2));
|
|
3282
|
+
}
|
|
3283
|
+
#if GL_UNSAFE_OPTS
|
|
3284
|
+
if (canSkip) return;
|
|
3285
|
+
GL.immediate.lastRenderer = this;
|
|
3286
|
+
GL.immediate.lastArrayBuffer = arrayBuffer;
|
|
3287
|
+
GL.immediate.lastProgram = GL.currProgram || this.program;
|
|
3288
|
+
GL.immediate.lastStride == GL.immediate.stride;
|
|
3289
|
+
GL.immediate.matricesModified = false;
|
|
3290
|
+
#endif
|
|
3291
|
+
|
|
3292
|
+
if (!GL.currProgram) {
|
|
3293
|
+
Module.ctx.useProgram(this.program);
|
|
3294
|
+
GL.immediate.fixedFunctionProgram = this.program;
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
if (this.modelViewLocation) Module.ctx.uniformMatrix4fv(this.modelViewLocation, false, GL.immediate.matrix['m']);
|
|
3298
|
+
if (this.projectionLocation) Module.ctx.uniformMatrix4fv(this.projectionLocation, false, GL.immediate.matrix['p']);
|
|
3299
|
+
|
|
3300
|
+
var clientAttributes = GL.immediate.clientAttributes;
|
|
3301
|
+
|
|
3302
|
+
Module.ctx.vertexAttribPointer(this.positionLocation, positionSize, positionType, false,
|
|
3303
|
+
GL.immediate.stride, clientAttributes[GL.immediate.VERTEX].offset);
|
|
3304
|
+
Module.ctx.enableVertexAttribArray(this.positionLocation);
|
|
3305
|
+
if (this.hasTextures) {
|
|
3306
|
+
//for (var i = 0; i < this.usedTexUnitList.length; i++) {
|
|
3307
|
+
// var texUnitID = this.usedTexUnitList[i];
|
|
3308
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
3309
|
+
var texUnitID = i;
|
|
3310
|
+
var attribLoc = this.texCoordLocations[texUnitID];
|
|
3311
|
+
if (attribLoc === undefined || attribLoc < 0) continue;
|
|
3312
|
+
|
|
3313
|
+
if (texUnitID < textureSizes.length && textureSizes[texUnitID]) {
|
|
3314
|
+
Module.ctx.vertexAttribPointer(attribLoc, textureSizes[texUnitID], textureTypes[texUnitID], false,
|
|
3315
|
+
GL.immediate.stride, GL.immediate.clientAttributes[GL.immediate.TEXTURE0 + texUnitID].offset);
|
|
3316
|
+
Module.ctx.enableVertexAttribArray(attribLoc);
|
|
3317
|
+
} else {
|
|
3318
|
+
// These two might be dangerous, but let's try them.
|
|
3319
|
+
Module.ctx.vertexAttrib4f(attribLoc, 0, 0, 0, 1);
|
|
3320
|
+
Module.ctx.disableVertexAttribArray(attribLoc);
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
3324
|
+
if (this.textureMatrixLocations[i]) { // XXX might we need this even without the condition we are currently in?
|
|
3325
|
+
Module.ctx.uniformMatrix4fv(this.textureMatrixLocations[i], false, GL.immediate.matrix['t' + i]);
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
if (colorSize) {
|
|
3330
|
+
Module.ctx.vertexAttribPointer(this.colorLocation, colorSize, colorType, true,
|
|
3331
|
+
GL.immediate.stride, clientAttributes[GL.immediate.COLOR].offset);
|
|
3332
|
+
Module.ctx.enableVertexAttribArray(this.colorLocation);
|
|
3333
|
+
} else if (this.hasColor) {
|
|
3334
|
+
Module.ctx.disableVertexAttribArray(this.colorLocation);
|
|
3335
|
+
Module.ctx.vertexAttrib4fv(this.colorLocation, GL.immediate.clientColor);
|
|
3336
|
+
}
|
|
3337
|
+
if (this.hasNormal) {
|
|
3338
|
+
Module.ctx.vertexAttribPointer(this.normalLocation, normalSize, normalType, true,
|
|
3339
|
+
GL.immediate.stride, clientAttributes[GL.immediate.NORMAL].offset);
|
|
3340
|
+
Module.ctx.enableVertexAttribArray(this.normalLocation);
|
|
3341
|
+
}
|
|
3342
|
+
if (this.hasFog) {
|
|
3343
|
+
if (this.fogColorLocation) Module.ctx.uniform4fv(this.fogColorLocation, GLEmulation.fogColor);
|
|
3344
|
+
if (this.fogEndLocation) Module.ctx.uniform1f(this.fogEndLocation, GLEmulation.fogEnd);
|
|
3345
|
+
if (this.fogScaleLocation) Module.ctx.uniform1f(this.fogScaleLocation, 1/(GLEmulation.fogEnd - GLEmulation.fogStart));
|
|
3346
|
+
if (this.fogDensityLocation) Module.ctx.uniform1f(this.fogDensityLocation, GLEmulation.fogDensity);
|
|
3347
|
+
}
|
|
3348
|
+
},
|
|
3349
|
+
|
|
3350
|
+
cleanup: function() {
|
|
3351
|
+
Module.ctx.disableVertexAttribArray(this.positionLocation);
|
|
3352
|
+
if (this.hasTextures) {
|
|
3353
|
+
for (var i = 0; i < textureSizes.length; i++) {
|
|
3354
|
+
if (textureSizes[i] && this.texCoordLocations[i] >= 0) {
|
|
3355
|
+
Module.ctx.disableVertexAttribArray(this.texCoordLocations[i]);
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
if (this.hasColor) {
|
|
3360
|
+
Module.ctx.disableVertexAttribArray(this.colorLocation);
|
|
3361
|
+
}
|
|
3362
|
+
if (this.hasNormal) {
|
|
3363
|
+
Module.ctx.disableVertexAttribArray(this.normalLocation);
|
|
3364
|
+
}
|
|
3365
|
+
if (!GL.currProgram) {
|
|
3366
|
+
Module.ctx.useProgram(null);
|
|
3367
|
+
}
|
|
3368
|
+
if (!GL.currArrayBuffer) {
|
|
3369
|
+
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, null);
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
#if GL_UNSAFE_OPTS
|
|
3373
|
+
GL.immediate.lastRenderer = null;
|
|
3374
|
+
GL.immediate.lastArrayBuffer = null;
|
|
3375
|
+
GL.immediate.lastProgram = null;
|
|
3376
|
+
#endif
|
|
3377
|
+
GL.immediate.matricesModified = true;
|
|
3378
|
+
}
|
|
3379
|
+
};
|
|
3380
|
+
ret.init();
|
|
3381
|
+
return ret;
|
|
3382
|
+
},
|
|
3383
|
+
|
|
3384
|
+
setupFuncs: function() {
|
|
3385
|
+
// Replace some functions with immediate-mode aware versions. If there are no client
|
|
3386
|
+
// attributes enabled, and we use webgl-friendly modes (no GL_QUADS), then no need
|
|
3387
|
+
// for emulation
|
|
3388
|
+
_glDrawArrays = function(mode, first, count) {
|
|
3389
|
+
if (GL.immediate.totalEnabledClientAttributes == 0 && mode <= 6) {
|
|
3390
|
+
Module.ctx.drawArrays(mode, first, count);
|
|
3391
|
+
return;
|
|
3392
|
+
}
|
|
3393
|
+
GL.immediate.prepareClientAttributes(count, false);
|
|
3394
|
+
GL.immediate.mode = mode;
|
|
3395
|
+
if (!GL.currArrayBuffer) {
|
|
3396
|
+
GL.immediate.vertexData = {{{ makeHEAPView('F32', 'GL.immediate.vertexPointer', 'GL.immediate.vertexPointer + (first+count)*GL.immediate.stride') }}}; // XXX assuming float
|
|
3397
|
+
GL.immediate.firstVertex = first;
|
|
3398
|
+
GL.immediate.lastVertex = first + count;
|
|
3399
|
+
}
|
|
3400
|
+
GL.immediate.flush(null, first);
|
|
3401
|
+
GL.immediate.mode = -1;
|
|
3402
|
+
};
|
|
3403
|
+
|
|
3404
|
+
_glDrawElements = function(mode, count, type, indices, start, end) { // start, end are given if we come from glDrawRangeElements
|
|
3405
|
+
if (GL.immediate.totalEnabledClientAttributes == 0 && mode <= 6 && GL.currElementArrayBuffer) {
|
|
3406
|
+
Module.ctx.drawElements(mode, count, type, indices);
|
|
3407
|
+
return;
|
|
3408
|
+
}
|
|
3409
|
+
if (!GL.currElementArrayBuffer) {
|
|
3410
|
+
assert(type == Module.ctx.UNSIGNED_SHORT); // We can only emulate buffers of this kind, for now
|
|
3411
|
+
}
|
|
3412
|
+
#if ASSERTIONS
|
|
3413
|
+
console.log("DrawElements doesn't actually prepareClientAttributes properly.");
|
|
3414
|
+
#endif
|
|
3415
|
+
GL.immediate.prepareClientAttributes(count, false);
|
|
3416
|
+
GL.immediate.mode = mode;
|
|
3417
|
+
if (!GL.currArrayBuffer) {
|
|
3418
|
+
GL.immediate.firstVertex = end ? start : TOTAL_MEMORY; // if we don't know the start, set an invalid value and we will calculate it later from the indices
|
|
3419
|
+
GL.immediate.lastVertex = end ? end+1 : 0;
|
|
3420
|
+
GL.immediate.vertexData = {{{ makeHEAPView('F32', 'GL.immediate.vertexPointer', '(end ? GL.immediate.vertexPointer + (end+1)*GL.immediate.stride : TOTAL_MEMORY)') }}}; // XXX assuming float
|
|
3421
|
+
}
|
|
3422
|
+
GL.immediate.flush(count, 0, indices);
|
|
3423
|
+
GL.immediate.mode = -1;
|
|
3424
|
+
};
|
|
3425
|
+
|
|
3426
|
+
// TexEnv stuff needs to be prepared early, so do it here.
|
|
3427
|
+
// init() is too late for -O2, since it freezes the GL functions
|
|
3428
|
+
// by that point.
|
|
3429
|
+
GL.immediate.MapTreeLib = GL.immediate.spawnMapTreeLib();
|
|
3430
|
+
GL.immediate.spawnMapTreeLib = null;
|
|
3431
|
+
|
|
3432
|
+
GL.immediate.TexEnvJIT = GL.immediate.spawnTexEnvJIT();
|
|
3433
|
+
GL.immediate.spawnTexEnvJIT = null;
|
|
3434
|
+
|
|
3435
|
+
GL.immediate.setupHooks();
|
|
3436
|
+
},
|
|
3437
|
+
|
|
3438
|
+
setupHooks: function() {
|
|
3439
|
+
if (!GLEmulation.hasRunInit) {
|
|
3440
|
+
GLEmulation.init();
|
|
3441
|
+
}
|
|
3442
|
+
|
|
3443
|
+
var glActiveTexture = _glActiveTexture;
|
|
3444
|
+
_glActiveTexture = function(texture) {
|
|
3445
|
+
GL.immediate.TexEnvJIT.hook_activeTexture(texture);
|
|
3446
|
+
glActiveTexture(texture);
|
|
3447
|
+
};
|
|
3448
|
+
|
|
3449
|
+
var glEnable = _glEnable;
|
|
3450
|
+
_glEnable = function(cap) {
|
|
3451
|
+
GL.immediate.TexEnvJIT.hook_enable(cap);
|
|
3452
|
+
glEnable(cap);
|
|
3453
|
+
};
|
|
3454
|
+
var glDisable = _glDisable;
|
|
3455
|
+
_glDisable = function(cap) {
|
|
3456
|
+
GL.immediate.TexEnvJIT.hook_disable(cap);
|
|
3457
|
+
glDisable(cap);
|
|
3458
|
+
};
|
|
3459
|
+
|
|
3460
|
+
var glTexEnvf = (typeof(_glTexEnvf) != 'undefined') ? _glTexEnvf : function(){};
|
|
3461
|
+
_glTexEnvf = function(target, pname, param) {
|
|
3462
|
+
GL.immediate.TexEnvJIT.hook_texEnvf(target, pname, param);
|
|
3463
|
+
// Don't call old func, since we are the implementor.
|
|
3464
|
+
//glTexEnvf(target, pname, param);
|
|
3465
|
+
};
|
|
3466
|
+
var glTexEnvi = (typeof(_glTexEnvi) != 'undefined') ? _glTexEnvi : function(){};
|
|
3467
|
+
_glTexEnvi = function(target, pname, param) {
|
|
3468
|
+
GL.immediate.TexEnvJIT.hook_texEnvi(target, pname, param);
|
|
3469
|
+
// Don't call old func, since we are the implementor.
|
|
3470
|
+
//glTexEnvi(target, pname, param);
|
|
3471
|
+
};
|
|
3472
|
+
var glTexEnvfv = (typeof(_glTexEnvfv) != 'undefined') ? _glTexEnvfv : function(){};
|
|
3473
|
+
_glTexEnvfv = function(target, pname, param) {
|
|
3474
|
+
GL.immediate.TexEnvJIT.hook_texEnvfv(target, pname, param);
|
|
3475
|
+
// Don't call old func, since we are the implementor.
|
|
3476
|
+
//glTexEnvfv(target, pname, param);
|
|
3477
|
+
};
|
|
3478
|
+
|
|
3479
|
+
var glGetIntegerv = _glGetIntegerv;
|
|
3480
|
+
_glGetIntegerv = function(pname, params) {
|
|
3481
|
+
switch (pname) {
|
|
3482
|
+
case 0x8B8D: { // GL_CURRENT_PROGRAM
|
|
3483
|
+
// Just query directly so we're working with WebGL objects.
|
|
3484
|
+
var cur = Module.ctx.getParameter(Module.ctx.CURRENT_PROGRAM);
|
|
3485
|
+
if (cur == GL.immediate.fixedFunctionProgram) {
|
|
3486
|
+
// Pretend we're not using a program.
|
|
3487
|
+
{{{ makeSetValue('params', '0', '0', 'i32') }}};
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
break;
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
glGetIntegerv(pname, params);
|
|
3494
|
+
};
|
|
3495
|
+
},
|
|
3496
|
+
|
|
3497
|
+
// Main functions
|
|
3498
|
+
initted: false,
|
|
3499
|
+
init: function() {
|
|
3500
|
+
Module.printErr('WARNING: using emscripten GL immediate mode emulation. This is very limited in what it supports');
|
|
3501
|
+
GL.immediate.initted = true;
|
|
3502
|
+
|
|
3503
|
+
if (!Module.useWebGL) return; // a 2D canvas may be currently used TODO: make sure we are actually called in that case
|
|
3504
|
+
|
|
3505
|
+
this.TexEnvJIT.init(Module.ctx);
|
|
3506
|
+
|
|
3507
|
+
GL.immediate.MAX_TEXTURES = Module.ctx.getParameter(Module.ctx.MAX_TEXTURE_IMAGE_UNITS);
|
|
3508
|
+
GL.immediate.NUM_ATTRIBUTES = GL.immediate.TEXTURE0 + GL.immediate.MAX_TEXTURES;
|
|
3509
|
+
GL.immediate.clientAttributes = [];
|
|
3510
|
+
for (var i = 0; i < GL.immediate.NUM_ATTRIBUTES; i++) {
|
|
3511
|
+
GL.immediate.clientAttributes.push({});
|
|
3512
|
+
}
|
|
3513
|
+
|
|
3514
|
+
this.matrixStack['m'] = [];
|
|
3515
|
+
this.matrixStack['p'] = [];
|
|
3516
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
3517
|
+
this.matrixStack['t' + i] = [];
|
|
3518
|
+
}
|
|
3519
|
+
|
|
3520
|
+
// Initialize matrix library
|
|
3521
|
+
|
|
3522
|
+
GL.immediate.matrix['m'] = GL.immediate.matrix.lib.mat4.create();
|
|
3523
|
+
GL.immediate.matrix.lib.mat4.identity(GL.immediate.matrix['m']);
|
|
3524
|
+
GL.immediate.matrix['p'] = GL.immediate.matrix.lib.mat4.create();
|
|
3525
|
+
GL.immediate.matrix.lib.mat4.identity(GL.immediate.matrix['p']);
|
|
3526
|
+
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
|
|
3527
|
+
GL.immediate.matrix['t' + i] = GL.immediate.matrix.lib.mat4.create();
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
// Renderer cache
|
|
3531
|
+
this.rendererCache = this.MapTreeLib.create();
|
|
3532
|
+
|
|
3533
|
+
// Buffers for data
|
|
3534
|
+
this.tempData = new Float32Array(GL.MAX_TEMP_BUFFER_SIZE >> 2);
|
|
3535
|
+
this.indexData = new Uint16Array(GL.MAX_TEMP_BUFFER_SIZE >> 1);
|
|
3536
|
+
|
|
3537
|
+
this.vertexDataU8 = new Uint8Array(this.tempData.buffer);
|
|
3538
|
+
|
|
3539
|
+
GL.generateTempBuffers(true);
|
|
3540
|
+
|
|
3541
|
+
this.clientColor = new Float32Array([1, 1, 1, 1]);
|
|
3542
|
+
},
|
|
3543
|
+
|
|
3544
|
+
// Prepares and analyzes client attributes.
|
|
3545
|
+
// Modifies liveClientAttributes, stride, vertexPointer, vertexCounter
|
|
3546
|
+
// count: number of elements we will draw
|
|
3547
|
+
// beginEnd: whether we are drawing the results of a begin/end block
|
|
3548
|
+
prepareClientAttributes: function(count, beginEnd) {
|
|
3549
|
+
// If no client attributes were modified since we were last called, do nothing. Note that this
|
|
3550
|
+
// does not work for glBegin/End, where we generate renderer components dynamically and then
|
|
3551
|
+
// disable them ourselves, but it does help with glDrawElements/Arrays.
|
|
3552
|
+
if (!this.modifiedClientAttributes) {
|
|
3553
|
+
return;
|
|
3554
|
+
}
|
|
3555
|
+
this.modifiedClientAttributes = false;
|
|
3556
|
+
|
|
3557
|
+
var stride = 0, start;
|
|
3558
|
+
var attributes = GL.immediate.liveClientAttributes;
|
|
3559
|
+
attributes.length = 0;
|
|
3560
|
+
for (var i = 0; i < GL.immediate.NUM_ATTRIBUTES; i++) {
|
|
3561
|
+
if (GL.immediate.enabledClientAttributes[i]) attributes.push(GL.immediate.clientAttributes[i]);
|
|
3562
|
+
}
|
|
3563
|
+
attributes.sort(function(x, y) { return !x ? (!y ? 0 : 1) : (!y ? -1 : (x.pointer - y.pointer)) });
|
|
3564
|
+
start = GL.currArrayBuffer ? 0 : attributes[0].pointer;
|
|
3565
|
+
var multiStrides = false;
|
|
3566
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
3567
|
+
var attribute = attributes[i];
|
|
3568
|
+
if (!attribute) break;
|
|
3569
|
+
if (stride != 0 && stride != attribute.stride) multiStrides = true;
|
|
3570
|
+
if (attribute.stride) stride = attribute.stride;
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
if (multiStrides) stride = 0; // we will need to restride
|
|
3574
|
+
var bytes = 0; // total size in bytes
|
|
3575
|
+
if (!stride && !beginEnd) {
|
|
3576
|
+
// beginEnd can not have stride in the attributes, that is fine. otherwise,
|
|
3577
|
+
// no stride means that all attributes are in fact packed. to keep the rest of
|
|
3578
|
+
// our emulation code simple, we perform unpacking/restriding here. this adds overhead, so
|
|
3579
|
+
// it is a good idea to not hit this!
|
|
3580
|
+
#if ASSERTIONS
|
|
3581
|
+
Runtime.warnOnce('Unpacking/restriding attributes, this is slow and dangerous');
|
|
3582
|
+
#endif
|
|
3583
|
+
if (!GL.immediate.restrideBuffer) GL.immediate.restrideBuffer = _malloc(GL.MAX_TEMP_BUFFER_SIZE);
|
|
3584
|
+
start = GL.immediate.restrideBuffer;
|
|
3585
|
+
#if ASSERTIONS
|
|
3586
|
+
assert(start % 4 == 0);
|
|
3587
|
+
#endif
|
|
3588
|
+
// calculate restrided offsets and total size
|
|
3589
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
3590
|
+
var attribute = attributes[i];
|
|
3591
|
+
if (!attribute) break;
|
|
3592
|
+
var size = attribute.size * GL.byteSizeByType[attribute.type - GL.byteSizeByTypeRoot];
|
|
3593
|
+
if (size % 4 != 0) size += 4 - (size % 4); // align everything
|
|
3594
|
+
attribute.offset = bytes;
|
|
3595
|
+
bytes += size;
|
|
3596
|
+
}
|
|
3597
|
+
#if ASSERTIONS
|
|
3598
|
+
assert(count*bytes <= GL.MAX_TEMP_BUFFER_SIZE);
|
|
3599
|
+
#endif
|
|
3600
|
+
// copy out the data (we need to know the stride for that, and define attribute.pointer
|
|
3601
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
3602
|
+
var attribute = attributes[i];
|
|
3603
|
+
if (!attribute) break;
|
|
3604
|
+
var size4 = Math.floor((attribute.size * GL.byteSizeByType[attribute.type - GL.byteSizeByTypeRoot])/4);
|
|
3605
|
+
for (var j = 0; j < count; j++) {
|
|
3606
|
+
for (var k = 0; k < size4; k++) { // copy in chunks of 4 bytes, our alignment makes this possible
|
|
3607
|
+
HEAP32[((start + attribute.offset + bytes*j)>>2) + k] = HEAP32[(attribute.pointer>>2) + j*size4 + k];
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
attribute.pointer = start + attribute.offset;
|
|
3611
|
+
}
|
|
3612
|
+
} else {
|
|
3613
|
+
// normal situation, everything is strided and in the same buffer
|
|
3614
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
3615
|
+
var attribute = attributes[i];
|
|
3616
|
+
if (!attribute) break;
|
|
3617
|
+
attribute.offset = attribute.pointer - start;
|
|
3618
|
+
if (attribute.offset > bytes) { // ensure we start where we should
|
|
3619
|
+
assert((attribute.offset - bytes)%4 == 0); // XXX assuming 4-alignment
|
|
3620
|
+
bytes += attribute.offset - bytes;
|
|
3621
|
+
}
|
|
3622
|
+
bytes += attribute.size * GL.byteSizeByType[attribute.type - GL.byteSizeByTypeRoot];
|
|
3623
|
+
if (bytes % 4 != 0) bytes += 4 - (bytes % 4); // XXX assuming 4-alignment
|
|
3624
|
+
}
|
|
3625
|
+
assert(beginEnd || bytes <= stride); // if not begin-end, explicit stride should make sense with total byte size
|
|
3626
|
+
if (bytes < stride) { // ensure the size is that of the stride
|
|
3627
|
+
bytes = stride;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
GL.immediate.stride = bytes;
|
|
3631
|
+
|
|
3632
|
+
if (!beginEnd) {
|
|
3633
|
+
bytes *= count;
|
|
3634
|
+
if (!GL.currArrayBuffer) {
|
|
3635
|
+
GL.immediate.vertexPointer = start;
|
|
3636
|
+
}
|
|
3637
|
+
GL.immediate.vertexCounter = bytes / 4; // XXX assuming float
|
|
3638
|
+
}
|
|
3639
|
+
},
|
|
3640
|
+
|
|
3641
|
+
flush: function(numProvidedIndexes, startIndex, ptr) {
|
|
3642
|
+
#if ASSERTIONS
|
|
3643
|
+
assert(numProvidedIndexes >= 0 || !numProvidedIndexes);
|
|
3644
|
+
#endif
|
|
3645
|
+
startIndex = startIndex || 0;
|
|
3646
|
+
ptr = ptr || 0;
|
|
3647
|
+
|
|
3648
|
+
var renderer = this.getRenderer();
|
|
3649
|
+
|
|
3650
|
+
// Generate index data in a format suitable for GLES 2.0/WebGL
|
|
3651
|
+
var numVertexes = 4 * this.vertexCounter / GL.immediate.stride;
|
|
3652
|
+
assert(numVertexes % 1 == 0, "`numVertexes` must be an integer.");
|
|
3653
|
+
|
|
3654
|
+
var emulatedElementArrayBuffer = false;
|
|
3655
|
+
var numIndexes = 0;
|
|
3656
|
+
if (numProvidedIndexes) {
|
|
3657
|
+
numIndexes = numProvidedIndexes;
|
|
3658
|
+
if (!GL.currArrayBuffer && GL.immediate.firstVertex > GL.immediate.lastVertex) {
|
|
3659
|
+
// Figure out the first and last vertex from the index data
|
|
3660
|
+
assert(!GL.currElementArrayBuffer); // If we are going to upload array buffer data, we need to find which range to
|
|
3661
|
+
// upload based on the indices. If they are in a buffer on the GPU, that is very
|
|
3662
|
+
// inconvenient! So if you do not have an array buffer, you should also not have
|
|
3663
|
+
// an element array buffer. But best is to use both buffers!
|
|
3664
|
+
for (var i = 0; i < numProvidedIndexes; i++) {
|
|
3665
|
+
var currIndex = {{{ makeGetValue('ptr', 'i*2', 'i16', null, 1) }}};
|
|
3666
|
+
GL.immediate.firstVertex = Math.min(GL.immediate.firstVertex, currIndex);
|
|
3667
|
+
GL.immediate.lastVertex = Math.max(GL.immediate.lastVertex, currIndex+1);
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
if (!GL.currElementArrayBuffer) {
|
|
3671
|
+
// If no element array buffer is bound, then indices is a literal pointer to clientside data
|
|
3672
|
+
assert(numProvidedIndexes << 1 <= GL.MAX_TEMP_BUFFER_SIZE, 'too many immediate mode indexes (a)');
|
|
3673
|
+
var indexBuffer = GL.tempIndexBuffers[GL.tempBufferIndexLookup[numProvidedIndexes << 1]];
|
|
3674
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
3675
|
+
Module.ctx.bufferSubData(Module.ctx.ELEMENT_ARRAY_BUFFER, 0, {{{ makeHEAPView('U16', 'ptr', 'ptr + (numProvidedIndexes << 1)') }}});
|
|
3676
|
+
ptr = 0;
|
|
3677
|
+
emulatedElementArrayBuffer = true;
|
|
3678
|
+
}
|
|
3679
|
+
} else if (GL.immediate.mode > 6) { // above GL_TRIANGLE_FAN are the non-GL ES modes
|
|
3680
|
+
if (GL.immediate.mode != 7) throw 'unsupported immediate mode ' + GL.immediate.mode; // GL_QUADS
|
|
3681
|
+
// GL.immediate.firstVertex is the first vertex we want. Quad indexes are in the pattern
|
|
3682
|
+
// 0 1 2, 0 2 3, 4 5 6, 4 6 7, so we need to look at index firstVertex * 1.5 to see it.
|
|
3683
|
+
// Then since indexes are 2 bytes each, that means 3
|
|
3684
|
+
assert(GL.immediate.firstVertex % 4 == 0);
|
|
3685
|
+
ptr = GL.immediate.firstVertex*3;
|
|
3686
|
+
var numQuads = numVertexes / 4;
|
|
3687
|
+
numIndexes = numQuads * 6; // 0 1 2, 0 2 3 pattern
|
|
3688
|
+
assert(ptr + (numIndexes << 1) <= GL.MAX_TEMP_BUFFER_SIZE, 'too many immediate mode indexes (b)');
|
|
3689
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, GL.tempQuadIndexBuffer);
|
|
3690
|
+
emulatedElementArrayBuffer = true;
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
renderer.prepare();
|
|
3694
|
+
|
|
3695
|
+
if (numIndexes) {
|
|
3696
|
+
Module.ctx.drawElements(Module.ctx.TRIANGLES, numIndexes, Module.ctx.UNSIGNED_SHORT, ptr);
|
|
3697
|
+
} else {
|
|
3698
|
+
Module.ctx.drawArrays(GL.immediate.mode, startIndex, numVertexes);
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
if (emulatedElementArrayBuffer) {
|
|
3702
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, GL.buffers[GL.currElementArrayBuffer] || null);
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
#if GL_UNSAFE_OPTS == 0
|
|
3706
|
+
renderer.cleanup();
|
|
3707
|
+
#endif
|
|
3708
|
+
}
|
|
3709
|
+
},
|
|
3710
|
+
|
|
3711
|
+
$GLImmediateSetup__deps: ['$GLImmediate', function() { return 'GL.immediate = GLImmediate; GL.immediate.matrix.lib = ' + read('gl-matrix.js') + ';\n' }],
|
|
3712
|
+
$GLImmediateSetup: {},
|
|
3713
|
+
|
|
3714
|
+
glBegin__deps: ['$GLImmediateSetup'],
|
|
3715
|
+
glBegin: function(mode) {
|
|
3716
|
+
// Push the old state:
|
|
3717
|
+
GL.immediate.enabledClientAttributes_preBegin = GL.immediate.enabledClientAttributes;
|
|
3718
|
+
GL.immediate.enabledClientAttributes = [];
|
|
3719
|
+
|
|
3720
|
+
GL.immediate.clientAttributes_preBegin = GL.immediate.clientAttributes;
|
|
3721
|
+
GL.immediate.clientAttributes = []
|
|
3722
|
+
for (var i = 0; i < GL.immediate.clientAttributes_preBegin.length; i++) {
|
|
3723
|
+
GL.immediate.clientAttributes.push({});
|
|
3724
|
+
}
|
|
3725
|
+
|
|
3726
|
+
GL.immediate.mode = mode;
|
|
3727
|
+
GL.immediate.vertexCounter = 0;
|
|
3728
|
+
var components = GL.immediate.rendererComponents = [];
|
|
3729
|
+
for (var i = 0; i < GL.immediate.NUM_ATTRIBUTES; i++) {
|
|
3730
|
+
components[i] = 0;
|
|
3731
|
+
}
|
|
3732
|
+
GL.immediate.rendererComponentPointer = 0;
|
|
3733
|
+
GL.immediate.vertexData = GL.immediate.tempData;
|
|
3734
|
+
},
|
|
3735
|
+
|
|
3736
|
+
glEnd: function() {
|
|
3737
|
+
GL.immediate.prepareClientAttributes(GL.immediate.rendererComponents[GL.immediate.VERTEX], true);
|
|
3738
|
+
GL.immediate.firstVertex = 0;
|
|
3739
|
+
GL.immediate.lastVertex = GL.immediate.vertexCounter / (GL.immediate.stride >> 2);
|
|
3740
|
+
GL.immediate.flush();
|
|
3741
|
+
GL.immediate.disableBeginEndClientAttributes();
|
|
3742
|
+
GL.immediate.mode = -1;
|
|
3743
|
+
|
|
3744
|
+
// Pop the old state:
|
|
3745
|
+
GL.immediate.enabledClientAttributes = GL.immediate.enabledClientAttributes_preBegin;
|
|
3746
|
+
GL.immediate.clientAttributes = GL.immediate.clientAttributes_preBegin;
|
|
3747
|
+
|
|
3748
|
+
GL.immediate.modifiedClientAttributes = true;
|
|
3749
|
+
},
|
|
3750
|
+
|
|
3751
|
+
glVertex3f: function(x, y, z) {
|
|
3752
|
+
#if ASSERTIONS
|
|
3753
|
+
assert(GL.immediate.mode >= 0); // must be in begin/end
|
|
3754
|
+
#endif
|
|
3755
|
+
GL.immediate.vertexData[GL.immediate.vertexCounter++] = x;
|
|
3756
|
+
GL.immediate.vertexData[GL.immediate.vertexCounter++] = y;
|
|
3757
|
+
GL.immediate.vertexData[GL.immediate.vertexCounter++] = z || 0;
|
|
3758
|
+
#if ASSERTIONS
|
|
3759
|
+
assert(GL.immediate.vertexCounter << 2 < GL.MAX_TEMP_BUFFER_SIZE);
|
|
3760
|
+
#endif
|
|
3761
|
+
GL.immediate.addRendererComponent(GL.immediate.VERTEX, 3, Module.ctx.FLOAT);
|
|
3762
|
+
},
|
|
3763
|
+
glVertex2f: 'glVertex3f',
|
|
3764
|
+
|
|
3765
|
+
glVertex3fv__deps: ['glVertex3f'],
|
|
3766
|
+
glVertex3fv: function(p) {
|
|
3767
|
+
_glVertex3f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, {{{ makeGetValue('p', '8', 'float') }}});
|
|
3768
|
+
},
|
|
3769
|
+
glVertex2fv__deps: ['glVertex3f'],
|
|
3770
|
+
glVertex2fv: function(p) {
|
|
3771
|
+
_glVertex3f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, 0);
|
|
3772
|
+
},
|
|
3773
|
+
|
|
3774
|
+
glVertex3i: 'glVertex3f',
|
|
3775
|
+
|
|
3776
|
+
glVertex2i: 'glVertex3f',
|
|
3777
|
+
|
|
3778
|
+
glTexCoord2i: function(u, v) {
|
|
3779
|
+
#if ASSERTIONS
|
|
3780
|
+
assert(GL.immediate.mode >= 0); // must be in begin/end
|
|
3781
|
+
#endif
|
|
3782
|
+
GL.immediate.vertexData[GL.immediate.vertexCounter++] = u;
|
|
3783
|
+
GL.immediate.vertexData[GL.immediate.vertexCounter++] = v;
|
|
3784
|
+
GL.immediate.addRendererComponent(GL.immediate.TEXTURE0, 2, Module.ctx.FLOAT);
|
|
3785
|
+
},
|
|
3786
|
+
glTexCoord2f: 'glTexCoord2i',
|
|
3787
|
+
|
|
3788
|
+
glTexCoord2fv__deps: ['glTexCoord2i'],
|
|
3789
|
+
glTexCoord2fv: function(v) {
|
|
3790
|
+
_glTexCoord2i({{{ makeGetValue('v', '0', 'float') }}}, {{{ makeGetValue('v', '4', 'float') }}});
|
|
3791
|
+
},
|
|
3792
|
+
|
|
3793
|
+
glTexCoord4f: function() { throw 'glTexCoord4f: TODO' },
|
|
3794
|
+
|
|
3795
|
+
glColor4f: function(r, g, b, a) {
|
|
3796
|
+
r = Math.max(Math.min(r, 1), 0);
|
|
3797
|
+
g = Math.max(Math.min(g, 1), 0);
|
|
3798
|
+
b = Math.max(Math.min(b, 1), 0);
|
|
3799
|
+
a = Math.max(Math.min(a, 1), 0);
|
|
3800
|
+
|
|
3801
|
+
// TODO: make ub the default, not f, save a few mathops
|
|
3802
|
+
if (GL.immediate.mode >= 0) {
|
|
3803
|
+
var start = GL.immediate.vertexCounter << 2;
|
|
3804
|
+
GL.immediate.vertexDataU8[start + 0] = r * 255;
|
|
3805
|
+
GL.immediate.vertexDataU8[start + 1] = g * 255;
|
|
3806
|
+
GL.immediate.vertexDataU8[start + 2] = b * 255;
|
|
3807
|
+
GL.immediate.vertexDataU8[start + 3] = a * 255;
|
|
3808
|
+
GL.immediate.vertexCounter++;
|
|
3809
|
+
GL.immediate.addRendererComponent(GL.immediate.COLOR, 4, Module.ctx.UNSIGNED_BYTE);
|
|
3810
|
+
} else {
|
|
3811
|
+
GL.immediate.clientColor[0] = r;
|
|
3812
|
+
GL.immediate.clientColor[1] = g;
|
|
3813
|
+
GL.immediate.clientColor[2] = b;
|
|
3814
|
+
GL.immediate.clientColor[3] = a;
|
|
3815
|
+
}
|
|
3816
|
+
},
|
|
3817
|
+
glColor4d: 'glColor4f',
|
|
3818
|
+
glColor4ub__deps: ['glColor4f'],
|
|
3819
|
+
glColor4ub: function(r, g, b, a) {
|
|
3820
|
+
_glColor4f((r&255)/255, (g&255)/255, (b&255)/255, (a&255)/255);
|
|
3821
|
+
},
|
|
3822
|
+
glColor4us__deps: ['glColor4f'],
|
|
3823
|
+
glColor4us: function(r, g, b, a) {
|
|
3824
|
+
_glColor4f((r&65535)/65535, (g&65535)/65535, (b&65535)/65535, (a&65535)/65535);
|
|
3825
|
+
},
|
|
3826
|
+
glColor4ui__deps: ['glColor4f'],
|
|
3827
|
+
glColor4ui: function(r, g, b, a) {
|
|
3828
|
+
_glColor4f((r>>>0)/4294967295, (g>>>0)/4294967295, (b>>>0)/4294967295, (a>>>0)/4294967295);
|
|
3829
|
+
},
|
|
3830
|
+
glColor3f__deps: ['glColor4f'],
|
|
3831
|
+
glColor3f: function(r, g, b) {
|
|
3832
|
+
_glColor4f(r, g, b, 1);
|
|
3833
|
+
},
|
|
3834
|
+
glColor3d: 'glColor3f',
|
|
3835
|
+
glColor3ub__deps: ['glColor4ub'],
|
|
3836
|
+
glColor3ub: function(r, g, b) {
|
|
3837
|
+
_glColor4ub(r, g, b, 255);
|
|
3838
|
+
},
|
|
3839
|
+
glColor3us__deps: ['glColor4us'],
|
|
3840
|
+
glColor3us: function(r, g, b) {
|
|
3841
|
+
_glColor4us(r, g, b, 65535);
|
|
3842
|
+
},
|
|
3843
|
+
glColor3ui__deps: ['glColor4ui'],
|
|
3844
|
+
glColor3ui: function(r, g, b) {
|
|
3845
|
+
_glColor4ui(r, g, b, 4294967295);
|
|
3846
|
+
},
|
|
3847
|
+
|
|
3848
|
+
glColor3ubv__deps: ['glColor3ub'],
|
|
3849
|
+
glColor3ubv: function(p) {
|
|
3850
|
+
_glColor3ub({{{ makeGetValue('p', '0', 'i8') }}}, {{{ makeGetValue('p', '1', 'i8') }}}, {{{ makeGetValue('p', '2', 'i8') }}});
|
|
3851
|
+
},
|
|
3852
|
+
glColor3usv__deps: ['glColor3us'],
|
|
3853
|
+
glColor3usv: function(p) {
|
|
3854
|
+
_glColor3us({{{ makeGetValue('p', '0', 'i16') }}}, {{{ makeGetValue('p', '2', 'i16') }}}, {{{ makeGetValue('p', '4', 'i16') }}});
|
|
3855
|
+
},
|
|
3856
|
+
glColor3uiv__deps: ['glColor3ui'],
|
|
3857
|
+
glColor3uiv: function(p) {
|
|
3858
|
+
_glColor3ui({{{ makeGetValue('p', '0', 'i32') }}}, {{{ makeGetValue('p', '4', 'i32') }}}, {{{ makeGetValue('p', '8', 'i32') }}});
|
|
3859
|
+
},
|
|
3860
|
+
glColor3fv__deps: ['glColor3f'],
|
|
3861
|
+
glColor3fv: function(p) {
|
|
3862
|
+
_glColor3f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, {{{ makeGetValue('p', '8', 'float') }}});
|
|
3863
|
+
},
|
|
3864
|
+
glColor4fv__deps: ['glColor4f'],
|
|
3865
|
+
glColor4fv: function(p) {
|
|
3866
|
+
_glColor4f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, {{{ makeGetValue('p', '8', 'float') }}}, {{{ makeGetValue('p', '12', 'float') }}});
|
|
3867
|
+
},
|
|
3868
|
+
|
|
3869
|
+
glColor4ubv: function() { throw 'glColor4ubv not implemented' },
|
|
3870
|
+
|
|
3871
|
+
glFogf: function(pname, param) { // partial support, TODO
|
|
3872
|
+
switch(pname) {
|
|
3873
|
+
case 0x0B63: // GL_FOG_START
|
|
3874
|
+
GLEmulation.fogStart = param; break;
|
|
3875
|
+
case 0x0B64: // GL_FOG_END
|
|
3876
|
+
GLEmulation.fogEnd = param; break;
|
|
3877
|
+
case 0x0B62: // GL_FOG_DENSITY
|
|
3878
|
+
GLEmulation.fogDensity = param; break;
|
|
3879
|
+
case 0x0B65: // GL_FOG_MODE
|
|
3880
|
+
switch (param) {
|
|
3881
|
+
case 0x0801: // GL_EXP2
|
|
3882
|
+
case 0x2601: // GL_LINEAR
|
|
3883
|
+
GLEmulation.fogMode = param; break;
|
|
3884
|
+
default: // default to GL_EXP
|
|
3885
|
+
GLEmulation.fogMode = 0x0800 /* GL_EXP */; break;
|
|
3886
|
+
}
|
|
3887
|
+
break;
|
|
3888
|
+
}
|
|
3889
|
+
},
|
|
3890
|
+
glFogi__deps: ['glFogf'],
|
|
3891
|
+
glFogi: function(pname, param) {
|
|
3892
|
+
return _glFogf(pname, param);
|
|
3893
|
+
},
|
|
3894
|
+
glFogfv__deps: ['glFogf'],
|
|
3895
|
+
glFogfv: function(pname, param) { // partial support, TODO
|
|
3896
|
+
switch(pname) {
|
|
3897
|
+
case 0x0B66: // GL_FOG_COLOR
|
|
3898
|
+
GLEmulation.fogColor[0] = {{{ makeGetValue('param', '0', 'float') }}};
|
|
3899
|
+
GLEmulation.fogColor[1] = {{{ makeGetValue('param', '4', 'float') }}};
|
|
3900
|
+
GLEmulation.fogColor[2] = {{{ makeGetValue('param', '8', 'float') }}};
|
|
3901
|
+
GLEmulation.fogColor[3] = {{{ makeGetValue('param', '12', 'float') }}};
|
|
3902
|
+
break;
|
|
3903
|
+
case 0x0B63: // GL_FOG_START
|
|
3904
|
+
case 0x0B64: // GL_FOG_END
|
|
3905
|
+
_glFogf(pname, {{{ makeGetValue('param', '0', 'float') }}}); break;
|
|
3906
|
+
}
|
|
3907
|
+
},
|
|
3908
|
+
glFogiv__deps: ['glFogf'],
|
|
3909
|
+
glFogiv: function(pname, param) {
|
|
3910
|
+
switch(pname) {
|
|
3911
|
+
case 0x0B66: // GL_FOG_COLOR
|
|
3912
|
+
GLEmulation.fogColor[0] = ({{{ makeGetValue('param', '0', 'i32') }}}/2147483647)/2.0+0.5;
|
|
3913
|
+
GLEmulation.fogColor[1] = ({{{ makeGetValue('param', '4', 'i32') }}}/2147483647)/2.0+0.5;
|
|
3914
|
+
GLEmulation.fogColor[2] = ({{{ makeGetValue('param', '8', 'i32') }}}/2147483647)/2.0+0.5;
|
|
3915
|
+
GLEmulation.fogColor[3] = ({{{ makeGetValue('param', '12', 'i32') }}}/2147483647)/2.0+0.5;
|
|
3916
|
+
break;
|
|
3917
|
+
default:
|
|
3918
|
+
_glFogf(pname, {{{ makeGetValue('param', '0', 'i32') }}}); break;
|
|
3919
|
+
}
|
|
3920
|
+
},
|
|
3921
|
+
glFogx: 'glFogi',
|
|
3922
|
+
glFogxv: 'glFogiv',
|
|
3923
|
+
|
|
3924
|
+
glPolygonMode: function(){}, // TODO
|
|
3925
|
+
|
|
3926
|
+
glAlphaFunc: function(){}, // TODO
|
|
3927
|
+
|
|
3928
|
+
glNormal3f: function(){}, // TODO
|
|
3929
|
+
|
|
3930
|
+
// Additional non-GLES rendering calls
|
|
3931
|
+
|
|
3932
|
+
glDrawRangeElements__sig: 'viiiiii',
|
|
3933
|
+
glDrawRangeElements: function(mode, start, end, count, type, indices) {
|
|
3934
|
+
_glDrawElements(mode, count, type, indices, start, end);
|
|
3935
|
+
},
|
|
3936
|
+
|
|
3937
|
+
// ClientState/gl*Pointer
|
|
3938
|
+
|
|
3939
|
+
glEnableClientState: function(cap, disable) {
|
|
3940
|
+
var attrib = GLEmulation.getAttributeFromCapability(cap);
|
|
3941
|
+
if (attrib === null) {
|
|
3942
|
+
#if ASSERTIONS
|
|
3943
|
+
Module.printErr('WARNING: unhandled clientstate: ' + cap);
|
|
3944
|
+
#endif
|
|
3945
|
+
return;
|
|
3946
|
+
}
|
|
3947
|
+
if (disable && GL.immediate.enabledClientAttributes[attrib]) {
|
|
3948
|
+
GL.immediate.enabledClientAttributes[attrib] = false;
|
|
3949
|
+
GL.immediate.totalEnabledClientAttributes--;
|
|
3950
|
+
if (GLEmulation.currentVao) delete GLEmulation.currentVao.enabledClientStates[cap];
|
|
3951
|
+
} else if (!disable && !GL.immediate.enabledClientAttributes[attrib]) {
|
|
3952
|
+
GL.immediate.enabledClientAttributes[attrib] = true;
|
|
3953
|
+
GL.immediate.totalEnabledClientAttributes++;
|
|
3954
|
+
if (GLEmulation.currentVao) GLEmulation.currentVao.enabledClientStates[cap] = 1;
|
|
3955
|
+
}
|
|
3956
|
+
GL.immediate.modifiedClientAttributes = true;
|
|
3957
|
+
},
|
|
3958
|
+
glDisableClientState: function(cap) {
|
|
3959
|
+
_glEnableClientState(cap, 1);
|
|
3960
|
+
},
|
|
3961
|
+
|
|
3962
|
+
glVertexPointer__deps: ['$GLEmulation'], // if any pointers are used, glVertexPointer must be, and if it is, then we need emulation
|
|
3963
|
+
glVertexPointer: function(size, type, stride, pointer) {
|
|
3964
|
+
GL.immediate.setClientAttribute(GL.immediate.VERTEX, size, type, stride, pointer);
|
|
3965
|
+
},
|
|
3966
|
+
glTexCoordPointer: function(size, type, stride, pointer) {
|
|
3967
|
+
GL.immediate.setClientAttribute(GL.immediate.TEXTURE0 + GL.immediate.clientActiveTexture, size, type, stride, pointer);
|
|
3968
|
+
},
|
|
3969
|
+
glNormalPointer: function(type, stride, pointer) {
|
|
3970
|
+
GL.immediate.setClientAttribute(GL.immediate.NORMAL, 3, type, stride, pointer);
|
|
3971
|
+
},
|
|
3972
|
+
glColorPointer: function(size, type, stride, pointer) {
|
|
3973
|
+
GL.immediate.setClientAttribute(GL.immediate.COLOR, size, type, stride, pointer);
|
|
3974
|
+
},
|
|
3975
|
+
|
|
3976
|
+
glClientActiveTexture__sig: 'vi',
|
|
3977
|
+
glClientActiveTexture: function(texture) {
|
|
3978
|
+
GL.immediate.clientActiveTexture = texture - 0x84C0; // GL_TEXTURE0
|
|
3979
|
+
},
|
|
3980
|
+
|
|
3981
|
+
// Vertex array object (VAO) support. TODO: when the WebGL extension is popular, use that and remove this code and GL.vaos
|
|
3982
|
+
glGenVertexArrays__deps: ['$GLEmulation'],
|
|
3983
|
+
glGenVertexArrays__sig: 'vii',
|
|
3984
|
+
glGenVertexArrays: function(n, vaos) {
|
|
3985
|
+
for (var i = 0; i < n; i++) {
|
|
3986
|
+
var id = GL.getNewId(GLEmulation.vaos);
|
|
3987
|
+
GLEmulation.vaos[id] = {
|
|
3988
|
+
id: id,
|
|
3989
|
+
arrayBuffer: 0,
|
|
3990
|
+
elementArrayBuffer: 0,
|
|
3991
|
+
enabledVertexAttribArrays: {},
|
|
3992
|
+
vertexAttribPointers: {},
|
|
3993
|
+
enabledClientStates: {},
|
|
3994
|
+
};
|
|
3995
|
+
{{{ makeSetValue('vaos', 'i*4', 'id', 'i32') }}};
|
|
3996
|
+
}
|
|
3997
|
+
},
|
|
3998
|
+
glDeleteVertexArrays__sig: 'vii',
|
|
3999
|
+
glDeleteVertexArrays: function(n, vaos) {
|
|
4000
|
+
for (var i = 0; i < n; i++) {
|
|
4001
|
+
var id = {{{ makeGetValue('vaos', 'i*4', 'i32') }}};
|
|
4002
|
+
GLEmulation.vaos[id] = null;
|
|
4003
|
+
if (GLEmulation.currentVao && GLEmulation.currentVao.id == id) GLEmulation.currentVao = null;
|
|
4004
|
+
}
|
|
4005
|
+
},
|
|
4006
|
+
glBindVertexArray__sig: 'vi',
|
|
4007
|
+
glBindVertexArray: function(vao) {
|
|
4008
|
+
// undo vao-related things, wipe the slate clean, both for vao of 0 or an actual vao
|
|
4009
|
+
GLEmulation.currentVao = null; // make sure the commands we run here are not recorded
|
|
4010
|
+
if (GL.immediate.lastRenderer) GL.immediate.lastRenderer.cleanup();
|
|
4011
|
+
_glBindBuffer(Module.ctx.ARRAY_BUFFER, 0); // XXX if one was there before we were bound?
|
|
4012
|
+
_glBindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, 0);
|
|
4013
|
+
for (var vaa in GLEmulation.enabledVertexAttribArrays) {
|
|
4014
|
+
Module.ctx.disableVertexAttribArray(vaa);
|
|
4015
|
+
}
|
|
4016
|
+
GLEmulation.enabledVertexAttribArrays = {};
|
|
4017
|
+
GL.immediate.enabledClientAttributes = [0, 0];
|
|
4018
|
+
GL.immediate.totalEnabledClientAttributes = 0;
|
|
4019
|
+
GL.immediate.modifiedClientAttributes = true;
|
|
4020
|
+
if (vao) {
|
|
4021
|
+
// replay vao
|
|
4022
|
+
var info = GLEmulation.vaos[vao];
|
|
4023
|
+
_glBindBuffer(Module.ctx.ARRAY_BUFFER, info.arrayBuffer); // XXX overwrite current binding?
|
|
4024
|
+
_glBindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, info.elementArrayBuffer);
|
|
4025
|
+
for (var vaa in info.enabledVertexAttribArrays) {
|
|
4026
|
+
_glEnableVertexAttribArray(vaa);
|
|
4027
|
+
}
|
|
4028
|
+
for (var vaa in info.vertexAttribPointers) {
|
|
4029
|
+
_glVertexAttribPointer.apply(null, info.vertexAttribPointers[vaa]);
|
|
4030
|
+
}
|
|
4031
|
+
for (var attrib in info.enabledClientStates) {
|
|
4032
|
+
_glEnableClientState(attrib|0);
|
|
4033
|
+
}
|
|
4034
|
+
GLEmulation.currentVao = info; // set currentVao last, so the commands we ran here were not recorded
|
|
4035
|
+
}
|
|
4036
|
+
},
|
|
4037
|
+
|
|
4038
|
+
// OpenGL Immediate Mode matrix routines.
|
|
4039
|
+
// Note that in the future we might make these available only in certain modes.
|
|
4040
|
+
glMatrixMode__deps: ['$GL', '$GLImmediateSetup', '$GLEmulation'], // emulation is not strictly needed, this is a workaround
|
|
4041
|
+
glMatrixMode: function(mode) {
|
|
4042
|
+
if (mode == 0x1700 /* GL_MODELVIEW */) {
|
|
4043
|
+
GL.immediate.currentMatrix = 'm';
|
|
4044
|
+
} else if (mode == 0x1701 /* GL_PROJECTION */) {
|
|
4045
|
+
GL.immediate.currentMatrix = 'p';
|
|
4046
|
+
} else if (mode == 0x1702) { // GL_TEXTURE
|
|
4047
|
+
GL.immediate.useTextureMatrix = true;
|
|
4048
|
+
GL.immediate.currentMatrix = 't' + GL.immediate.clientActiveTexture;
|
|
4049
|
+
} else {
|
|
4050
|
+
throw "Wrong mode " + mode + " passed to glMatrixMode";
|
|
4051
|
+
}
|
|
4052
|
+
},
|
|
4053
|
+
|
|
4054
|
+
glPushMatrix: function() {
|
|
4055
|
+
GL.immediate.matricesModified = true;
|
|
4056
|
+
GL.immediate.matrixStack[GL.immediate.currentMatrix].push(
|
|
4057
|
+
Array.prototype.slice.call(GL.immediate.matrix[GL.immediate.currentMatrix]));
|
|
4058
|
+
},
|
|
4059
|
+
|
|
4060
|
+
glPopMatrix: function() {
|
|
4061
|
+
GL.immediate.matricesModified = true;
|
|
4062
|
+
GL.immediate.matrix[GL.immediate.currentMatrix] = GL.immediate.matrixStack[GL.immediate.currentMatrix].pop();
|
|
4063
|
+
},
|
|
4064
|
+
|
|
4065
|
+
glLoadIdentity__deps: ['$GL', '$GLImmediateSetup'],
|
|
4066
|
+
glLoadIdentity: function() {
|
|
4067
|
+
GL.immediate.matricesModified = true;
|
|
4068
|
+
GL.immediate.matrix.lib.mat4.identity(GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4069
|
+
},
|
|
4070
|
+
|
|
4071
|
+
glLoadMatrixd: function(matrix) {
|
|
4072
|
+
GL.immediate.matricesModified = true;
|
|
4073
|
+
GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4074
|
+
},
|
|
4075
|
+
|
|
4076
|
+
glLoadMatrixf: function(matrix) {
|
|
4077
|
+
#if GL_DEBUG
|
|
4078
|
+
if (GL.debug) Module.printErr('glLoadMatrixf receiving: ' + Array.prototype.slice.call(HEAPF32.subarray(matrix >> 2, (matrix >> 2) + 16)));
|
|
4079
|
+
#endif
|
|
4080
|
+
GL.immediate.matricesModified = true;
|
|
4081
|
+
GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4082
|
+
},
|
|
4083
|
+
|
|
4084
|
+
glLoadTransposeMatrixd: function(matrix) {
|
|
4085
|
+
GL.immediate.matricesModified = true;
|
|
4086
|
+
GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4087
|
+
GL.immediate.matrix.lib.mat4.transpose(GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4088
|
+
},
|
|
4089
|
+
|
|
4090
|
+
glLoadTransposeMatrixf: function(matrix) {
|
|
4091
|
+
GL.immediate.matricesModified = true;
|
|
4092
|
+
GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4093
|
+
GL.immediate.matrix.lib.mat4.transpose(GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4094
|
+
},
|
|
4095
|
+
|
|
4096
|
+
glMultMatrixd: function(matrix) {
|
|
4097
|
+
GL.immediate.matricesModified = true;
|
|
4098
|
+
GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix],
|
|
4099
|
+
{{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}});
|
|
4100
|
+
},
|
|
4101
|
+
|
|
4102
|
+
glMultMatrixf: function(matrix) {
|
|
4103
|
+
GL.immediate.matricesModified = true;
|
|
4104
|
+
GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix],
|
|
4105
|
+
{{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}});
|
|
4106
|
+
},
|
|
4107
|
+
|
|
4108
|
+
glMultTransposeMatrixd: function(matrix) {
|
|
4109
|
+
GL.immediate.matricesModified = true;
|
|
4110
|
+
var colMajor = GL.immediate.matrix.lib.mat4.create();
|
|
4111
|
+
GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}}, colMajor);
|
|
4112
|
+
GL.immediate.matrix.lib.mat4.transpose(colMajor);
|
|
4113
|
+
GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], colMajor);
|
|
4114
|
+
},
|
|
4115
|
+
|
|
4116
|
+
glMultTransposeMatrixf: function(matrix) {
|
|
4117
|
+
GL.immediate.matricesModified = true;
|
|
4118
|
+
var colMajor = GL.immediate.matrix.lib.mat4.create();
|
|
4119
|
+
GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}}, colMajor);
|
|
4120
|
+
GL.immediate.matrix.lib.mat4.transpose(colMajor);
|
|
4121
|
+
GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], colMajor);
|
|
4122
|
+
},
|
|
4123
|
+
|
|
4124
|
+
glFrustum: function(left, right, bottom, top_, nearVal, farVal) {
|
|
4125
|
+
GL.immediate.matricesModified = true;
|
|
4126
|
+
GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix],
|
|
4127
|
+
GL.immediate.matrix.lib.mat4.frustum(left, right, bottom, top_, nearVal, farVal));
|
|
4128
|
+
},
|
|
4129
|
+
glFrustumf: 'glFrustum',
|
|
4130
|
+
|
|
4131
|
+
glOrtho: function(left, right, bottom, top_, nearVal, farVal) {
|
|
4132
|
+
GL.immediate.matricesModified = true;
|
|
4133
|
+
GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix],
|
|
4134
|
+
GL.immediate.matrix.lib.mat4.ortho(left, right, bottom, top_, nearVal, farVal));
|
|
4135
|
+
},
|
|
4136
|
+
glOrthof: 'glOrtho',
|
|
4137
|
+
|
|
4138
|
+
glScaled: function(x, y, z) {
|
|
4139
|
+
GL.immediate.matricesModified = true;
|
|
4140
|
+
GL.immediate.matrix.lib.mat4.scale(GL.immediate.matrix[GL.immediate.currentMatrix], [x, y, z]);
|
|
4141
|
+
},
|
|
4142
|
+
glScalef: 'glScaled',
|
|
4143
|
+
|
|
4144
|
+
glTranslated: function(x, y, z) {
|
|
4145
|
+
GL.immediate.matricesModified = true;
|
|
4146
|
+
GL.immediate.matrix.lib.mat4.translate(GL.immediate.matrix[GL.immediate.currentMatrix], [x, y, z]);
|
|
4147
|
+
},
|
|
4148
|
+
glTranslatef: 'glTranslated',
|
|
4149
|
+
|
|
4150
|
+
glRotated: function(angle, x, y, z) {
|
|
4151
|
+
GL.immediate.matricesModified = true;
|
|
4152
|
+
GL.immediate.matrix.lib.mat4.rotate(GL.immediate.matrix[GL.immediate.currentMatrix], angle*Math.PI/180, [x, y, z]);
|
|
4153
|
+
},
|
|
4154
|
+
glRotatef: 'glRotated',
|
|
4155
|
+
|
|
4156
|
+
glDrawBuffer: function() { throw 'glDrawBuffer: TODO' },
|
|
4157
|
+
glReadBuffer: function() { throw 'glReadBuffer: TODO' },
|
|
4158
|
+
|
|
4159
|
+
glLightfv: function() { throw 'glLightfv: TODO' },
|
|
4160
|
+
glLightModelfv: function() { throw 'glLightModelfv: TODO' },
|
|
4161
|
+
glMaterialfv: function() { throw 'glMaterialfv: TODO' },
|
|
4162
|
+
|
|
4163
|
+
glTexGeni: function() { throw 'glTexGeni: TODO' },
|
|
4164
|
+
glTexGenfv: function() { throw 'glTexGenfv: TODO' },
|
|
4165
|
+
glTexEnvi: function() { Runtime.warnOnce('glTexEnvi: TODO') },
|
|
4166
|
+
glTexEnvf: function() { Runtime.warnOnce('glTexEnvf: TODO') },
|
|
4167
|
+
glTexEnvfv: function() { Runtime.warnOnce('glTexEnvfv: TODO') },
|
|
4168
|
+
|
|
4169
|
+
glTexImage1D: function() { throw 'glTexImage1D: TODO' },
|
|
4170
|
+
glTexCoord3f: function() { throw 'glTexCoord3f: TODO' },
|
|
4171
|
+
glGetTexLevelParameteriv: function() { throw 'glGetTexLevelParameteriv: TODO' },
|
|
4172
|
+
|
|
4173
|
+
glShadeModel: function() { Runtime.warnOnce('TODO: glShadeModel') },
|
|
4174
|
+
|
|
4175
|
+
// Open GLES1.1 compatibility
|
|
4176
|
+
|
|
4177
|
+
glGenFramebuffersOES : 'glGenFramebuffers',
|
|
4178
|
+
glGenRenderbuffersOES : 'glGenRenderbuffers',
|
|
4179
|
+
glBindFramebufferOES : 'glBindFramebuffer',
|
|
4180
|
+
glBindRenderbufferOES : 'glBindRenderbuffer',
|
|
4181
|
+
glGetRenderbufferParameterivOES : 'glGetRenderbufferParameteriv',
|
|
4182
|
+
glFramebufferRenderbufferOES : 'glFramebufferRenderbuffer',
|
|
4183
|
+
glRenderbufferStorageOES : 'glRenderbufferStorage',
|
|
4184
|
+
glCheckFramebufferStatusOES : 'glCheckFramebufferStatus',
|
|
4185
|
+
glDeleteFramebuffersOES : 'glDeleteFramebuffers',
|
|
4186
|
+
glDeleteRenderbuffersOES : 'glDeleteRenderbuffers',
|
|
4187
|
+
glGenVertexArraysOES: 'glGenVertexArrays',
|
|
4188
|
+
glDeleteVertexArraysOES: 'glDeleteVertexArrays',
|
|
4189
|
+
glBindVertexArrayOES: 'glBindVertexArray',
|
|
4190
|
+
glFramebufferTexture2DOES: 'glFramebufferTexture2D',
|
|
4191
|
+
|
|
4192
|
+
#endif // DISABLE_GL_EMULATION == 0
|
|
4193
|
+
|
|
4194
|
+
// GLU
|
|
4195
|
+
|
|
4196
|
+
gluPerspective: function(fov, aspect, near, far) {
|
|
4197
|
+
GL.immediate.matricesModified = true;
|
|
4198
|
+
GL.immediate.matrix[GL.immediate.currentMatrix] =
|
|
4199
|
+
GL.immediate.matrix.lib.mat4.perspective(fov, aspect, near, far,
|
|
4200
|
+
GL.immediate.matrix[GL.immediate.currentMatrix]);
|
|
4201
|
+
},
|
|
4202
|
+
|
|
4203
|
+
gluLookAt: function(ex, ey, ez, cx, cy, cz, ux, uy, uz) {
|
|
4204
|
+
GL.immediate.matricesModified = true;
|
|
4205
|
+
GL.immediate.matrix.lib.mat4.lookAt(GL.immediate.matrix[GL.immediate.currentMatrix], [ex, ey, ez],
|
|
4206
|
+
[cx, cy, cz], [ux, uy, uz]);
|
|
4207
|
+
},
|
|
4208
|
+
|
|
4209
|
+
gluProject: function(objX, objY, objZ, model, proj, view, winX, winY, winZ) {
|
|
4210
|
+
// The algorithm for this functions comes from Mesa
|
|
4211
|
+
|
|
4212
|
+
var inVec = new Float32Array(4);
|
|
4213
|
+
var outVec = new Float32Array(4);
|
|
4214
|
+
GL.immediate.matrix.lib.mat4.multiplyVec4({{{ makeHEAPView('F64', 'model', 'model+' + (16*8)) }}},
|
|
4215
|
+
[objX, objY, objZ, 1.0], outVec);
|
|
4216
|
+
GL.immediate.matrix.lib.mat4.multiplyVec4({{{ makeHEAPView('F64', 'proj', 'proj+' + (16*8)) }}},
|
|
4217
|
+
outVec, inVec);
|
|
4218
|
+
if (inVec[3] == 0.0) {
|
|
4219
|
+
return 0 /* GL_FALSE */;
|
|
4220
|
+
}
|
|
4221
|
+
inVec[0] /= inVec[3];
|
|
4222
|
+
inVec[1] /= inVec[3];
|
|
4223
|
+
inVec[2] /= inVec[3];
|
|
4224
|
+
// Map x, y and z to range 0-1 */
|
|
4225
|
+
inVec[0] = inVec[0] * 0.5 + 0.5;
|
|
4226
|
+
inVec[1] = inVec[1] * 0.5 + 0.5;
|
|
4227
|
+
inVec[2] = inVec[2] * 0.5 + 0.5;
|
|
4228
|
+
// Map x, y to viewport
|
|
4229
|
+
inVec[0] = inVec[0] * {{{ makeGetValue('view', 2*4, 'i32') }}} + {{{ makeGetValue('view', 0*4, 'i32') }}};
|
|
4230
|
+
inVec[1] = inVec[1] * {{{ makeGetValue('view', 3*4, 'i32') }}} + {{{ makeGetValue('view', 1*4, 'i32') }}};
|
|
4231
|
+
|
|
4232
|
+
{{{ makeSetValue('winX', '0', 'inVec[0]', 'double') }}};
|
|
4233
|
+
{{{ makeSetValue('winY', '0', 'inVec[1]', 'double') }}};
|
|
4234
|
+
{{{ makeSetValue('winZ', '0', 'inVec[2]', 'double') }}};
|
|
4235
|
+
|
|
4236
|
+
return 1 /* GL_TRUE */;
|
|
4237
|
+
},
|
|
4238
|
+
|
|
4239
|
+
gluUnProject: function(winX, winY, winZ, model, proj, view, objX, objY, objZ) {
|
|
4240
|
+
var result = GL.immediate.matrix.lib.mat4.unproject([winX, winY, winZ],
|
|
4241
|
+
{{{ makeHEAPView('F64', 'model', 'model+' + (16*8)) }}},
|
|
4242
|
+
{{{ makeHEAPView('F64', 'proj', 'proj+' + (16*8)) }}},
|
|
4243
|
+
{{{ makeHEAPView('32', 'view', 'view+' + (4*4)) }}});
|
|
4244
|
+
|
|
4245
|
+
if (result === null) {
|
|
4246
|
+
return 0 /* GL_FALSE */;
|
|
4247
|
+
}
|
|
4248
|
+
|
|
4249
|
+
{{{ makeSetValue('objX', '0', 'result[0]', 'double') }}};
|
|
4250
|
+
{{{ makeSetValue('objY', '0', 'result[1]', 'double') }}};
|
|
4251
|
+
{{{ makeSetValue('objZ', '0', 'result[2]', 'double') }}};
|
|
4252
|
+
|
|
4253
|
+
return 1 /* GL_TRUE */;
|
|
4254
|
+
},
|
|
4255
|
+
|
|
4256
|
+
gluOrtho2D: function(left, right, bottom, top) {
|
|
4257
|
+
_glOrtho(left, right, bottom, top, -1, 1);
|
|
4258
|
+
},
|
|
4259
|
+
|
|
4260
|
+
// GLES2 emulation
|
|
4261
|
+
|
|
4262
|
+
glVertexAttribPointer__sig: 'viiiiii',
|
|
4263
|
+
glVertexAttribPointer: function(index, size, type, normalized, stride, ptr) {
|
|
4264
|
+
#if FULL_ES2
|
|
4265
|
+
var cb = GL.clientBuffers[index];
|
|
4266
|
+
#if ASSERTIONS
|
|
4267
|
+
assert(cb, index);
|
|
4268
|
+
#endif
|
|
4269
|
+
if (!GL.currArrayBuffer) {
|
|
4270
|
+
cb.size = size;
|
|
4271
|
+
cb.type = type;
|
|
4272
|
+
cb.normalized = normalized;
|
|
4273
|
+
cb.stride = stride;
|
|
4274
|
+
cb.ptr = ptr;
|
|
4275
|
+
cb.clientside = true;
|
|
4276
|
+
return;
|
|
4277
|
+
}
|
|
4278
|
+
cb.clientside = false;
|
|
4279
|
+
#endif
|
|
4280
|
+
Module.ctx.vertexAttribPointer(index, size, type, normalized, stride, ptr);
|
|
4281
|
+
},
|
|
4282
|
+
|
|
4283
|
+
glEnableVertexAttribArray__sig: 'vi',
|
|
4284
|
+
glEnableVertexAttribArray: function(index) {
|
|
4285
|
+
#if FULL_ES2
|
|
4286
|
+
var cb = GL.clientBuffers[index];
|
|
4287
|
+
#if ASSERTIONS
|
|
4288
|
+
assert(cb, index);
|
|
4289
|
+
#endif
|
|
4290
|
+
cb.enabled = true;
|
|
4291
|
+
#endif
|
|
4292
|
+
Module.ctx.enableVertexAttribArray(index);
|
|
4293
|
+
},
|
|
4294
|
+
|
|
4295
|
+
glDisableVertexAttribArray__sig: 'vi',
|
|
4296
|
+
glDisableVertexAttribArray: function(index) {
|
|
4297
|
+
#if FULL_ES2
|
|
4298
|
+
var cb = GL.clientBuffers[index];
|
|
4299
|
+
#if ASSERTIONS
|
|
4300
|
+
assert(cb, index);
|
|
4301
|
+
#endif
|
|
4302
|
+
cb.enabled = false;
|
|
4303
|
+
#endif
|
|
4304
|
+
Module.ctx.disableVertexAttribArray(index);
|
|
4305
|
+
},
|
|
4306
|
+
|
|
4307
|
+
glDrawArrays__sig: 'viii',
|
|
4308
|
+
glDrawArrays: function(mode, first, count) {
|
|
4309
|
+
#if FULL_ES2
|
|
4310
|
+
// bind any client-side buffers
|
|
4311
|
+
GL.preDrawHandleClientVertexAttribBindings(first + count);
|
|
4312
|
+
#endif
|
|
4313
|
+
|
|
4314
|
+
Module.ctx.drawArrays(mode, first, count);
|
|
4315
|
+
|
|
4316
|
+
#if FULL_ES2
|
|
4317
|
+
GL.postDrawHandleClientVertexAttribBindings();
|
|
4318
|
+
#endif
|
|
4319
|
+
},
|
|
4320
|
+
|
|
4321
|
+
glDrawElements__sig: 'viiii',
|
|
4322
|
+
glDrawElements: function(mode, count, type, indices) {
|
|
4323
|
+
#if FULL_ES2
|
|
4324
|
+
var buf;
|
|
4325
|
+
if (!GL.currElementArrayBuffer) {
|
|
4326
|
+
var size = GL.calcBufLength(1, type, 0, count);
|
|
4327
|
+
buf = GL.tempIndexBuffers[GL.tempBufferIndexLookup[size]];
|
|
4328
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, buf);
|
|
4329
|
+
Module.ctx.bufferSubData(Module.ctx.ELEMENT_ARRAY_BUFFER,
|
|
4330
|
+
0,
|
|
4331
|
+
HEAPU8.subarray(indices, indices + size));
|
|
4332
|
+
// the index is now 0
|
|
4333
|
+
indices = 0;
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
// bind any client-side buffers
|
|
4337
|
+
GL.preDrawHandleClientVertexAttribBindings(count);
|
|
4338
|
+
#endif
|
|
4339
|
+
|
|
4340
|
+
Module.ctx.drawElements(mode, count, type, indices);
|
|
4341
|
+
|
|
4342
|
+
#if FULL_ES2
|
|
4343
|
+
GL.postDrawHandleClientVertexAttribBindings(count);
|
|
4344
|
+
|
|
4345
|
+
if (!GL.currElementArrayBuffer) {
|
|
4346
|
+
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, null);
|
|
4347
|
+
}
|
|
4348
|
+
#endif
|
|
4349
|
+
},
|
|
4350
|
+
|
|
4351
|
+
// signatures of simple pass-through functions, see later
|
|
4352
|
+
|
|
4353
|
+
glActiveTexture__sig: 'vi',
|
|
4354
|
+
glCheckFramebufferStatus__sig: 'ii',
|
|
4355
|
+
glRenderbufferStorage__sig: 'viiii',
|
|
4356
|
+
glClearStencil__sig: 'vi',
|
|
4357
|
+
glStencilFunc__sig: 'viii',
|
|
4358
|
+
glLineWidth__sig: 'vi',
|
|
4359
|
+
glBlendEquation__sig: 'vi',
|
|
4360
|
+
glBlendEquationSeparate__sig: 'vii',
|
|
4361
|
+
glVertexAttrib1f__sig: 'vii',
|
|
4362
|
+
glVertexAttrib2f__sig: 'viii',
|
|
4363
|
+
glVertexAttrib3f__sig: 'viiii',
|
|
4364
|
+
glVertexAttrib4f__sig: 'viiiii',
|
|
4365
|
+
glCullFace__sig: 'vi',
|
|
4366
|
+
glBlendFunc__sig: 'vii',
|
|
4367
|
+
glBlendFuncSeparate__sig: 'viiii',
|
|
4368
|
+
glPolygonOffset__sig: 'vii',
|
|
4369
|
+
glColorMask__sig: 'viiii',
|
|
4370
|
+
glStencilOp__sig: 'viii',
|
|
4371
|
+
glStencilOpSeparate__sig: 'viiii',
|
|
4372
|
+
glGenerateMipmap__sig: 'vi',
|
|
4373
|
+
glHint__sig: 'vii',
|
|
4374
|
+
glDepthMask__sig: 'vi',
|
|
4375
|
+
glViewport__sig: 'viiii',
|
|
4376
|
+
glDepthFunc__sig: 'vi',
|
|
4377
|
+
glStencilMask__sig: 'vi',
|
|
4378
|
+
glStencilMaskSeparate__sig: 'vii',
|
|
4379
|
+
glClearDepthf__sig: 'vi',
|
|
4380
|
+
glFinish__sig: 'v',
|
|
4381
|
+
glFlush__sig: 'v',
|
|
4382
|
+
glClearColor__sig: 'viiii',
|
|
4383
|
+
glIsEnabled__sig: 'ii',
|
|
4384
|
+
glGetError__sig: 'i',
|
|
4385
|
+
glFrontFace__sig: 'vi',
|
|
4386
|
+
glSampleCoverage__sig: 'vi',
|
|
4387
|
+
};
|
|
4388
|
+
|
|
4389
|
+
|
|
4390
|
+
// Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name
|
|
4391
|
+
[[0, 'getError* finish flush'],
|
|
4392
|
+
[1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation sampleCoverage isEnabled*'],
|
|
4393
|
+
[2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f'],
|
|
4394
|
+
[3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'],
|
|
4395
|
+
[4, 'viewport clearColor scissor vertexAttrib3f colorMask renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate'],
|
|
4396
|
+
[5, 'vertexAttrib4f'],
|
|
4397
|
+
[8, 'copyTexImage2D copyTexSubImage2D']].forEach(function(data) {
|
|
4398
|
+
var num = data[0];
|
|
4399
|
+
var names = data[1];
|
|
4400
|
+
var args = range(num).map(function(i) { return 'x' + i }).join(', ');
|
|
4401
|
+
var plainStub = '(function(' + args + ') { Module.ctx.NAME(' + args + ') })';
|
|
4402
|
+
var returnStub = '(function(' + args + ') { return Module.ctx.NAME(' + args + ') })';
|
|
4403
|
+
var sigEnd = range(num).map(function() { return 'i' }).join('');
|
|
4404
|
+
names.split(' ').forEach(function(name) {
|
|
4405
|
+
var stub = plainStub;
|
|
4406
|
+
var sig;
|
|
4407
|
+
if (name[name.length-1] == '*') {
|
|
4408
|
+
name = name.substr(0, name.length-1);
|
|
4409
|
+
stub = returnStub;
|
|
4410
|
+
sig = 'i' + sigEnd;
|
|
4411
|
+
} else {
|
|
4412
|
+
sig = 'v' + sigEnd;
|
|
4413
|
+
}
|
|
4414
|
+
var cName = name;
|
|
4415
|
+
if (name.indexOf('[') >= 0) {
|
|
4416
|
+
cName = name.replace('[', '').replace(']', '');
|
|
4417
|
+
name = cName.substr(0, cName.length-1);
|
|
4418
|
+
}
|
|
4419
|
+
var cName = 'gl' + cName[0].toUpperCase() + cName.substr(1);
|
|
4420
|
+
assert(!(cName in LibraryGL), "Cannot reimplement the existing function " + cName);
|
|
4421
|
+
LibraryGL[cName] = eval(stub.replace('NAME', name));
|
|
4422
|
+
if (!LibraryGL[cName + '__sig']) LibraryGL[cName + '__sig'] = sig;
|
|
4423
|
+
});
|
|
4424
|
+
});
|
|
4425
|
+
|
|
4426
|
+
autoAddDeps(LibraryGL, '$GL');
|
|
4427
|
+
|
|
4428
|
+
if (!DISABLE_GL_EMULATION) {
|
|
4429
|
+
// Emulation requires everything else, potentially
|
|
4430
|
+
LibraryGL.$GLEmulation__deps = LibraryGL.$GLEmulation__deps.slice(0); // the __deps object is shared
|
|
4431
|
+
var glFuncs = [];
|
|
4432
|
+
for (var item in LibraryGL) {
|
|
4433
|
+
if (item != '$GLEmulation' && item.substr(-6) != '__deps' && item.substr(-9) != '__postset' && item.substr(-5) != '__sig' && item.substr(0, 2) == 'gl') {
|
|
4434
|
+
glFuncs.push(item);
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
LibraryGL.$GLEmulation__deps = LibraryGL.$GLEmulation__deps.concat(glFuncs);
|
|
4438
|
+
LibraryGL.$GLEmulation__deps.push(function() {
|
|
4439
|
+
for (var func in Functions.getIndex.tentative) {
|
|
4440
|
+
Functions.getIndex(func);
|
|
4441
|
+
Functions.unimplementedFunctions[func] = LibraryGL[func.substr(1) + '__sig'];
|
|
4442
|
+
}
|
|
4443
|
+
});
|
|
4444
|
+
|
|
4445
|
+
if (FORCE_GL_EMULATION) {
|
|
4446
|
+
LibraryGL.glDrawElements__deps = LibraryGL.glDrawElements__deps.concat('$GLEmulation');
|
|
4447
|
+
LibraryGL.glDrawArrays__deps = LibraryGL.glDrawArrays__deps.concat('$GLEmulation');
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
|
|
4451
|
+
mergeInto(LibraryManager.library, LibraryGL);
|
|
4452
|
+
|