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

Re: [Public WebGL] getContext multiple context language



On Jan 26, 2010, at 1:44 PM, Vladimir Vukicevic wrote:

>> ...I thought from earlier discussions that we were going to stay closer
>> to WGL's (and Mac OS X's) approach to the matching of the attributes
>> than that of GLX. In WGL, the pixel format best matching the requested
>> attributes is returned, while in GLX, if any one of the requested
>> attributes can't be satisfied, glXChooseVisual / glXChooseFBConfig
>> fails. GLX's behavior is too stringent in my experience. If we do
>> this, then it isn't necessary to change the naming of any of the
>> attributes in WebGLContextAttributes.
>> 
>> In particular, I don't like the idea that we are mandating the
>> presence of the stencil buffer by default. This would mean that all
>> current WebGL implementations are not spec compliant.
>>   
> 
> That's a good point; but I'd rather fix that by changing the defaults in the spec.  Things like stencil and depth buffer seem like hard requirements for an app to me; I guess if a stencil buffer isn't available an app could use a different algorithm in some cases, but if the app does have that option then it could just retry the getContext() call.  I realize that this gets into the somewhat ugly gl attribs loops that are found in C, but it's either that or requiring every app to ensure that, for example, it got a depth buffer.  Seems that the simplest code would be for an app to request some basic capabilities, such as depth and maybe stencil, and require that it gets those; antialiasing is the outlier here, since the app would run just fine without AA... thus the 'Hint' status.

Stencil is required in GLES. With that said, I believe it's default should be false. I think it's a typo that it's not.

> 
>>> One thing that I didn't do here but might be a good idea is to move
>>> getContextAttributes(contextId) to the canvas itself, as opposed to putting
>>> it on the context.  That seems to be better symmetry.
>>>     
>> Perhaps. For convenience though it seems helpful to retain
>> getContextAttributes() on the context object itself.
>> 
>>   
>>>>> If we require that the attributes must be identical during all
>>>>> requests, then exactly what version of the attributes need to be
>>>>> passed? The originally requested ones, which might not have been able
>>>>> to be honored, or the actual attributes that were satisfied by the
>>>>> implementation?
>>>>> 
>>>>> For this reason I strongly think that it would be a mistake to pay
>>>>> attention to the attributes on second and subsequent getContext()
>>>>> calls. Here is suggested re-wording:
>>>>> 
>>>>> "If getContext() is called with a contextId that names an
>>>>> already-active context, it must return the same resulting context
>>>>> object. In this case, the attributes, if any, are ignored."
>>>>> 
>>>>> -Ken
>>>>>         
>>>> I agree with Ken's suggestion.  If the point of being able to call
>>>> getContext() multiple times is to avoid having to pass the context object
>>>> around then requiring every call to use the same arguments seems to negate
>>>> that benefit (you would have to pass the arguments around instead).  It also
>>>> possibly creates an expectation that by passing a different set of arguments
>>>> you could modify an existing context which we know it's not what happens.
>>> 
>>> It would be simpler, but the latter bit is exactly what worries me -- if the
>>> attributes are just silently ignored, then the user might think that a
>>> switch took place.
>>> 
>>> What about a third alternative: attributes are invalid on a getContext()
>>> call for an already-active context?  That is, any subsequent getContext call
>>> must not specify any attributes?
>>>     
>> I think this will lead to problems when composing multiple libraries
>> that all use WebGL, so I still think the attributes should just be
>> ignored on the second and subsequent getContext() calls. Well-written
>> libraries will check the context attributes and ensure that they got
>> all of the features they require; but the vast majority of libraries
>> that don't will still work, and interoperate cleanly.
>>   
> 
> Hmm, that's exactly the problem that I was trying to solve by requiring the attributes to always be passed... that is, if library A requests some attributes, and library B requests other attributes, library B won't have any option but to fail if it inspects the attributes after the fact.. or it would have ignored them in the first place.
> 
> However, really, I want to strongly discourage people from using getContext(); I'd like authors to call getContext once and then pass around the context object.  The language that's in there currently about requiring the same attributes is an oblique way at encouraging that.  If we didn't already have code using getContext("2d") all over the place in rendering loops, I'd push for making it illegal to call getContext more than once with the same context name.  I don't think the point of being able to call getContext() multiple times is necessarily to avoid having to pass around the context... you'd still have to pass around the canvas element.

Yeah, I'd like that, too. But it would break content.

> 
> I still think the safest option is to require that the same set of attributes is specified in each call -- silent-ignore behaviour for something like this seems wrong, and my suggested error-if-specified-at-all behaviour is really just a bandaid for that problem.
> 
> We can try to craft another alternative:
> 
> - First call to getContext -- unspecified attributes means defaults, specified as given.
> - Subsequent calls to getContext -- unspecified attributes means "give me what's there", specified as given, error if specified isn't a subset of currently active attributes.

I like this compromise.

-----
~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: