]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
add a file I forgot (can do that with git too)
authorRudolf Polzer <divVerent@alientrap.org>
Fri, 10 Sep 2010 12:16:08 +0000 (14:16 +0200)
committerRudolf Polzer <divVerent@alientrap.org>
Fri, 10 Sep 2010 12:16:08 +0000 (14:16 +0200)
qcsrc/menu/xonotic/slider_picmip.c [new file with mode: 0644]

diff --git a/qcsrc/menu/xonotic/slider_picmip.c b/qcsrc/menu/xonotic/slider_picmip.c
new file mode 100644 (file)
index 0000000..7529878
--- /dev/null
@@ -0,0 +1,43 @@
+#ifdef INTERFACE
+CLASS(XonoticPicmipSlider) EXTENDS(XonoticTextSlider)
+       METHOD(XonoticPicmipSlider, configureXonoticPicmipSlider, void(entity))
+       METHOD(XonoticPicmipSlider, draw, void(entity))
+ENDCLASS(XonoticPicmipSlider)
+entity makeXonoticPicmipSlider(); // note: you still need to call addValue and configureXonoticTextSliderValues!
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeXonoticPicmipSlider()
+{
+       entity me;
+       me = spawnXonoticPicmipSlider();
+       me.configureXonoticPicmipSlider(me);
+       return me;
+}
+void XonoticPicmipSlider_configureXonoticPicmipSlider(entity me)
+{
+       me.configureXonoticTextSlider(me, "gl_picmip");
+}
+float texmemsize()
+{
+       return
+       (
+                 2500 * pow(0.5, max(0, cvar("gl_picmip") + cvar("gl_picmip_other")))
+               + 1500 * pow(0.5, max(0, cvar("gl_picmip") + cvar("gl_picmip_world")))
+       ) * ((cvar("r_texture_dds_load") || cvar("gl_texturecompression")) ? 0.4 : 1.0); // TC: normalmaps 50%, other 25%, few incompressible, guessing 40% as conservative average
+}
+void XonoticPicmipSlider_draw(entity me)
+{
+       float max_hard, max_soft;
+       max_hard = cvar("sys_memsize_virtual");
+       max_soft = cvar("sys_memsize_physical");
+       if(max_hard > 0)
+       {
+               while(me.value > 0 && texmemsize() > max_hard)
+                       me.setValue(me, me.value - 1);
+       }
+       // TODO also check the soft limit!
+       // TODO better handling than clamping the slider!
+       SUPER(XonoticPicmipSlider).draw(me);
+}
+#endif