As you said, the thing you're doing wrong is not calling emscripten_webgl_ create_context. As far as I understand, emscripten uses JS's webGL context (and textures, and other objects) behind the screen, so you have to register the context you're using with emscripten in order for it to transform your OpenGL calls to calls on the relevant WebGL objects.
On Sun, 7 Jul 2019 at 14:51, nevo natan <[email protected]> wrote: > > I am trying create webGL canvas and context in Javascript: > > var canvas = document.getElementById('canvas'); > var gl = canvas.getContext('webgl'); > var buffer = gl.createBuffer(); > > and then use it in my cpp: > > // EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = > emscripten_webgl_create_context("#canvas", &attrs);... > glGenBuffers(1, &vb); > > but without emscripten_webgl_create_context I always get > > Uncaught (in promise) TypeError: Cannot read property 'createBuffer' of > undefined > at __glGenObject (output.js:1) > > if I use emscripten_webgl_create_context all works well. > > what am I doing wrong? Help much appreciated! > > -- > 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/b51bce37-a3f4-4472-8e78-eb6de7e59b9a%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/b51bce37-a3f4-4472-8e78-eb6de7e59b9a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CA%2B_KjGa70LUB_8D9Xp%2BNV%3DAdHtEPHr1VH-TMAPNXu05%2B8fjjag%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
