get texture object of webgl by ID

565 views
Skip to first unread message

Alon Faraj

unread,
May 24, 2017, 8:46:58 AM5/24/17
to emscripten-discuss
Im using the function bindTexture directly from JS:

var texture = some_GL_ID;
gl.bindTexture(gl.TEXTURE_2D, texture);

but I get an error:
Failed to execute 'bindTexture' on 'WebGLRenderingContext': parameter 2 is not of type 'WebGLTexture'.

How Can I get the 'WebGLTexture' itself by GL texture ID?

Alon Zakai

unread,
May 24, 2017, 12:49:52 PM5/24/17
to emscripten-discuss
The GL object has mappings of ids to objects, GL.textures[id] will give you the WebGLTexture for it.


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

Alon Faraj

unread,
May 25, 2017, 4:08:28 AM5/25/17
to emscripten-discuss
Thanks!
but now I get an error/warning "WebGL: INVALID_OPERATION: bindTexture: object not from this context" when rendering to the second canvas.
any idea why?

בתאריך יום רביעי, 24 במאי 2017 בשעה 19:49:52 UTC+3, מאת Alon Zakai:

Brian Gavin

unread,
May 25, 2017, 8:49:11 AM5/25/17
to emscripten-discuss
I would guess the value of some_GL_ID is incorrect based on your error message.   

Brian Gavin

Alon Zakai

unread,
May 25, 2017, 1:02:59 PM5/25/17
to emscripten-discuss
I'm not familiar with that error message, but I guess it means that you need to use the same context as the texture was created in? That would be GL.currentContext (unless you created more than one).

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages