[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54098] trunk/blender/source/blender/ windowmanager/intern/wm_subwindow.c: Bugfix #33989

Jason Wilkins jason.a.wilkins at gmail.com
Fri Jan 25 20:16:34 CET 2013


I made the change to trunk due to a difficult merge conflict with
swiss-cheese.  The conflict obscured what was modified, so I did not
correctly merge the bugfix.  "Readability" was my original reason for
making the changes.  My version makes it more clear that the
dimensions are either the same or both glScissor and glViewport, or
they are different.

The problem is that wmOrtho2 also uses width and height, but it should
always use the same values that Viewport got.  Whoever fixed this used
variable shadowing to kind of sweep this under the rug.  Who uses
variable shadowing on purpose!? ;-)

My solution would have been to move wmOrtho2 just after glViewport
instead of creating a new width and height with the same name.

With the maintainer's permission I'd like another shot at fixing the
tangled logic of this function :-)



On Fri, Jan 25, 2013 at 4:17 AM, Ton Roosendaal <ton at blender.org> wrote:
> Revision: 54098
>           http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54098
> Author:   ton
> Date:     2013-01-25 10:17:06 +0000 (Fri, 25 Jan 2013)
> Log Message:
> -----------
> Bugfix #33989
>
> Transparent region drawing and blend broke by commit 53919 5 days ago.
> This commit reverts the change.
>
> The claim in previous commit "edited code for readability" is quite
> disputable :) The error is hard to notice even.
>
> I also like to emphasize that people should check with owners for code
> before committing changes! Cleaning code is first a job for maintainers.
>
> Modified Paths:
> --------------
>     trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c
>
> Modified: trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c
> ===================================================================
> --- trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c    2013-01-25 09:57:17 UTC (rev 54097)
> +++ trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c    2013-01-25 10:17:06 UTC (rev 54098)
> @@ -241,8 +241,7 @@
>
>  void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
>  {
> -       int x, y, width, height;
> -
> +       int width, height;
>         _curswin = swin_from_swinid(win, swinid);
>
>         if (_curswin == NULL) {
> @@ -251,33 +250,26 @@
>         }
>
>         win->curswin = _curswin;
> -
>         _curwindow = win;
>
> -       x      = _curswin->winrct.xmin;
> -       y      = _curswin->winrct.ymin;
>         width  = BLI_rcti_size_x(&_curswin->winrct) + 1;
>         height = BLI_rcti_size_y(&_curswin->winrct) + 1;
> -
> -       glViewport(x, y, width, height);
> -
> +       glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
> +
>         if (srct) {
> -               x      = srct->xmin;
> -               y      = srct->ymin;
> -               width  = BLI_rcti_size_x(srct) + 1;
> -               height = BLI_rcti_size_y(srct) + 1;
> +               int width  = BLI_rcti_size_x(srct) + 1; /* only here */
> +               int height = BLI_rcti_size_y(srct) + 1;
> +               glScissor(srct->xmin, srct->ymin, width, height);
>         }
> -
> -    glScissor(x, y, width, height);
> +       else
> +               glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
>
>         wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
> -
> -       glLoadIdentity(); /* reset MODELVIEW */
> -
> -       glFlush(); /* XXX: jwilkins - is this really needed here? */
> +       glLoadIdentity();
> +
> +       glFlush();
>  }
>
> -
>  /* enable the WM versions of opengl calls */
>  void wmSubWindowSet(wmWindow *win, int swinid)
>  {
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs


More information about the Bf-committers mailing list