diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-05-22 18:20:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-05-22 18:20:18 +0400 |
commit | 26e60db6b519883e022dcd8b6749cfb11f00cd25 (patch) | |
tree | 91b0ff768f5917f2711e1ce9f50348abd97ebb7b /source/blender/src/drawmesh.c | |
parent | bc2ad537ed582ae866b7d3d2277165af8ebd3fd5 (diff) |
option to limit the size of textures loaded into GL memory, usefull when a scene's models wont fit into GFX memory.
Diffstat (limited to 'source/blender/src/drawmesh.c')
-rw-r--r-- | source/blender/src/drawmesh.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c index 9fa5068410b..88ca6a54b49 100644 --- a/source/blender/src/drawmesh.c +++ b/source/blender/src/drawmesh.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); |