option to limit the size of textures loaded into GL memory, usefull when a scene...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 22 May 2007 14:20:18 +0000 (14:20 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 22 May 2007 14:20:18 +0000 (14:20 +0000)
source/blender/include/blendef.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/src/drawmesh.c
source/blender/src/headerbuttons.c
source/blender/src/space.c

index 70c16fd5df91638ba0ca599a526570089ca1b22a..44833b66576a8960f04afd6d70b8eced7163201f 100644 (file)
 #define B_PLAINMENUS           66
 
 
+#define B_GLRESLIMITCHANGED            69
 #define B_SHOWSPLASH           70
 #define B_RESETAUTOSAVE                71
 #define B_SOUNDTOGGLE          72
index 6d2f9411ebfe514db972d6863c6a2548008de4c9..27c9bc16e4a18cca1250ab3fb517304b9eb8d41e 100644 (file)
@@ -180,7 +180,8 @@ typedef struct UserDef {
        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 !!!! */
index 9fa5068410b59bf201f7ae27afc15cda026f1f13..88ca6a54b4928644c16c1dd74d2221826771bd57 100644 (file)
@@ -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 @@ static int smaller_pow2(int num) {
        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 @@ int set_tpage(MTFace *tface)
                        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);
index f079294c81aa47249840e0121c3f02fd077ff519..7685ec99b2e52a45adc0abd58dd4d2c126df8bf8 100644 (file)
@@ -1341,6 +1341,10 @@ void do_global_buttons(unsigned short event)
                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;
index 8025f11c55cad2ce8d56265f45bea97bd933601c..a528fd260ff0a1aebed0021389747acaffd611f3 100644 (file)
@@ -3745,11 +3745,16 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        &(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)");