I think the issue is that Module will not be found until initialization of the runtime is finished. This raises the following question. Will
Module.preinitializedWebGLContext = gl;
in onRuntimeInitialized (before making any Emscripten OpenGL ES calls) work or
do I need so somehow arrange for the JS app’s context creation to complete
together with setting of preinitializedWebGLContext before Emscripten runtime
initialization starts? If so, how do I accomplish that?
Regards
-Mark
> On Jan 5, 2020, at 13:59, キャロウ マーク <[email protected]> wrote:
>
> I am working on a wrapper to provide a JS API for a C++ library and I am
> struggling mightily to get all the pieces in place. I have been completely
> unable find a simple and *complete* working example (.html, .js & .wasm).
> Finding and accessing Module is my current problem. (I feel like a newbie
> having to ask these questions.)
>
> My wrapper code successfully compiles creating a .js and a .wasm file. I have
> an index.html file with
>
> <script src="../mylib.js"></script>
> <script src="webgl-demo.js"></script>
>
> webgl-demo.js creates the canvas and WebGL context the code in mylib.js must
> use.
>
> I first tried in weggl-demo.js just after the context has been created
>
> Module.preinitializedWebGLContext = gl;
>
> which tells me Module is undefined. The comments in the generated mylib.js
> say that a Module will be created if not already defined so why do I get
> “undefined” here? window.Module also gives me undefined. I’m running in a
> browser.
>
> Then I added
>
> <script>
> var Module = {}
> </script>
>
> before the script tag with the link to mylib.js in index.html. It solves the
> undefined but will the setting of preinitializedWebGLContext be too late? The
> value to use will not be known before some part of webgl-demo.js runs. How
> can I initialize Module correctly?
>
> I also need to access the GL object so I can find the WebGLTexture objects
> matching OpenGL ES texture names, so I can from JS create a texture that
> Emscripten’s OpenGL ES emulation will know about. This will be used for
> loading texture data. I am thinking of calling GL._glGenTextures and
> GL._bindTexture then looking in GL.textures to find the matching
> WebGLTexture. Is this viable? Is there a better way?
>
> Will I find the GL object on Module once I successfully get it initialized?
>
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/28D7910D-E5EA-4EC3-B504-0A132DAE7AF2%40callow.im.
signature.asc
Description: Message signed with OpenPGP
