[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 14/06/2012 15:13, Gregg Tavares (çç) wrote:

On Wed, Jun 13, 2012 at 10:46 PM, Mark Callow <callow_mark@hicorp.co.jp> wrote:

On 14/06/2012 12:08, Gregg Tavares (çç) wrote:


 Âvoid main( void ) {
float r = mod(gl_FragCoord.x / 20.0, 2.0) < 1.0 ? 0.0 : 1.0;Â
float g = mod(gl_FragCoord.y / 20.0, 2.0) < 1.0 ? 0.0 : 1.0;Â
gl_FragColor = vec4(r, g, 0, 1);
 Â} ÂÂ

This shader will generate a 20x20 plaid pattern. It has no input to fix. Having it suddenly go 1/4 size on a HD-DPI display doesn't seem acceptable.

Similarly, having every particle in three.js suddenly draw at 1/2 size also doesn't seem acceptable.

Or having all the lines in MapsGL suddenly become 1/2 as thick.

If the author's intention is that the pattern always approximates to some particular size in human terms, then the shader above is buggy. Given the wide range of screen resolutions out there (in the proper sense of resolution) a pattern like that is obviously going to render at many different actual sizes. Perhaps the author intends it to vary in actual size.

No, it wouldn't this has nothing to with display size. It has to do with rendering pixels. No OpenGL api asks for some backbuffer of width by height pixels and is given some other size. All OpenGL programs explicitly request a size or leave it up to the OS and then query it. These units are always in device pixels. It can work no other way.
Who mentioned display size? I wrote "in the proper sense of resolution".

As I understand it, the shader draws a 20 pixel by 20 pixel pattern. The case where it would "suddenly go to 1/4 size," is when the display resolution (dpi) increases and the display size is unchanged.

If the author does not intend the pattern to change size as the dpi increases, instead of hard-coding 20, he or she needs to calculate a divisor based on the display resolution.

Either the code is buggy or you are making an unwarranted assumption when you say having it go to 1/4 size on an "HD-DPI' display is not acceptable.

ÂÂÂ -Mark