[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?





On Thu, Sep 9, 2010 at 2:01 PM, Kenneth Russell <kbr@google.com> wrote:
On Thu, Sep 9, 2010 at 12:32 PM, Gregg Tavares (wrk) <gman@google.com> wrote:
> If I do this
>
> <canvas width="2560" height="1600"></canvas>
>
> canvas = document.getElementByTagName("canvas")[0];
> gl = canvas.getContext("webgl");
>
> Or this
>
> <canvas></canvas>
> canvas = document.getElementByTagName("canvas")[0];
> gl = canvas.getContext("webgl");
> canvas.width = 2560;
> canvas.height = 1600;
>
> And the GPU I'm on only supports 2048 maximum backbuffer size. What should
> happen?
> 1) getContext fails for case 1 above? for 2 you get lost context
> 2) You get a backbuffer of the maximum size. canvas.width and canvas.height
> change to match?
> 3) You get an exception
> 4) An out of range width setting is ignored it stays whatever it previously
> was.
> 5) ????

I think (1) is the right behavior for WebGL, because this is an
limitation specific to OpenGL, not the canvas element in general.

1 is okay I guess but I suspect lots of developers will do this

<canvas style="width: 100%; height: 100%></canvas>

canvasElement. {
  canvasElement.width = canvasElement.clientWidth;
  canvasElement.height = canvasElement.clientHeight;
}

And then the user will size their browser and the app will fail past a certain point.  I guess we need to make it clear that if you're going to change the back buffer size you have to query the maximum values.



 

-Ken