1 #ifndef SLIDER_PICMIP_H
2 #define SLIDER_PICMIP_H
3 #include "textslider.qc"
4 CLASS(XonoticPicmipSlider, XonoticTextSlider)
5 METHOD(XonoticPicmipSlider, configureXonoticPicmipSlider, void(entity));
6 METHOD(XonoticPicmipSlider, draw, void(entity));
7 METHOD(XonoticPicmipSlider, autofix, void(entity));
8 ATTRIB(XonoticPicmipSlider, have_s3tc, float, 0)
9 ENDCLASS(XonoticPicmipSlider)
10 entity makeXonoticPicmipSlider(); // note: you still need to call addValue and configureXonoticTextSliderValues!
14 entity makeXonoticPicmipSlider()
17 me = NEW(XonoticPicmipSlider);
18 me.configureXonoticPicmipSlider(me);
21 void XonoticPicmipSlider_configureXonoticPicmipSlider(entity me)
23 me.configureXonoticTextSlider(me, "gl_picmip",
24 _("Change the sharpness of the textures. Lowering it will effectively reduce texture memory usage, but make the textures appear very blurry. (default: good)"));
26 me.have_s3tc = GL_Have_TextureCompression();
28 float texmemsize(float s3tc)
32 2500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_other")))
33 + 1500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_world")))
34 ) * ((s3tc && (cvar("r_texture_dds_load") || cvar("gl_texturecompression"))) ? 0.2 : 1.0); // TC: normalmaps 50%, other 25%, few incompressible, guessing 40% as conservative average
36 void XonoticPicmipSlider_autofix(entity me)
38 float max_hard, max_soft;
39 if(cvar("menu_picmip_bypass"))
41 max_hard = cvar("sys_memsize_virtual");
42 max_soft = cvar("sys_memsize_physical");
45 while(me.value > 0 && texmemsize(me.have_s3tc) > max_hard)
46 me.setValue(me, me.value - 1);
48 // TODO also check the soft limit!
49 // TODO better handling than clamping the slider!
51 void XonoticPicmipSlider_draw(entity me)
54 SUPER(XonoticPicmipSlider).draw(me);