When linking, to prevent Module.GL from disappearing, I use -s EXTRA_EXPORTED_RUNTIME_METHODS=[\'GL\’]"
then in my c++ wrapper code I use
val texture = val::module_property("GL")["textures"][texname];
to get the id for a texture that was created earlier by c code calling OpenGL
ES and therefore the Emscripten wrapper.
Regards
-Mark
> On Aug 26, 2020, at 10:11, Shachar Langbeheim <[email protected]> wrote:
>
> Thank you Sam, that's exactly what I needed.
>
> On Wed, 26 Aug 2020 at 12:47, 'Sam Clegg' via emscripten-discuss
> <[email protected]
> <mailto:[email protected]>> wrote:
>
>
> On Tue, Aug 25, 2020 at 11:41 PM Shachar Langbeheim <[email protected]
> <mailto:[email protected]>> wrote:
> how does EmscriptenExtension.js access objects in Module's closure?
>
> Code that you include via `--pre-js` and `--post-js` lives inside the module
> closure, no? So it should be trivial.
>
>
>
>
> On Wed, 26 Aug 2020 at 09:31, Prashanth Nethi <[email protected]
> <mailto:[email protected]>> wrote:
> Hi,
>
> There was a similar requirement in our app. And this is what I did. Although
> I am not sure if this is the official way or if there are any better way to
> do it.
>
> 1) Added method to Module["getNewId"] = function() {...} to a new JS file
> call it EmscriptenExtension.js
> 2) Link this JS file using em_link_post_js
> 3) This would make getNewId available to the Module object, that you receive
> as an argument, upon instantiating the Wasm.
>
> Hope this helps.
>
>
> On Tuesday, August 25, 2020 at 5:09:37 PM UTC+5:30 [email protected]
> <mailto:[email protected]> wrote:
> Hi,
> My app is using the Module.GL.getNewId function in order to create handles to
> WebGL textures, This is done so that I'll be able to load the textures on the
> JS side, and use them via OpenGL APIs in WASM. We want to start building with
> MODULARIZE=1, but this hides the GL object in the Module's closure.
> I know that this can be fixed with post-js operations, but I'd like to have a
> solution that is less likely to be broken by future versions of Emscripten,
> so I want to open a PR that will fix this situation. I see 3 possible
> solutions:
> 1. Expose the GL object as-is on the Module.
> 2. Expose a wrapper to the getNewId function, and a matching function that
> allows removal of said handle.
> 3. Add to the module a JS function that returns a pair - a WebGL texture, and
> its OpenGL handle, and a matching function to remove said handle.
>
> Are any of these ideas worth pursuing? Anything I might be missing?
>
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/115207d8-284d-4d37-b164-d4851fdb1d70n%40googlegroups.com
>
> <https://groups.google.com/d/msgid/emscripten-discuss/115207d8-284d-4d37-b164-d4851fdb1d70n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGYP5H_zKX0Kg8PMpmCnpFq-yM%2BO_cW81xQoT%3DWS0pbFNA%40mail.gmail.com
>
> <https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGYP5H_zKX0Kg8PMpmCnpFq-yM%2BO_cW81xQoT%3DWS0pbFNA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29_fdmtTmQZt_QyfQ-1KBhe%3DEw297rSBZ_assWqCgdZFw%40mail.gmail.com
>
> <https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29_fdmtTmQZt_QyfQ-1KBhe%3DEw297rSBZ_assWqCgdZFw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGYgOHFBdP0qwDtUOAPt80FZqEz6AHPPZ4TRKRBUav%2Bi2g%40mail.gmail.com
>
> <https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGYgOHFBdP0qwDtUOAPt80FZqEz6AHPPZ4TRKRBUav%2Bi2g%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
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/7176ABD8-4A91-4382-872E-88B4F730A89B%40callow.im.
signature.asc
Description: Message signed with OpenPGP
