OpenGL anti-aliasing for 3D view, user selectable
authorDamien Plisson <damien.plisson@yahoo.fr>
Thu, 7 Jan 2010 10:32:48 +0000 (10:32 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Thu, 7 Jan 2010 10:32:48 +0000 (10:32 +0000)
Enables AA only for 3D view, and gives the user the option to turn it on/off (in system panel of user prefs)

release/scripts/ui/space_userpref.py
source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/intern/wm_window.c

index 46ebe3070ef0a355e42ef6c837f828c8356c61de..11e3a8e4fd9df7c2f5c47b43c75426cd415e83e9 100644 (file)
@@ -411,6 +411,7 @@ class USERPREF_PT_system(bpy.types.Panel):
         col.prop(system, "clip_alpha", slider=True)
         col.prop(system, "use_mipmaps")
         col.prop(system, "use_vbos")
+        col.prop(system, "use_antialiasing")
         col.label(text="Window Draw Method:")
         col.row().prop(system, "window_draw_method", expand=True)
         col.label(text="Textures:")
index bd196718c50c9a8475cd1a290bbb8f216df2a4f9..93eaace3cef57312d9ef2e75d1c2fae35c6429c6 100644 (file)
@@ -2040,6 +2040,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        Object *obact = OBACT;
        char *grid_unit= NULL;
        
+       /* enables anti-aliasing for 3D view drawing */
+       if (!(U.gameflags & USER_DISABLE_AA))
+               glEnable(GL_MULTISAMPLE_ARB);
+       
        /* from now on all object derived meshes check this */
        v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), scene, obact);
        
@@ -2222,6 +2226,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        /* XXX here was the blockhandlers for floating panels */
 
        v3d->flag |= V3D_INVALID_BACKBUF;
+       
+       /* Disable back anti-aliasing */
+       if (!(U.gameflags & USER_DISABLE_AA))
+               glDisable(GL_MULTISAMPLE_ARB);
 }
 
 
index a6be72561701000fb475d71d025d49397e03b0c5..cc33d556726309e20fa64d75868219503f567131 100644 (file)
@@ -468,6 +468,7 @@ extern UserDef U; /* from blenkernel blender.c */
 #define USER_DISABLE_SOUND             2
 #define USER_DISABLE_MIPMAP            4
 #define USER_DISABLE_VBO               8
+#define USER_DISABLE_AA                        16
 
 /* wm draw method */
 #define USER_DRAW_TRIPLE               0
index 9b314afeb08841209bb2770164e75adc22508497..c2871298dbdde5c124d5accfedb27de0ffd9c8f2 100644 (file)
@@ -2212,6 +2212,10 @@ static void rna_def_userdef_system(BlenderRNA *brna)
        RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_VBO);
        RNA_def_property_ui_text(prop, "VBOs", "Use Vertex Buffer Objects (or Vertex Arrays, if unsupported) for viewport rendering.");
 
+       prop= RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_AA);
+       RNA_def_property_ui_text(prop, "Anti-aliasing", "Use anti-aliasing for the 3D view (may impact redraw performance)");
+       
        prop= RNA_def_property(srna, "gl_texture_limit", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "glreslimit");
        RNA_def_property_enum_items(prop, gl_texture_clamp_items);
index 0e1d7969daf404eb22b6d0abe7de5baa91db5745..61e6063329a649dde118b79cb414d1b48f15cdb4 100644 (file)
@@ -313,7 +313,7 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow
                                                                 inital_state, 
                                                                 GHOST_kDrawingContextTypeOpenGL,
                                                                 0 /* no stereo */,
-                                                                0 /* no AA */);
+                                                                4 /* 4x AA */);
        
        if (ghostwin) {