mirror of
https://github.com/BinomialLLC/basis_universal.git
synced 2026-10-14 13:05:30 +00:00
Modularize emscripten build.
By default, emscripten's generated javascript modules lives in the global object "Module'. This makes it impossible to load multiple emscripten modules on the same page. In attempt to avoid namespace collision, this change modularizes the emscripten build so the Module is instead called 'BASIS'. Many target applications for Basis are likely to already be using other emscripten modules. Testing: The existing webgl/(texture|gltf) pages have been updated to use the new name and seem to operate as before
This commit is contained in:
committed by
Preston Tamkin
parent
f3f7c69f28
commit
39b5c5bc42
@@ -15,7 +15,7 @@
|
||||
|
||||
<body>
|
||||
<script>
|
||||
Module.onRuntimeInitialized = () => {
|
||||
BASIS().then(Module => {
|
||||
|
||||
const { BasisFile, initializeBasis } = Module;
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
|
||||
}, false );
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function log(s) {
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ function viewAlpha() { drawMode = 2; redraw(); }
|
||||
<div id='logger'></div>
|
||||
</body>
|
||||
<script>
|
||||
Module.onRuntimeInitialized = () => {
|
||||
BASIS({onRuntimeInitialized : () => {
|
||||
var gl = elem('canvas').getContext('webgl');
|
||||
// Load the DXT extension, and verify it exists.
|
||||
if (!gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc') && !gl.getExtension('WEBGL_compressed_texture_s3tc')) {
|
||||
@@ -275,6 +275,6 @@ function viewAlpha() { drawMode = 2; redraw(); }
|
||||
}, false);
|
||||
|
||||
runLoadFile();
|
||||
}
|
||||
}}).then(module => window.Module = module);
|
||||
</script>
|
||||
</html>
|
||||
|
||||
@@ -17,5 +17,5 @@ if (EMSCRIPTEN)
|
||||
set_target_properties(basis_transcoder.js PROPERTIES
|
||||
OUTPUT_NAME "basis_transcoder"
|
||||
SUFFIX ".js"
|
||||
LINK_FLAGS "--bind -s ALLOW_MEMORY_GROWTH=1 -O3 -s ASSERTIONS=0 -s MALLOC=emmalloc")
|
||||
LINK_FLAGS "--bind -s ALLOW_MEMORY_GROWTH=1 -O3 -s ASSERTIONS=0 -s MALLOC=emmalloc -s MODULARIZE=1 -s EXPORT_NAME=BASIS ")
|
||||
endif()
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user