[whatwg] [canvas] getContext & multiple contexts

On Aug 3, 2010, at 3:41 PM, Ian Hickson wrote:

> On Tue, 3 Aug 2010, Chris Marrin wrote:
>> On Aug 2, 2010, at 3:16 PM, Ian Hickson wrote:
>>> On Thu, 29 Apr 2010, Vladimir Vukicevic wrote:
>>>> 
>>>> A while ago questions came up in the WebGL WG about using a canvas 
>>>> with multiple rendering contexts, and synchronization issues that 
>>>> arise there. Here's our suggested change to getContext.
>>> 
>>> This seems overly complex. I've gone for a somewhat simpler approach, 
>>> which basically makes <canvas> fail getContext() if you call it with a 
>>> context that isn't "compatible" with the last one that was used, as 
>>> defined by a registry of contexts types. Currently, only '2d' and '3d' 
>>> are defined in this registry, and they are not defined as compatible.
>> 
>> '3d'? We're calling it 'webgl'. Is there another 3D context registered 
>> somewhere?
> 
> Sorry, typo in the e-mail. The spec correctly refers to a "webgl" context.
> 
> (I have to say, I'd rather we called it "3d". I hate it when we embed 
> marketing names into the platform.)

I generally agree. For me, I consider WebGL to be a clarifying name like HTML, rather than a marketing name.

> 
> 
>>> [arguments on getContext]
>> 
>> We feel it's more appropriate on the getContext() call because it 
>> involves creation of the resources for the context. If it were a 
>> separate call, you'd need to defer creation of those resources until the 
>> attribute call is made or create them as needed. This not only involves 
>> overhead in every call, but it requires you to provide specific rules on 
>> which calls cause automatic resource creation. Making it a parameter to 
>> getContext simplifies the definition. And it seems this would be a 
>> useful parameter for many types of contexts, even the 2D context as Vlad 
>> pointed out.
> 
> What happens if you call getContext with the same contextID but different 
> attributes?

Good question. It's addressed in https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html#2.1. It says that subsequent calls ignore the attributes. There is a getContextAttributes call on the context to return what attributes were actually set.

-----
~Chris
cmarrin at apple.com

Received on Wednesday, 4 August 2010 08:16:55 UTC