[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Behavior of WebGL canvas when it can't make a backbuffer of the requested size?
- To: Steve Baker <email@example.com>
- Subject: Re: [Public WebGL] Behavior of WebGL canvas when it can't make a backbuffer of the requested size?
- From: Kenneth Russell <firstname.lastname@example.org>
- Date: Wed, 3 Nov 2010 19:11:19 -0700
- Cc: "Gregg Tavares (wrk)" <email@example.com>, Chris Marrin <firstname.lastname@example.org>, Vladimir Vukicevic <email@example.com>, public webgl <firstname.lastname@example.org>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1288836682; bh=FdZTJOMztBG8fb7VXZZXCSPKcmo=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Cc:Content-Type:Content-Transfer-Encoding; b=brZD+V3VkrbftNipXTd1HLkh7QrtH6d+HUV61XgB00Ic7WLyNeprKzl7r8o/oCBpZ essbodJvV8FRr2toSThyg==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=+lBsbIu0ss+OkuE0sRUUjSCbRgwJI2p/CbY11dTf6N4=; b=gQp4v6zzrJiz8guj6rr8zdMoYdvdxxIinztCJeC0Xs2SszU6GyRHO2G1+nYEyKXHJ+ 29xadgSPo/wTbEyQn7/w==
- Domainkey-signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=X1hSm9OY75wvmXHQO14MgrWLzpqdGGQWGp932Nyj8KPEQeptK3qi+VvU0NJjytyR69 SnVsrPBpqChkav3i2TBA==
- In-reply-to: <4CA50820.email@example.com>
- References: <AANLkTi=rKRNuWGwfD39h5d6Ttu55paWSq9qTNQ19xfC5@mail.gmail.com> <1561074246.1142.1285141436615.JavaMail.firstname.lastname@example.org> <AANLkTin2iu-V1LckEs_YJCUFgwRWX4rPvy+Z8MnaGy5c@mail.gmail.com> <27872E4C-B753-4DAC-8353-BFC3D74739D2@apple.com> <AANLkTim-i8j4LrzDrWyi_djdSxpg0-j5igvRhK9DNSMj@mail.gmail.com> <4C9D395A.email@example.com> <7ED78BBF-6DD3-45B1-978E-0FFDA5856695@apple.com> <AANLkTi=rFt3apXrfwfxtcF47nZS+fKDRCXMmPRUfd0Ja@mail.gmail.com> <29C16266-C657-4CB6-9B01-CFD9B2DD8A61@apple.com> <AANLkTimutLit_273e5pg1e3fg7n-uQyPK1ZxoZenBj59@mail.gmail.com> <AFA5AA20-36D7-4B85-95CA-2BB520C59DEC@apple.com> <AANLkTimi-Zgq62B7GEnYR72qR+kkMgFzagbX=4PWM0Rt@mail.gmail.com> <34C909B2-D7A1-4983-A79F-99D322F2AC17@apple.com> <AANLkTikr5ZDtydmyTn+OLqbuut6uquVW6PW+2tM_btmR@mail.gmail.com> <4CA50820.firstname.lastname@example.org>
- Sender: email@example.com
On Thu, Sep 30, 2010 at 2:58 PM, Steve Baker <firstname.lastname@example.org> wrote:
> Gregg Tavares (wrk) wrote:
>> On Wed, Sep 29, 2010 at 5:50 PM, Chris Marrin <email@example.com
>> <mailto:firstname.lastname@example.org>> wrote:
>> On Sep 29, 2010, at 2:37 PM, Gregg Tavares (wrk) wrote:
>> > ...And I assume that when that's done an implicit transform is
>> applied to make it look to the user like the canvas is the
>> requested size? That's what I suggested in the first place, but it
>> was pointed out that hiding the actual size from the author like
>> that is not really possible. Canvas 2D doesn't have concepts like
>> viewport, which are not affected by transforms. And WebGL doesn't
>> have an overarching transform that is applied to everything. I
>> don't see how you can have a drawing buffer that is not the
>> requested size without the rendering coming out all wrong. If so,
>> you're not helping the author by doing things behind his back.
>> > For 99% of WebGL apps they should be using canvas.clientWidth
>> and canvas.clientHeight as the dimensions for computing rendering
>> aspect. Those will always be correct regardless of the backbuffer
>> I don't understand what you mean. clientHeight and clientWidth are
>> the size in pixels of the canvas image on the page, which has
>> nothing to do with the size of the drawing buffer. I believe there
>> will be many uses for WebGL where the drawing buffer size is
>> different from the client size for performance, etc.
>> Most WebGL apps call a function modeled after gluPerspective
>> <http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml> to
>> compute a perspective projection matrix and set the aspect ratio such
>> that their images show up with the correct aspect. The correct aspect
>> ratio to pass in is canvas.clientWidth / canvas.clientHeight. It is
>> NOT canvas.width / canvas.height. The aspect ratio that needs to be
>> passed in is the size at which the result will be displayed, not the
>> size it's rendered. The size that it's rendered is rarely relevant to
>> anything in a WebGL app except for rendering quality.
> There are some very specific algorithms (like screen-space ambient
> occlusion, for example) that really require you to know the true screen
> resolution. I don't think it matters that you don't get the resolution
> you asked for so long as you can always find out what the resolution you
> have is.
> Traditional fixed-function pipeline OpenGL applications do indeed use a
> projection matrix - which you could possibly intercept and modify if
> that helped - but with the advent of vertex shaders, all bets are off
> and applications can send whatever matrices they like however they like
> - so there is no longer a single place to change that. But the viewport
> and scissor commands are the ones you'd need to be careful with.
> I'd still prefer a system where we explicitly say that the context
> dimensions you ask for are merely suggestions from the application (just
> like the stencil and depth buffer precisions) - which the browser may
> choose to ignore, making the actual resolution either larger or smaller
> - and hence, applications should ALWAYS query the system to find out
> what resolution they actually have.
Apologies for the delay getting back to this, but the WebGL working
group strongly wants to resolve this issue. As I understand it the
viable options when setting the canvas's width or height to a value
unsupportable by the underlying OpenGL implementation appear to be:
1. Make the largest supported backing store, and stretch it to fit the
canvas's area on the web page. Add an API to WebGLRenderingContext,
"long getDrawingBufferSize()", returning the actual width and height
of the backing store.
2. Set a synchronous error condition on the canvas which can be
checked via a new API such as "boolean isDrawingBufferValid()". Draw
calls either raise an error or are ignored.
3. Raise a WebGL context lost event when the canvas is resized too
large, and a context restored event when it is shrunk back to a
At this point I continue to believe that (1) is the best option for
web developers. Naive developers will get mostly correct results,
which based on discussion with Tab Atkins are better than no results.
I would no longer advocate (3) as it is too complex to handle. Raising
an exception from the setting of canvas.width or canvas.height does
not seem to be a viable option as it changes the semantics of these
I propose that we update the spec to indicate that WebGL
implementations do (1). Please send any comments to the list.
You are currently subscribed to email@example.com.
To unsubscribe, send an email to firstname.lastname@example.org with
the following command in the body of your email: