METHOD(XonoticPicmipSlider, configureXonoticPicmipSlider, void(entity))
METHOD(XonoticPicmipSlider, draw, void(entity))
METHOD(XonoticPicmipSlider, autofix, void(entity))
+ ATTRIB(XonoticPicmipSlider, have_s3tc, float, 0)
ENDCLASS(XonoticPicmipSlider)
entity makeXonoticPicmipSlider(); // note: you still need to call addValue and configureXonoticTextSliderValues!
#endif
{
me.configureXonoticTextSlider(me, "gl_picmip");
me.autofix(me);
+ me.have_s3tc = GL_Have_TextureCompression();
}
-float texmemsize()
+float texmemsize(float s3tc)
{
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
+ ) * (s3tc && ((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_autofix(entity me)
{
max_soft = cvar("sys_memsize_physical");
if(max_hard > 0)
{
- while(me.value > 0 && texmemsize() > max_hard)
+ while(me.value > 0 && texmemsize(me.have_s3tc) > max_hard)
me.setValue(me, me.value - 1);
}
// TODO also check the soft limit!
+float GL_CheckExtension(string ext)
+{
+ return (strstrofs(strcat(" ", cvar_string("gl_info_extensions"), " "), strcat(" ", ext, " "), 0) >= 0);
+}
+
+float GL_Have_TextureCompression()
+{
+ return (GL_CheckExtension("GL_EXT_texture_compression_s3tc") && GL_CheckExtension("GL_ARB_texture_compression"));
+}
+
float tooltipdb;
void loadTooltips()
{
{
float fh;
float have_dds, have_jpg, have_tga;
+ float can_dds;
if((have_dds = ((fh = fopen("dds/particles/particlefont.dds", FILE_READ)) >= 0)))
fclose(fh);
if((have_jpg = ((fh = fopen("particles/particlefont.jpg", FILE_READ)) >= 0)))
fclose(fh);
if((have_tga = ((fh = fopen("particles/particlefont.tga", FILE_READ)) >= 0)))
fclose(fh);
+ can_dds = GL_Have_TextureCompression();
if(have_dds && (have_jpg || have_tga))
{
// both? Let's only use good quality precompressed files
- cvar_set("gl_texturecompression", "0");
- return 1;
+ // but ONLY if we actually support it!
+ if(can_dds)
+ {
+ cvar_set("gl_texturecompression", "0");
+ return 1;
+ }
+ else
+ {
+ cvar_set("gl_texturecompression", "0");
+ cvar_set("r_texture_dds_load", "0");
+ return 0;
+ }
}
else if(have_dds)
{
// DDS only? We probably always want texture compression
cvar_set("gl_texturecompression", "1");
cvar_set("r_texture_dds_load", "1");
+ if(!can_dds)
+ print("^1ERROR: Texture compression is required but not supported.\n^1Expect visual problems.\n");
return 0;
}
else
{
// TGA only? Allow runtime compression
- cvar_set("gl_texturecompression", cvar_string("r_texture_dds_load"));
- return 2;
+ if(can_dds)
+ {
+ cvar_set("gl_texturecompression", cvar_string("r_texture_dds_load"));
+ return 2;
+ }
+ else
+ {
+ cvar_set("gl_texturecompression", "0");
+ cvar_set("r_texture_dds_load", "0");
+ return 0;
+ }
}
}
+float GL_CheckExtension(string ext);
+float GL_Have_TextureCompression();
+
void forAllDescendants(entity root, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass);
void saveAllCvars(entity root);
void loadAllCvars(entity root);