2 CLASS(XonoticPicmipSlider) EXTENDS(XonoticTextSlider)
3 METHOD(XonoticPicmipSlider, configureXonoticPicmipSlider, void(entity))
4 METHOD(XonoticPicmipSlider, draw, void(entity))
5 METHOD(XonoticPicmipSlider, autofix, void(entity))
6 ATTRIB(XonoticPicmipSlider, have_s3tc, float, 0)
7 ENDCLASS(XonoticPicmipSlider)
8 entity makeXonoticPicmipSlider(); // note: you still need to call addValue and configureXonoticTextSliderValues!
12 entity makeXonoticPicmipSlider()
15 me = spawnXonoticPicmipSlider();
16 me.configureXonoticPicmipSlider(me);
19 void XonoticPicmipSlider_configureXonoticPicmipSlider(entity me)
21 me.configureXonoticTextSlider(me, "gl_picmip");
23 me.have_s3tc = GL_Have_TextureCompression();
25 float texmemsize(float s3tc)
29 2500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_other")))
30 + 1500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_world")))
31 ) * ((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
33 void XonoticPicmipSlider_autofix(entity me)
35 float max_hard, max_soft;
36 if(cvar("menu_picmip_bypass"))
38 max_hard = cvar("sys_memsize_virtual");
39 max_soft = cvar("sys_memsize_physical");
42 while(me.value > 0 && texmemsize(me.have_s3tc) > max_hard)
43 me.setValue(me, me.value - 1);
45 // TODO also check the soft limit!
46 // TODO better handling than clamping the slider!
48 void XonoticPicmipSlider_draw(entity me)
51 SUPER(XonoticPicmipSlider).draw(me);