option to limit the size of textures loaded into GL memory, usefull when a scene's models wont fit into GFX memory.
This commit is contained in:
parent
bc2ad537ed
commit
26e60db6b5
@ -171,6 +171,7 @@
|
||||
#define B_PLAINMENUS 66
|
||||
|
||||
|
||||
#define B_GLRESLIMITCHANGED 69
|
||||
#define B_SHOWSPLASH 70
|
||||
#define B_RESETAUTOSAVE 71
|
||||
#define B_SOUNDTOGGLE 72
|
||||
|
@ -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 !!!! */
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)");
|
||||
|
Loading…
Reference in New Issue
Block a user