I need advice, I got a OpenGL that relies on the glm library for matrix calulations, but emscripten doesn't support it. Can someone give me advice (sorry for the long subject title)

623 views
Skip to first unread message

james morrissey

unread,
Apr 1, 2015, 5:53:30 AM4/1/15
to emscripte...@googlegroups.com
I'm considering moving the matrix calculation stuff in the shader code. But if anyone has better advice let me know

Jukka Jylänki

unread,
Apr 1, 2015, 6:08:46 AM4/1/15
to emscripte...@googlegroups.com
From GLM homepage, http://glm.g-truc.net/0.9.6/index.html , GLM is a header-only C++ math library, and to my understanding, it should be very platform independent and therefore compile through Emscripten. GLM does have some SIMD paths that Emscripten and the web does not yet support, but according to http://glm.g-truc.net/0.9.2/api/a00002.html , those can be disabled. What do you mean specifically by "emscripten doesn't support it"? Did you run to a specific compilation error with that library?

2015-04-01 12:53 GMT+03:00 james morrissey <jamm...@gmail.com>:
I'm considering moving the matrix calculation stuff in the shader code. But if anyone has better advice let me know

--
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 emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Warren Seine

unread,
Apr 1, 2015, 8:49:00 AM4/1/15
to emscripte...@googlegroups.com
On Wednesday, April 1, 2015 at 11:53:30 AM UTC+2, james morrissey wrote:
I'm considering moving the matrix calculation stuff in the shader code. But if anyone has better advice let me know

Minko (dev branch) is using parts of glm and supports HTML5 with Emscripten.

You can see how we initialize glm here.

james morrissey

unread,
Apr 1, 2015, 10:05:28 AM4/1/15
to emscripte...@googlegroups.com
Hi
Thanks for the really fast response I wasn't expecting it, and sorry for my late response.

Honestly I'm just getting started Emscripten and compiling from C++ to JS,  but I find it really interesting :)

What do mean by SIMD paths (I googled it, and got a lot vague definitions)
Thanks for SIMD advice I'm working on implementing it now. 

"emscripten doesn't support it"
I mean I checked the include directory but it's not there, while glew,freeglut are.
emscripten has support for "user input(freeglut)" and getting extensions(glew) 
but no support for matrix calculations.

My problem in its most simplistic sense, is that emscripten doesn't recognize glm
#include <glm/glm.hpp> 
// I need to change the includes ??

so this lead to an error here

   trans = glm::rotate(
                    ^^^
                      
And again I'm new emscripten and compiling from C++ to JS.
Your help is really really appreciated

Floh

unread,
Apr 1, 2015, 12:19:18 PM4/1/15
to emscripte...@googlegroups.com
I found glm to be quite fast for general math code in emscripten, for instance this instancing demo uses glm for its particle updates, without any fancy optimizations:

http://floooh.github.io/oryol/Instancing.html

In comparision here's the same demo with the particle update running on the GPU (fragment shader writes to a  ping-ponged render target texture, which is then sampled in a vertex shader to displace particle positions):

http://floooh.github.io/oryol/GPUParticles.html

Dependending on the target platform, the extra effort to move all math to the GPU is not worth it because you need to restructure your entire code architecture around this.

Remember that you need to tell emcc about the location of the glm headers with -I.

And (shameless plug), if you want an easy-to-use cmake build system wrapper that also supports simple cross-compiling to emscripten, check out fips: http://floooh.github.io/fips/ (3D sample video with emscripten cross-compiling demo at the end (also works on Windows or Linux): https://www.youtube.com/watch?v=B5R0uE5IMZs)

Cheers,
-Floh.
Reply all
Reply to author
Forward
0 new messages