1

I have an application that currently is working with several webGL contexts that I need to make work correctly with only one webGL context (as many of the devices I'm targeting only support a single webGL context.)

I cannot reduce it down to a single canvas because I have layering with DOM-content such as webpages.

Ideally I would be able to simply switch the canvas and use the webGL context as normal, but I cannot find a method for doing this. Any ideas?

I'm using Pixi.js v3 in case that is helpful, but I do not mind directly using webGL commands. Is this even possible? There was some discussion in 2012 on the Khronos mailing list about this but it seems to be a dead end (https://www.khronos.org/webgl/public-mailing-list/archives/1210/msg00058.php) - but I'm hopeful there is an alternative?

jconder
  • 686
  • 4
  • 9

1 Answers1

1

Moving WebGL contexts to different canvases is not currently possible.

Does this technique not work for you?

https://stackoverflow.com/a/30546250/128511

Community
  • 1
  • 1
gman
  • 100,619
  • 31
  • 269
  • 393
  • Sorry I forgot to respond to this, been a hectic past few months. No unfortunately that technique does not work, as I need to be able to layer non-canvas content in between the canvas content. This means I need to be able to draw some canvas content, draw DOM-stuff, and then in the same spot draw more canvas content, then more DOM-stuff, etc. I wrote an optimizer that found optimal bounding rects for the canvas content and reduced as much of it to a single context as possible (since the layering order is known up front) which made it workable but not ideal. – jconder Jun 23 '16 at 21:37
  • maybe if you add a diagram of what you need to your question it would be clearer what you're trying to do – gman Jun 24 '16 at 11:44