[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10757] trunk/blender/source/blender: option to limit the size of textures loaded into GL memory, usefull when a scene's models wont fit into GFX memory.

Campbell Barton cbarton at metavr.com
Tue May 22 16:20:19 CEST 2007


Revision: 10757
          https://svn.blender.org//revision/?rev=10757&view=rev
Author:   campbellbarton
Date:     2007-05-22 16:20:18 +0200 (Tue, 22 May 2007)

Log Message:
-----------
option to limit the size of textures loaded into GL memory, usefull when a scene's models wont fit into GFX memory.

Modified Paths:
--------------
    trunk/blender/source/blender/include/blendef.h
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/src/drawmesh.c
    trunk/blender/source/blender/src/headerbuttons.c
    trunk/blender/source/blender/src/space.c

Modified: trunk/blender/source/blender/include/blendef.h
===================================================================
--- trunk/blender/source/blender/include/blendef.h	2007-05-22 10:58:30 UTC (rev 10756)
+++ trunk/blender/source/blender/include/blendef.h	2007-05-22 14:20:18 UTC (rev 10757)
@@ -171,6 +171,7 @@
 #define B_PLAINMENUS		66
 
 
+#define B_GLRESLIMITCHANGED		69
 #define B_SHOWSPLASH		70
 #define B_RESETAUTOSAVE		71
 #define B_SOUNDTOGGLE		72

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2007-05-22 10:58:30 UTC (rev 10756)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2007-05-22 14:20:18 UTC (rev 10757)
@@ -180,7 +180,8 @@
 	char verseuser[160];
 	short recent_files;		/* maximum number of recently used files to remember  */
 	short smooth_viewtx;	/* miliseconds to spend spinning the view */
-	char pad[6];
+	short glreslimit;
+	char pad[4];
 } UserDef;
 
 extern UserDef U; /* from usiblender.c !!!! */

Modified: trunk/blender/source/blender/src/drawmesh.c
===================================================================
--- trunk/blender/source/blender/src/drawmesh.c	2007-05-22 10:58:30 UTC (rev 10756)
+++ trunk/blender/source/blender/src/drawmesh.c	2007-05-22 14:20:18 UTC (rev 10757)
@@ -51,6 +51,7 @@
 #include "DNA_property_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_view3d_types.h"
+#include "DNA_userdef_types.h"
 
 #include "BKE_bmfont.h"
 #include "BKE_displist.h"
@@ -110,6 +111,18 @@
 	return num;	
 }
 
+/* These are used to enable texture clamping */
+static int is_pow2_limit(int num) {
+	if (U.glreslimit != 0 && num > U.glreslimit) return 0;
+	return ((num)&(num-1))==0;
+}
+
+static int smaller_pow2_limit(int num) {
+	if (U.glreslimit != 0 && num > U.glreslimit)
+		return U.glreslimit;
+	return smaller_pow2(num);
+}
+
 static int fCurtile=0, fCurmode=0,fCurtileXRep=0,fCurtileYRep=0;
 static Image *fCurpage=0;
 static short fTexwindx, fTexwindy, fTexwinsx, fTexwinsy;
@@ -371,9 +384,9 @@
 			rect= tilerect;
 		}
 #endif
-		if (!is_pow2(rectw) || !is_pow2(recth)) {
-			rectw= smaller_pow2(rectw);
-			recth= smaller_pow2(recth);
+		if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) {
+			rectw= smaller_pow2_limit(rectw);
+			recth= smaller_pow2_limit(recth);
 			
 			scalerect= MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect");
 			gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect);

Modified: trunk/blender/source/blender/src/headerbuttons.c
===================================================================
--- trunk/blender/source/blender/src/headerbuttons.c	2007-05-22 10:58:30 UTC (rev 10756)
+++ trunk/blender/source/blender/src/headerbuttons.c	2007-05-22 14:20:18 UTC (rev 10757)
@@ -1341,6 +1341,10 @@
 		set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
 		allqueue(REDRAWVIEW3D, 0);
 		break;
+	case B_GLRESLIMITCHANGED:
+		free_all_realtime_images(); /* force reloading with new res limit */
+		allqueue(REDRAWVIEW3D, 0);
+		break;
 	case B_NEWSPACE:
 		newspace(curarea, curarea->butspacetype);
 		break;

Modified: trunk/blender/source/blender/src/space.c
===================================================================
--- trunk/blender/source/blender/src/space.c	2007-05-22 10:58:30 UTC (rev 10756)
+++ trunk/blender/source/blender/src/space.c	2007-05-22 14:20:18 UTC (rev 10757)
@@ -3745,11 +3745,16 @@
 			&(U.uiflag), 0, 0, 0, 0, "Hide files/datablocks that start with a dot(.*)");
 
 		uiDefBut(block, LABEL,0,"OpenGL:",
-			(xpos+edgsp+(5*midsp)+(5*mpref)),y5label,mpref,buth,
+			(xpos+edgsp+(5*midsp)+(5*mpref)),y6label,mpref,buth,
 			0, 0, 0, 0, 0, "");
 		uiDefButBitI(block, TOGN, USER_DISABLE_MIPMAP, B_MIPMAPCHANGED, "Mipmaps",
-			(xpos+edgsp+(5*mpref)+(5*midsp)),y4,mpref,buth,
+			(xpos+edgsp+(5*mpref)+(5*midsp)),y5,mpref,buth,
 			&(U.gameflags), 0, 0, 0, 0, "Toggles between mipmap textures on (beautiful) and off (fast)");
+		
+		/* main choices pup: note, it uses collums, and the seperators (%l) then have to fill both halves equally for the menu to work */
+		uiDefButS(block, MENU, B_GLRESLIMITCHANGED, "GL Texture Clamp Off%x0|%l|GL Texture Clamp 8192%x8192|GL Texture Clamp 4096%x4096|GL Texture Clamp 2048%x2048|GL Texture Clamp 1024%x1024|GL Texture Clamp 512%x512|GL Texture Clamp 256%x256|GL Texture Clamp 128%x128",
+													(xpos+edgsp+(5*mpref)+(5*midsp)),y4,mpref,buth, &(U.glreslimit), 0, 0, 0, 0, "Limit the texture size to save graphics memory");
+		
 		uiDefButBitI(block, TOG, USER_VERTEX_ARRAYS, 0, "Vertex Arrays",
 			(xpos+edgsp+(5*mpref)+(5*midsp)),y3,mpref,buth,
 			&(U.gameflags), 0, 0, 0, 0, "Toggles between vertex arrays on (less reliable) and off (more reliable)");





More information about the Bf-blender-cvs mailing list