1
0
forked from mirrors/0ad

Set force_s3tc_enable automatically for greater chance of compressed texture support on Linux (see #575).

This was SVN commit r8356.
This commit is contained in:
Ykkrosh
2010-10-15 00:06:48 +00:00
parent 8edd28c43c
commit a1a7264aec
4 changed files with 28 additions and 3 deletions
+4
View File
@@ -36,6 +36,10 @@ noautomipmap = true
novbo = false
noframebufferobject = false
; Linux only: Set the driconf force_s3tc_enable option at startup,
; for compressed texture support
force_s3tc_enable = true
; Specify the render path. This can be one of:
; default Automatically select one of the below, depending on system capabilities
; fixed Only use OpenGL fixed function pipeline
+2 -2
View File
@@ -496,8 +496,8 @@ static void InitPs(bool setup_gui, const CStrW& gui_page)
g_GUI->DisplayMessageBox(600, 270, L"Warning",
L"Your graphics drivers do not support S3TC compressed textures. This may reduce performance.\n\n"
#if !(OS_WIN || OS_MACOSX)
L"To fix this, run the program \"driconf\" and enable the force_s3tc_enable option (\"Enable S3TC texture compression\"). "
L"(If this causes rendering errors, you may have to disable the option again.)"
L"To fix this, you may have to install the \"libtxc_dxtn\" library. "
L"See http://dri.freedesktop.org/wiki/S3TC for more information."
#else
L"Please try updating your graphics drivers to ensure you have full hardware acceleration."
#endif
+21 -1
View File
@@ -43,7 +43,7 @@ CVideoMode g_VideoMode;
CVideoMode::CVideoMode() :
m_IsInitialised(false),
m_PreferredW(0), m_PreferredH(0), m_PreferredBPP(0), m_PreferredFreq(0),
m_ConfigW(0), m_ConfigH(0), m_ConfigBPP(0), m_ConfigFullscreen(false),
m_ConfigW(0), m_ConfigH(0), m_ConfigBPP(0), m_ConfigFullscreen(false), m_ConfigForceS3TCEnable(true),
m_WindowedW(DEFAULT_WINDOW_W), m_WindowedH(DEFAULT_WINDOW_H)
{
// (m_ConfigFullscreen defaults to false, so users don't get stuck if
@@ -59,6 +59,7 @@ void CVideoMode::ReadConfig()
CFG_GET_USER_VAL("xres", Int, m_ConfigW);
CFG_GET_USER_VAL("yres", Int, m_ConfigH);
CFG_GET_USER_VAL("bpp", Int, m_ConfigBPP);
CFG_GET_USER_VAL("force_s3tc_enable", Bool, m_ConfigForceS3TCEnable);
}
bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
@@ -115,6 +116,25 @@ bool CVideoMode::InitSDL()
ReadConfig();
// On Linux we have to try hard to get S3TC compressed texture support.
// If the extension is already provided by default, that's fine.
// Otherwise we should enable the 'force_s3tc_enable' environment variable
// and (re)initialise the video system, so that Mesa provides the extension
// (if the driver at least supports decompression).
// (This overrides the force_s3tc_enable specified via driconf files.)
// Otherwise we should complain to the user, and stop using compressed textures.
//
// Setting the environment variable causes Mesa to print an ugly message to stderr
// ("ATTENTION: default value of option force_s3tc_enable overridden by environment."),
// so it'd be nicer to skip that if S3TC will be supported by default,
// but reinitialising video is a pain (and it might do weird things when fullscreen)
// so we just unconditionally set it (unless our config file explicitly disables it).
#if !(OS_WIN || OS_MACOSX) // (assume Mesa is used for all non-Windows non-Mac platforms)
if (m_ConfigForceS3TCEnable)
setenv("force_s3tc_enable", "true", 0);
#endif
// preferred video mode = current desktop settings
// (command line params may override these)
gfx_get_video_mode(&m_PreferredW, &m_PreferredH, &m_PreferredBPP, &m_PreferredFreq);
+1
View File
@@ -72,6 +72,7 @@ private:
int m_ConfigH;
int m_ConfigBPP;
bool m_ConfigFullscreen;
bool m_ConfigForceS3TCEnable;
// If we're fullscreen, size of window when we were last windowed (or the default window size
// if we started fullscreen), to support switching back to the old window size