From 9d9370e13c69f385eb724556f38256e8ee269c59 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Thu, 4 Oct 2007 21:29:16 +0000 Subject: [PATCH] * Make anti-aliassing of text optional (for slower systems); it's turned on by default though (option "textantialiassing") git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2529 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/ivis_common/textdraw.h | 11 +++++++++++ lib/ivis_opengl/textdraw.c | 32 +++++++++++++++++++++++++------- src/configuration.c | 13 +++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/lib/ivis_common/textdraw.h b/lib/ivis_common/textdraw.h index 99604435e..dff45f809 100644 --- a/lib/ivis_common/textdraw.h +++ b/lib/ivis_common/textdraw.h @@ -47,6 +47,17 @@ extern unsigned int iV_GetCharWidth(uint32_t charCode); extern unsigned int iV_GetTextHeight(const char* string); extern void iV_SetTextColour(SWORD Index); +/** Enable or disable anti-aliasing of text + * \param enable set this to true to enable anti-aliassing of text, + * set it to false to disable it. + */ +extern void iV_SetTextAntialias(bool enable); + +/** Find out if anti-aliasing of text is enabled or disabled + * \return true if anti-aliassing of text is enabled, false otherwise + */ +extern bool iV_TextAntialiased(void); + #define ASCII_SPACE (32) #define ASCII_NEWLINE ('@') #define ASCII_COLOURMODE ('#') diff --git a/lib/ivis_opengl/textdraw.c b/lib/ivis_opengl/textdraw.c index 41631d170..fcac6dddf 100644 --- a/lib/ivis_opengl/textdraw.c +++ b/lib/ivis_opengl/textdraw.c @@ -45,6 +45,8 @@ static GLint GLC_Context = 0; static GLint GLC_Font_Regular = 0; static GLint GLC_Font_Bold = 0; +static bool anti_aliasing = true; + /***************************************************************************/ /* * Source @@ -145,6 +147,16 @@ void iV_TextShutdown() glcDeleteContext(GLC_Context); } +void iV_SetTextAntialias(bool enable) +{ + anti_aliasing = enable; +} + +bool iV_TextAntialiased() +{ + return anti_aliasing; +} + void iV_SetFont(enum iV_fonts FontID) { switch (FontID) @@ -573,10 +585,13 @@ void iV_DrawTextRotated(const char* string, float XPos, float YPos, float rotati { pie_SetTexturePage(-2); - // Enable Anti Aliasing - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glEnable(GL_POLYGON_SMOOTH); + // Enable Anti Aliasing if it's enabled + if (anti_aliasing) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glEnable(GL_POLYGON_SMOOTH); + } if (rotation != 0.f) rotation = 360.f - rotation; @@ -592,9 +607,12 @@ void iV_DrawTextRotated(const char* string, float XPos, float YPos, float rotati glcRenderString(string); glFrontFace(GL_CCW); - // Turn off anti aliasing - glDisable(GL_BLEND); - glDisable(GL_POLYGON_SMOOTH); + // Turn off anti aliasing (if we enabled it above) + if (anti_aliasing) + { + glDisable(GL_BLEND); + glDisable(GL_POLYGON_SMOOTH); + } // Reset the current model view matrix glLoadIdentity(); diff --git a/src/configuration.c b/src/configuration.c index 8ee312482..c3424f3ce 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -33,6 +33,7 @@ #include "lib/sound/track.h" // audio #include "lib/sound/cdaudio.h" // audio #include "lib/ivis_common/piestate.h" // setgamma. +#include "lib/ivis_common/textdraw.h" // text-antialiassing #include "warzoneconfig.h" // renderMode #include "component.h" #include "text.h" @@ -516,6 +517,16 @@ BOOL loadConfig(void) setWarzoneKeyNumeric("radarTerrainMode", radarDrawMode); } + if (getWarzoneKeyNumeric("text-antialiassing", &val)) + { + iV_SetTextAntialias(val); + } + else + { + iV_SetTextAntialias(true); + setWarzoneKeyNumeric("text-antialiassing", true); + } + return closeWarzoneKey(); } @@ -622,6 +633,8 @@ BOOL saveConfig(void) setWarzoneKeyString("phrase4", ingame.phrases[4]); } + setWarzoneKeyNumeric("text-antialiassing", iV_TextAntialiased()); + return closeWarzoneKey(); }