1 #ifndef SLIDER_PICMIP_H
2 #define SLIDER_PICMIP_H
3 CLASS(XonoticPicmipSlider, XonoticTextSlider)
4 METHOD(XonoticPicmipSlider, configureXonoticPicmipSlider, void(entity))
5 METHOD(XonoticPicmipSlider, draw, void(entity))
6 METHOD(XonoticPicmipSlider, autofix, void(entity))
7 ATTRIB(XonoticPicmipSlider, have_s3tc, float, 0)
8 ENDCLASS(XonoticPicmipSlider)
9 entity makeXonoticPicmipSlider(); // note: you still need to call addValue and configureXonoticTextSliderValues!
13 entity makeXonoticPicmipSlider()
16 me = NEW(XonoticPicmipSlider);
17 me.configureXonoticPicmipSlider(me);
20 void XonoticPicmipSlider_configureXonoticPicmipSlider(entity me)
22 me.configureXonoticTextSlider(me, "gl_picmip");
24 me.have_s3tc = GL_Have_TextureCompression();
26 float texmemsize(float s3tc)
30 2500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_other")))
31 + 1500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_world")))
32 ) * ((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
34 void XonoticPicmipSlider_autofix(entity me)
36 float max_hard, max_soft;
37 if(cvar("menu_picmip_bypass"))
39 max_hard = cvar("sys_memsize_virtual");
40 max_soft = cvar("sys_memsize_physical");
43 while(me.value > 0 && texmemsize(me.have_s3tc) > max_hard)
44 me.setValue(me, me.value - 1);
46 // TODO also check the soft limit!
47 // TODO better handling than clamping the slider!
49 void XonoticPicmipSlider_draw(entity me)
52 SUPER(XonoticPicmipSlider).draw(me);