[Bf-taskforce25] Silly note about area/region/mask sizes vs. matrices
Ton Roosendaal
ton at blender.org
Sat Dec 6 17:18:37 CET 2008
Hi,
To keep the Blender UI behaving nice stable, it's important to keep
track of this issue:
Rects for area, region, and view2d masks are in pixel coordinates.
They're integers, and use coordinates from start-pixel to (and
including) the end-pixel.
Example: a region rect (100, 100, 200, 200) is actually of "size" (101,
101). A similar sized region or mask above that should get coordinates
(100, 201, 200, 301).
This is how glViewport then should be set:
/* glViewport(x, y, sizex, sizey); */
glViewport(xmin, ymin, xmax-xmin+1, ymax-ymin+1);
Same goes for a 1:1 mapping for drawing:
wmOrtho2(C->window, 0, 101, 0, 101);
The opengl spec defines that you should substract 0.375 from the above
values for 100% accurate 1:1 mapped transform.
I've noticed some glitches for this in my code, which is being
submitted now. :)
-Ton-
------------------------------------------------------------------------
Ton Roosendaal Blender Foundation ton at blender.org www.blender.org
Blender Institute BV Entrepotdok 57A 1018AD Amsterdam The Netherlands
More information about the Bf-taskforce25
mailing list