[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Addition to WebGLContextLostEvent wrt extensions



On Apr 22, 2010, at 4:02 PM, Gregg Tavares wrote:

> 
> 
> On Thu, Apr 22, 2010 at 3:41 PM, Chris Marrin <cmarrin@apple.com> wrote:
> 
> On Apr 22, 2010, at 10:30 AM, Gregg Tavares wrote:
> 
> > So I worked through some sample code using WebGLContextRestored and convinced myself my fears were unfounded. Thank you for being patient with me.
> 
> Wait. I need context. Our current proposal has a WebGLContextRestorable event and a restore() method (replace restore with reset as needed). Is that your assumption, too?
> 
> 
> No need for restore() I think.
> 
> What's needed is WebGLEventContextLost and WebGLEventContextRestored with the detail that WebGL will fail all calls until the WebGLEventContextRestored is delivered (ie, the function registered for it is called)
> 
> In otherwords
> 
> ctx = canvas.getContext("webgl");
> cavnas.addEventListener("webGLEventContextRestored", handleRestore);
> 
> function handleRestore() {
>   // At this point ctx is usable and accesses the restored context, not the lost context.
> }
> 
> That means that for example if I do this
> 
> var textures[];
> for (var ii = 0; ii < 1000; ++ii) {
>   textures[ii] = ctx.createTexture();
> }
> 
> And while that loop is running the OpenGL context is lost (say at ii = 123) and then restored (say at ii = 456) WebGL will still fail all calls after ii = 456 because the WebGLEventContextRestored has not yet been handled (JavaScript being synchronous)
> 
> The other detail is that if no handler is registered then WebGL will fail forever after a lost context.

Hey! You Google guys need to get your stories straight. Ken thinks we should have the restore() function :-)

I don't have a strong feeling either way. But it does feel odd that, if you forget to setup an event handler, there will be no way to restore the context. Of course that's a bug, but it does require you to handle events. Maybe that's not a big deal.

-----
~Chris
cmarrin@apple.com




-----------------------------------------------------------
You are currently subscribe to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: