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

Re: [Public WebGL] How to set a canvas backing store to display units?





On Wed, Jun 13, 2012 at 6:05 PM, Steve Baker <steve@sjbaker.org> wrote:

Gregg Tavares (社用) wrote:
> On Wed, Jun 13, 2012 at 3:40 PM, Glenn Maynard <glenn@zewt.org> wrote:
>
>> On Wed, Jun 13, 2012 at 12:14 PM, Gregg Tavares (社用)
>> <gman@google.com>wrote:
>>
>>>  This only works now because the min "max size" (AFAIK) is 2048 and no
>>> one has tried to make it bigger.
>>>
>>> Yes, by the spec, EVERYONE IS CURRENTLY DOING IT WRONG
>>>
>>
>> Please stop screaming at me.
>>
>> That's not how things work on the Web.  If everyone is already doing
>> something in a certain way, then it becomes the correct way.  Web APIs
>> are
>> bound by web-compatibility.
>>
>
> Really? There's plenty of examples of breaking changes to web apis or
> deprecated features that have now been removed from browsers that pages
> were using.
>
> The spec does specify a specific usage. People aren't following the spec.
> Those are both true. Whether or not they need to start following it or the
> spec needs to change is up for debate.

Yes - but those kinds of change are generally for obscure corner cases or
long-obsolete features - and the problem generally affects only a
vanishingly small proportion of websites.

Here, we could easily affect close to 100% of WebGL programs - including
very recent ones - including those who followed the code in our example
programs and tutorials to the letter - and this is one of the newest web
API's, not some dusty old junk that people should have stopped using years
ago.

I think we have to tread very carefully.

I'm not suggesting breaking WebGL so much as enforcing the spec. Any program that uses something along the lines of

     --css--
     canvas {
        width: 100%;
        height: 100%;
     }

     --js--
     canvas.width = canvas.clientWidth;
     canvas.height = canvas.clientHeight;
     gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);

Is already broken today. Find a GPU with a 2048 or 4096 pixel MAX_TEXTURE_SIZE limit. Attach a second and or 3rd monitor. Stretch the window width across the monitors until its width is > than the limit. See the bug.

The only thing that has prevented these bugs from appearing is few people if any stretch their windows across views that large.

As for the rest, I think it's pretty clear we need to make WebGL always work in device pixels. The canvas.width and canvas.height have to make a backbuffer in those number of pixels. I don't see this has making WebGL second class. Most WebGL apps use libraries. It will be a short time until most of those libraries default to making HD backbfufers for HD-DPI displays.

 

 -- Steve