Fix: selecting with z-buffer hiding did not work when graphics card settings
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 31 Oct 2011 14:08:14 +0000 (14:08 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 31 Oct 2011 14:08:14 +0000 (14:08 +0000)
enabled antialiasing, overriding application settings.

The fix for this got lost when the FSAA option was added and later disabled
again. Added it back now, and also disable AA for UI widgets since it makes
them look too blurry, they already do their own AA.

source/blender/editors/interface/interface.c
source/blender/editors/space_view3d/view3d_draw.c

index 5b27fe8..a6316dc 100644 (file)
@@ -962,6 +962,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
        ARegion *ar;
        uiBut *but;
        rcti rect;
        ARegion *ar;
        uiBut *but;
        rcti rect;
+       int multisample_enabled;
        
        /* get menu region or area region */
        ar= CTX_wm_menu(C);
        
        /* get menu region or area region */
        ar= CTX_wm_menu(C);
@@ -971,6 +972,11 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
        if(!block->endblock)
                uiEndBlock(C, block);
 
        if(!block->endblock)
                uiEndBlock(C, block);
 
+       /* disable AA, makes widgets too blurry */
+       multisample_enabled= glIsEnabled(GL_MULTISAMPLE_ARB);
+       if(multisample_enabled)
+               glDisable(GL_MULTISAMPLE_ARB);
+
        /* we set this only once */
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        
        /* we set this only once */
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        
@@ -1015,6 +1021,9 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
+
+       if(multisample_enabled)
+               glEnable(GL_MULTISAMPLE_ARB);
        
        ui_draw_links(block);
 }
        
        ui_draw_links(block);
 }
index 32e5532..6b5e779 100644 (file)
@@ -1226,6 +1226,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
 {
        RegionView3D *rv3d= ar->regiondata;
        struct Base *base = scene->basact;
 {
        RegionView3D *rv3d= ar->regiondata;
        struct Base *base = scene->basact;
+       int multisample_enabled;
        rcti winrct;
 
        BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
        rcti winrct;
 
        BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
@@ -1252,8 +1253,13 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
 
        if(v3d->drawtype > OB_WIRE) v3d->zbuf= TRUE;
        
 
        if(v3d->drawtype > OB_WIRE) v3d->zbuf= TRUE;
        
+       /* dithering and AA break color coding, so disable */
        glDisable(GL_DITHER);
 
        glDisable(GL_DITHER);
 
+       multisample_enabled= glIsEnabled(GL_MULTISAMPLE_ARB);
+       if(multisample_enabled)
+               glDisable(GL_MULTISAMPLE_ARB);
+
        region_scissor_winrct(ar, &winrct);
        glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin);
 
        region_scissor_winrct(ar, &winrct);
        glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin);
 
@@ -1272,9 +1278,8 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
        
        G.f |= G_BACKBUFSEL;
        
        
        G.f |= G_BACKBUFSEL;
        
-       if(base && (base->lay & v3d->lay)) {
+       if(base && (base->lay & v3d->lay))
                draw_object_backbufsel(scene, v3d, rv3d, base->object);
                draw_object_backbufsel(scene, v3d, rv3d, base->object);
-       }
 
        v3d->flag &= ~V3D_INVALID_BACKBUF;
        ar->swap= 0; /* mark invalid backbuf for wm draw */
 
        v3d->flag &= ~V3D_INVALID_BACKBUF;
        ar->swap= 0; /* mark invalid backbuf for wm draw */
@@ -1283,6 +1288,8 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
        v3d->zbuf= FALSE; 
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_DITHER);
        v3d->zbuf= FALSE; 
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_DITHER);
+       if(multisample_enabled)
+               glEnable(GL_MULTISAMPLE_ARB);
 
        if(rv3d->rflag & RV3D_CLIPPING)
                view3d_clr_clipping();
 
        if(rv3d->rflag & RV3D_CLIPPING)
                view3d_clr_clipping();