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");
25 me.have_s3tc = GL_Have_TextureCompression();
27 float texmemsize(float s3tc)
31 2500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_other")))
32 + 1500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_world")))
33 ) * ((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
35 void XonoticPicmipSlider_autofix(entity me)
37 float max_hard, max_soft;
38 if(cvar("menu_picmip_bypass"))
40 max_hard = cvar("sys_memsize_virtual");
41 max_soft = cvar("sys_memsize_physical");
44 while(me.value > 0 && texmemsize(me.have_s3tc) > max_hard)
45 me.setValue(me, me.value - 1);
47 // TODO also check the soft limit!
48 // TODO better handling than clamping the slider!
50 void XonoticPicmipSlider_draw(entity me)
53 SUPER(XonoticPicmipSlider).draw(me);