[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52069] trunk/blender: Added UI support to set OpenGL MultiSample.

Ton Roosendaal ton at blender.org
Sat Nov 10 12:55:53 CET 2012


Revision: 52069
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52069
Author:   ton
Date:     2012-11-10 11:55:45 +0000 (Sat, 10 Nov 2012)
Log Message:
-----------
Added UI support to set OpenGL MultiSample.

Code to support it was lying around for long already, but not controlled by UI nicely.
Now you have in user preferences "System" tab an option to set it. 

NOTE:
- it only works saving as User startup.blend, and restart Blender.
- your system should support it, no check for it is visible in UI
- tested only on iMac OSX 10.7

Screenshot:
http://www.blender.org/bf/chinchilla.blend.png

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c
    trunk/blender/source/blender/windowmanager/intern/wm_window.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2012-11-10 10:26:39 UTC (rev 52068)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2012-11-10 11:55:45 UTC (rev 52069)
@@ -446,6 +446,7 @@
         #~ col.prop(system, "use_antialiasing")
         col.label(text="Window Draw Method:")
         col.prop(system, "window_draw_method", text="")
+        col.prop(system, "ogl_multisamples", text="")
         col.label(text="Text Draw Options:")
         col.prop(system, "use_text_antialiasing")
         col.label(text="Textures:")

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2012-11-10 10:26:39 UTC (rev 52068)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2012-11-10 11:55:45 UTC (rev 52069)
@@ -2985,11 +2985,11 @@
 		v3d->zbuf = FALSE;
 
 	/* enables anti-aliasing for 3D view drawing */
-#if 0
-	if (!(U.gameflags & USER_DISABLE_AA))
-		glEnable(GL_MULTISAMPLE_ARB);
-#endif
+	if (U.ogl_multisamples)
+		if (!(U.gameflags & USER_DISABLE_AA))
+			glEnable(GL_MULTISAMPLE_ARB);
 
+
 	/* needs to be done always, gridview is adjusted in drawgrid() now */
 	rv3d->gridview = v3d->grid;
 
@@ -3101,12 +3101,12 @@
 
 	BIF_draw_manipulator(C);
 
-#if 0
 	/* Disable back anti-aliasing */
-	if (!(U.gameflags & USER_DISABLE_AA))
-		glDisable(GL_MULTISAMPLE_ARB);
-#endif
+	if (U.ogl_multisamples)
+		if (!(U.gameflags & USER_DISABLE_AA))
+			glDisable(GL_MULTISAMPLE_ARB);
 
+	
 	if (v3d->zbuf) {
 		v3d->zbuf = FALSE;
 		glDisable(GL_DEPTH_TEST);

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2012-11-10 10:26:39 UTC (rev 52068)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2012-11-10 11:55:45 UTC (rev 52069)
@@ -418,9 +418,11 @@
 
 	float ndof_sensitivity;	/* overall sensitivity of 3D mouse */
 	float ndof_orbit_sensitivity;
-	float pad4;
 	int ndof_flag;			/* flags for 3D mouse */
 
+	short ogl_multisamples;	/* amount of samples for OpenGL FSA, if zero no FSA */
+	short pad4;
+	
 	float glalphaclip;
 	
 	short autokey_mode;		/* autokeying mode */
@@ -703,6 +705,17 @@
 	USER_COMPUTE_DEVICE_CUDA	= 2,
 } eCompute_Device_Type;
 
+	
+typedef enum eMultiSample_Type {
+	USER_MULTISAMPLE_NONE	= 0,
+	USER_MULTISAMPLE_2	= 2,
+	USER_MULTISAMPLE_4	= 4,
+	USER_MULTISAMPLE_8	= 8,
+	USER_MULTISAMPLE_16	= 16,
+} eMultiSample_Type;
+	
+	
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-11-10 10:26:39 UTC (rev 52068)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-11-10 11:55:45 UTC (rev 52069)
@@ -3018,6 +3018,15 @@
 		{0, NULL, 0, NULL, NULL}
 	};
 	
+	static EnumPropertyItem multi_sample_levels[] = {
+		{USER_MULTISAMPLE_NONE, "MULTISAMPLE_NONE", 0, "No MultiSample", "Do not use OpenGL MultiSample"},
+		{USER_MULTISAMPLE_2, "MULTISAMPLE_2", 0, "MultiSample: 2", "Use 2x OpenGL MultiSample (requires restart)"},
+		{USER_MULTISAMPLE_4, "MULTISAMPLE_4", 0, "MultiSample: 4", "Use 4x OpenGL MultiSample (requires restart)"},
+		{USER_MULTISAMPLE_8, "MULTISAMPLE_8", 0, "MultiSample: 8", "Use 8x OpenGL MultiSample (requires restart)"},
+		{USER_MULTISAMPLE_16, "MULTISAMPLE_16", 0, "MultiSample: 16", "Use 16x OpenGL MultiSample (requires restart)"},
+		{0, NULL, 0, NULL, NULL}
+	};
+	
 #if 0
 	/* hardcoded here, could become dynamic somehow */
 	/* locale according to http://www.roseindia.net/tutorials/I18N/locales-list.shtml */
@@ -3312,6 +3321,12 @@
 	RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased");
 	RNA_def_property_update(prop, 0, "rna_userdef_text_update");
 	
+	/* Full scene anti-aliasing */
+	prop = RNA_def_property(srna, "ogl_multisamples", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_bitflag_sdna(prop, NULL, "ogl_multisamples");
+	RNA_def_property_enum_items(prop, multi_sample_levels);
+	RNA_def_property_ui_text(prop, "MultiSample", "Enable OpenGL multi-sampling, only for systems that support it, requires restart");
+
 #ifdef WITH_CYCLES
 	prop = RNA_def_property(srna, "compute_device_type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);
@@ -3441,7 +3456,7 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_SHOW_GUIDE);
 	RNA_def_property_ui_text(prop, "Show Navigation Guide", "Display the center and axis during rotation");
 	/* TODO: update description when fly-mode visuals are in place  ("projected position in fly mode")*/
-
+	
 	/* 3D view */
 	prop = RNA_def_property(srna, "ndof_view_rotate_method", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "ndof_flag");

Modified: trunk/blender/source/blender/windowmanager/intern/wm_window.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_window.c	2012-11-10 10:26:39 UTC (rev 52068)
+++ trunk/blender/source/blender/windowmanager/intern/wm_window.c	2012-11-10 11:55:45 UTC (rev 52069)
@@ -345,7 +345,7 @@
 	                              (GHOST_TWindowState)win->windowstate,
 	                              GHOST_kDrawingContextTypeOpenGL,
 	                              0 /* no stereo */,
-	                              0 /* no AA */);
+								  U.ogl_multisamples /* AA */);
 	
 	if (ghostwin) {
 		/* needed so we can detect the graphics card below */
@@ -373,7 +373,7 @@
 		
 		/* standard state vars for window */
 		glEnable(GL_SCISSOR_TEST);
-		
+		glEnable(GL_MULTISAMPLE_ARB);
 		GPU_state_init();
 	}
 }




More information about the Bf-blender-cvs mailing list