Results 1 to 2 of 2

Thread: Context sharing and lifetime

  1. #1
    Junior Member
    Join Date
    Mar 2011

    Context sharing and lifetime


    Is it possible to share GL contexts among multiple canvas elements on the same page? If so, how - is it done by default?

    Also, what approach do you recommond for unit testing where each test uses a new GL context? Currently, I am using the Jasmine framework and have each test (or sometimes group of tests) dynamically create and destroy a canvas element with document.createElement, document.body.appendChild, and document.body.removeChild. Firefox seems to cleanup reasonably well, but I've gotten Chrome to choke more than a few times.


  2. #2
    Junior Member
    Join Date
    Mar 2011

    Re: Context sharing and lifetime

    Just an update: both Firefox and Chrome are now quite stable with my unit tests creating and destroying hundreds of canvas elements.

    I made a small test, like the html code shown below, and different canvases on the same page do not share the same context (I don't know how they would anyway) and do not share shaders. I assume the same is true for textures and other GL objects that can currently be shared in desktop GL. Perhaps there will be a future WebGL extension that allows context sharing or maybe there will be security concerns, but I don't know what.

    This isn't a huge concern to me. I was really just curious.

    Code :
    <head><title>Multiple context test</title></head>
    <canvas id="canvas0" style="border: none;" width="1" height="1"></canvas>
    <canvas id="canvas1" style="border: none;" width="1" height="1"></canvas>
    <script type="text/javascript">
        var gl0 = document.getElementById("canvas0").getContext("experimental-webgl");
        var gl1 = document.getElementById("canvas1").getContext("experimental-webgl");
        var s = gl0.createShader(gl0.VERTEX_SHADER);
        document.write(gl0.isShader(s) === gl1.isShader(s));
        document.write(gl0.getParameter(gl0.DEPTH_TEST) === gl1.getParameter(gl1.DEPTH_TEST));


Similar Threads

  1. Problem with GL-CL sharing context
    By eilgin in forum OpenCL
    Replies: 3
    Last Post: 05-20-2011, 04:44 AM
  2. Creating GL-Sharing context with SDL
    By mollitz in forum OpenCL
    Replies: 2
    Last Post: 07-19-2010, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean