From 004827ea10051e4008d56996a72fa01dc3f62600 Mon Sep 17 00:00:00 2001 From: torcs-ng Date: Sat, 23 Feb 2013 13:56:49 +0000 Subject: [PATCH] add anisotropic filter in OpenGL options by Gaetan git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5180 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 88f3dd0c8ef41ee14b533a464c2c869a98932389 Former-commit-id: a8b73ed99ae093d683a0e49df967897b4e6a707f --- src/libs/tgfclient/glfeatures.cpp | 61 +++++++++++++++---- src/libs/tgfclient/glfeatures.h | 15 ++--- src/libs/tgfclient/guiscreen.cpp | 10 ++- src/libs/tgfclient/guiscreen.h | 6 ++ src/modules/graphic/ssggraph/grmain.cpp | 4 +- src/modules/graphic/ssggraph/grtexture.cpp | 44 ++++++++++++- .../legacymenu/confscreens/openglconfig.cpp | 55 ++++++++++++++++- 7 files changed, 168 insertions(+), 27 deletions(-) diff --git a/src/libs/tgfclient/glfeatures.cpp b/src/libs/tgfclient/glfeatures.cpp index 4a83d3641..8b7aa3181 100644 --- a/src/libs/tgfclient/glfeatures.cpp +++ b/src/libs/tgfclient/glfeatures.cpp @@ -177,11 +177,17 @@ void GfglFeatures::detectStandardSupport() && gfglIsOpenGLExtensionSupported("GL_ARB_imaging"); _mapSupportedBool[BumpMapping] = bValue; + + + // 10) Anisotropic filtrering + bValue = gfglIsOpenGLExtensionSupported("GL_EXT_texture_filter_anisotropic"); + _mapSupportedInt[AnisotropicFiltering] = bValue?2:InvalidInt; + } // Best supported features detection for the given specs of the frame buffer. bool GfglFeatures::detectBestSupport(int& nWidth, int& nHeight, int& nDepth, - bool& bAlpha, bool& bFullScreen, bool& bBumpMapping, bool& bStereoVision) + bool& bAlpha, bool& bFullScreen, bool& bBumpMapping, bool& bStereoVision, int &nAniFilt) { GfLogInfo("Detecting best supported features for a %dx%dx%d%s frame buffer.\n", nWidth, nHeight, nDepth, bFullScreen ? " full-screen" : ""); @@ -335,7 +341,7 @@ bool GfglFeatures::detectBestSupport(int& nWidth, int& nHeight, int& nDepth, } bool GfglFeatures::loadSupport(int &nWidth, int &nHeight, int &nDepth, - bool &bAlpha, bool &bFullScreen, bool &bBump, bool &bStereo, void* hparmConfig) + bool &bAlpha, bool &bFullScreen, bool &bBump, bool &bStereo, int &nAniFilt,void* hparmConfig) { // Clear support data. _mapSupportedBool.clear(); @@ -351,6 +357,8 @@ bool GfglFeatures::loadSupport(int &nWidth, int &nHeight, int &nDepth, (int)GfParmGetNum(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_WIN_Y, pszNoUnit, 0); nDepth = (int)GfParmGetNum(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_BPP, pszNoUnit, 0); + nAniFilt = + (int)GfParmGetNum(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_ANISOTROPICFILTERING, pszNoUnit, 0); bAlpha = std::string(GfParmGetStr(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_ALPHACHANNEL, GFSCR_VAL_NO)) == GFSCR_VAL_YES; @@ -473,10 +481,18 @@ bool GfglFeatures::loadSupport(int &nWidth, int &nHeight, int &nDepth, // 11) Bump Mapping. const std::string strBumpMapping = GfParmGetStr(hparm, GFSCR_SECT_GLDETFEATURES, GFSCR_ATT_BUMPMAPPING, ""); - if (strTexComp == GFSCR_VAL_YES) + if (strTexComp == GFSCR_VAL_YES) //strTexComp ? Bug ? _mapSupportedBool[BumpMapping] = true; else if (strTexComp == GFSCR_VAL_NO) _mapSupportedBool[BumpMapping] = false; + + // 11) Anisotropic Filtering. + const int nAF = + (int)GfParmGetNum(hparm, GFSCR_SECT_GLDETFEATURES, GFSCR_ATT_ANISOTROPICFILTERING, + pszNoUnit, (tdble)0); + if (nMaxTexSize > 0) + _mapSupportedInt[AnisotropicFiltering] =nAF; + // Close config file if we open it. if (!hparmConfig) @@ -489,7 +505,7 @@ bool GfglFeatures::loadSupport(int &nWidth, int &nHeight, int &nDepth, } void GfglFeatures::storeSupport(int nWidth, int nHeight, int nDepth, - bool bAlpha, bool bFullScreen, bool bBump, bool bStereo, void* hparmConfig) + bool bAlpha, bool bFullScreen, bool bBump, bool bStereo, int nAniFilt, void* hparmConfig) { // Open the config file if not already done. void* hparm = hparmConfig ? hparmConfig : openConfigFile(); @@ -514,7 +530,9 @@ void GfglFeatures::storeSupport(int nWidth, int nHeight, int nDepth, (tdble)nHeight); GfParmSetNum(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_BPP, pszNoUnit, (tdble)nDepth); - GfParmSetStr(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_ALPHACHANNEL, + GfParmSetNum(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_ANISOTROPICFILTERING, pszNoUnit, + (tdble)nAniFilt); + GfParmSetStr(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_ALPHACHANNEL, bAlpha ? GFSCR_VAL_YES : GFSCR_VAL_NO); GfParmSetStr(hparm, GFSCR_SECT_GLDETSPECS, GFSCR_ATT_FSCR, bFullScreen ? GFSCR_VAL_YES : GFSCR_VAL_NO); @@ -588,6 +606,13 @@ void GfglFeatures::storeSupport(int nWidth, int nHeight, int nDepth, GfParmSetStr(hparm, GFSCR_SECT_GLDETFEATURES, GFSCR_ATT_BUMPMAPPING, isSupported(BumpMapping) ? GFSCR_VAL_YES : GFSCR_VAL_NO); + // 12) Aniso Filtering + if (getSupported(AnisotropicFiltering) != InvalidInt) + GfParmSetNum(hparm, GFSCR_SECT_GLDETFEATURES, GFSCR_ATT_ANISOTROPICFILTERING, pszNoUnit, + (tdble)getSupported(AnisotropicFiltering)); + else + GfParmRemove(hparm, GFSCR_SECT_GLDETFEATURES, GFSCR_ATT_ANISOTROPICFILTERING); + } // Write new params to config file. @@ -602,23 +627,23 @@ void GfglFeatures::storeSupport(int nWidth, int nHeight, int nDepth, } bool GfglFeatures::checkBestSupport(int nWidth, int nHeight, int nDepth, - bool bAlpha, bool bFullScreen, bool bBump, bool bStereo, void* hparmConfig) + bool bAlpha, bool bFullScreen, bool bBump, bool bStereo,int nAniFilt, void* hparmConfig) { // Open the config file if not already done. void* hparm = hparmConfig ? hparmConfig : openConfigFile(); // Get the frame buffer specs that are associated with the detected // Open GL features in the config file, if any. - int nDetWidth, nDetHeight, nDetDepth; + int nDetWidth, nDetHeight, nDetDepth, nDetAni; bool bDetFullScreen, bDetAlpha, bDetBump, bDetStereo; bool bPrevSupportFound = - loadSupport(nDetWidth, nDetHeight, nDetDepth, bDetAlpha, bDetFullScreen, bDetBump, bDetStereo, hparm); + loadSupport(nDetWidth, nDetHeight, nDetDepth, bDetAlpha, bDetFullScreen, bDetBump, bDetStereo,nDetAni, hparm); // Compare with the requested frame buffer specs // and run a new supported feature detection if any diffference. bool bSupportFound = true; if (!bPrevSupportFound || nWidth != nDetWidth || nHeight != nDetHeight || nDepth != nDetDepth - || bAlpha != bDetAlpha || bFullScreen != bDetFullScreen || bStereo != bDetStereo || bBump != bDetBump) + || bAlpha != bDetAlpha || bFullScreen != bDetFullScreen || bStereo != bDetStereo || bBump != bDetBump || nAniFilt!= nDetAni) { nDetWidth = nWidth; nDetHeight = nHeight; @@ -627,11 +652,12 @@ bool GfglFeatures::checkBestSupport(int nWidth, int nHeight, int nDepth, bDetAlpha = bAlpha; bDetStereo = bStereo; bDetBump = bBump; + nDetAni = nAniFilt; bSupportFound = - detectBestSupport(nDetWidth, nDetHeight, nDetDepth, bDetAlpha, bDetFullScreen, bDetBump, bDetStereo); + detectBestSupport(nDetWidth, nDetHeight, nDetDepth, bDetAlpha, bDetFullScreen, bDetBump, bDetStereo, nDetAni); // Store support data in any case. - storeSupport(nDetWidth, nDetHeight, nDetDepth, bDetAlpha, bDetFullScreen, bDetBump, bDetStereo, hparm); + storeSupport(nDetWidth, nDetHeight, nDetDepth, bDetAlpha, bDetFullScreen, bDetBump, bDetStereo,nDetAni, hparm); // If frame buffer specs supported, update relevant user settings and restart. if (bSupportFound) @@ -724,6 +750,8 @@ void GfglFeatures::dumpSupport() const isSupported(StereoVision) ? "Yes" : "No"); GfLogInfo(" Bump Mapping : %s\n", isSupported(BumpMapping) ? "Yes" : "No"); + GfLogInfo(" Anisotropic Filtering : %d\n", + getSupported(AnisotropicFiltering)); } // Load the selected OpenGL features from the config file. @@ -809,6 +837,9 @@ void GfglFeatures::loadSelection(void* hparmConfig) GFSCR_ATT_BUMPMAPPING_ENABLED)) == GFSCR_ATT_BUMPMAPPING_ENABLED; + // 12) Anisotropic Filtering : load from config file. + _mapSelectedInt[AnisotropicFiltering] = (int)GfParmGetNum(hparm, GFSCR_SECT_GLSELFEATURES, GFSCR_ATT_ANISOTROPICFILTERING, + pszNoUnit, (tdble)getSupported(AnisotropicFiltering)); // Close config file if we open it. if (!hparmConfig) closeConfigFile(hparm); @@ -880,6 +911,12 @@ void GfglFeatures::storeSelection(void* hparmConfig) const GfParmSetStr(hparm, GFSCR_SECT_GLSELFEATURES, GFSCR_ATT_BUMPMAPPING, isSelected(BumpMapping) ? GFSCR_ATT_BUMPMAPPING_ENABLED : GFSCR_ATT_BUMPMAPPING_DISABLED); + + if (getSupported(AnisotropicFiltering) != InvalidInt) + GfParmSetNum(hparm, GFSCR_SECT_GLSELFEATURES, GFSCR_ATT_ANISOTROPICFILTERING, pszNoUnit, + (tdble)getSelected(AnisotropicFiltering)); + else + GfParmRemove(hparm, GFSCR_SECT_GLSELFEATURES, GFSCR_ATT_ANISOTROPICFILTERING); // Write new params to config file. GfParmWriteFile(NULL, hparm, "Screen"); @@ -919,6 +956,8 @@ void GfglFeatures::dumpSelection() const GfLogInfo("\n"); GfLogInfo(" Stereo vision : %s\n", isSelected(StereoVision) ? "On" : "Off"); GfLogInfo(" Bump Mapping : %s\n", isSelected(BumpMapping) ? "On" : "Off"); + GfLogInfo(" Anisotropic Filtering : %d\n", + getSupported(AnisotropicFiltering)); } // Bool features management. diff --git a/src/libs/tgfclient/glfeatures.h b/src/libs/tgfclient/glfeatures.h index ac6c95ab0..c8de0197e 100644 --- a/src/libs/tgfclient/glfeatures.h +++ b/src/libs/tgfclient/glfeatures.h @@ -66,7 +66,7 @@ class TGFCLIENT_API GfglFeatures // Check best supported OpenGL features, and store report to the config file // (default = GFSCR_CONF_FILE). May restart the game. bool checkBestSupport(int nWidth, int nHeight, int nDepth, - bool bAlpha, bool bFullScreen, bool bBump, bool bStereo, void* hparmConfig = 0); + bool bAlpha, bool bFullScreen, bool bBump, bool bStereo,int nAniFilt, void* hparmConfig = 0); // Detect standard supported features. Don't restart the game. // Precondiftion: SDL_setVideoMode(...) @@ -99,7 +99,7 @@ class TGFCLIENT_API GfglFeatures TextureNonPowerOf2, // GL_ARB_texture_non_power_of_two, in case mipmapping needed. MultiTexturing, // GL_ARB_multitexture MultiSampling, // GL_ARB_multisample - BumpMapping, // Bump Mapping + BumpMapping, // Bump Mapping StereoVision // StereoVision }; void select(EFeatureBool eFeature, bool bSelected); @@ -113,7 +113,8 @@ class TGFCLIENT_API GfglFeatures ColorDepth, AlphaDepth, TextureMaxSize, MultiTexturingUnits, - MultiSamplingSamples + MultiSamplingSamples, + AnisotropicFiltering }; void select(EFeatureInt eFeature, int nSelectedValue); int getSelected(EFeatureInt eFeature) const; @@ -128,14 +129,14 @@ class TGFCLIENT_API GfglFeatures GfglFeatures(); // Update supported OpenGL features according to the given frame buffer specs. - bool detectBestSupport(int& nWidth, int& nHeight, int& nDepth, - bool& bAlpha, bool& bBump, bool& bStereo, bool& bFullScreen); + bool detectBestSupport(int& nWidth, int& nHeight, int& nDepth, + bool& bAlpha, bool& bBump, bool& bStereo, bool& bFullScreen, int& nAniFilt); bool loadSupport(int &nWidth, int &nHeight, int &nDepth, - bool &bAlpha, bool &bFullScreen, bool &bBump, bool &bStereo, void* hparmConfig = 0); + bool &bAlpha, bool &bFullScreen, bool &bBump, bool &bStereo, int &nAniFilt, void* hparmConfig = 0); void storeSupport(int nWidth, int nHeight, int nDepth, - bool bAlpha, bool bFullScreen, bool bBump, bool bStereo, void* hparmConfig = 0); + bool bAlpha, bool bFullScreen, bool bBump, bool bStereo,int nAniFilt, void* hparmConfig = 0); static void* openConfigFile(); static void closeConfigFile(void* hparmConfig, bool bWrite = false); diff --git a/src/libs/tgfclient/guiscreen.cpp b/src/libs/tgfclient/guiscreen.cpp index b4ebd97c7..122e70dbe 100644 --- a/src/libs/tgfclient/guiscreen.cpp +++ b/src/libs/tgfclient/guiscreen.cpp @@ -439,6 +439,12 @@ bool GfScrInit(int nWinWidth, int nWinHeight, int nFullScreen) std::string(GfParmGetStr(hparmScreen, pszScrPropSec, GFSCR_ATT_BUMPMAPPING, GFSCR_VAL_NO)) == GFSCR_VAL_YES; + + int nAniFilt = + (int)GfParmGetNum(hparmScreen, pszScrPropSec, GFSCR_ATT_ANISOTROPICFILTERING, (char*)NULL, 0); + + + bool bStereo = std::string(GfParmGetStr(hparmScreen, pszScrPropSec, GFSCR_ATT_STEREOVISION, GFSCR_VAL_NO)) @@ -463,7 +469,7 @@ bool GfScrInit(int nWinWidth, int nWinHeight, int nFullScreen) // Warning: Restarts the game if the frame buffer specs changed since last call. // If specified and possible, setup the best possible settings. if (GfglFeatures::self().checkBestSupport(nWinWidth, nWinHeight, nTotalDepth, - bAlphaChannel, bFullScreen, bBumpMap, bStereo, hparmScreen)) + bAlphaChannel, bFullScreen, bBumpMap, bStereo,nAniFilt,hparmScreen)) { // Load Open GL user settings from the config file. GfglFeatures::self().loadSelection(); @@ -815,4 +821,4 @@ int GfScrCaptureAsPNG(const char *filename) GfLogError("Failed to capture screen to %s\n", filename); return nStatus; -} \ No newline at end of file +} diff --git a/src/libs/tgfclient/guiscreen.h b/src/libs/tgfclient/guiscreen.h index 0d8cf0c4a..4b453e1fc 100644 --- a/src/libs/tgfclient/guiscreen.h +++ b/src/libs/tgfclient/guiscreen.h @@ -140,6 +140,12 @@ #define GFSCR_ATT_STEREOVISION_ENABLED "enabled" #define GFSCR_ATT_STEREOVISION_DISABLED "disabled" +#define GFSCR_ATT_ANISOTROPICFILTERING "anisotropic filtering" +#define GFSCR_ATT_ANISOTROPICFILTERING_HIGH "high" +#define GFSCR_ATT_ANISOTROPICFILTERING_MEDIUM "medium" +#define GFSCR_ATT_ANISOTROPICFILTERING_DISABLED "disabled" + + #define GFSCR_ATT_MULTISAMPLINGSAMPLES "multi-sampling samples" // Open GL auto-detected features diff --git a/src/modules/graphic/ssggraph/grmain.cpp b/src/modules/graphic/ssggraph/grmain.cpp index 1eee8cb63..941963b30 100644 --- a/src/modules/graphic/ssggraph/grmain.cpp +++ b/src/modules/graphic/ssggraph/grmain.cpp @@ -93,8 +93,8 @@ static void setupOpenGLFeatures(void) // Don't do it twice. if (bInitialized) return; - - // Multi-texturing. + + // Multi-texturing. grMaxTextureUnits = 1; if (GfglFeatures::self().isSelected(GfglFeatures::MultiTexturing)) { diff --git a/src/modules/graphic/ssggraph/grtexture.cpp b/src/modules/graphic/ssggraph/grtexture.cpp index 57c530250..86a2fbcae 100644 --- a/src/modules/graphic/ssggraph/grtexture.cpp +++ b/src/modules/graphic/ssggraph/grtexture.cpp @@ -109,6 +109,8 @@ cgrMultiTexState* cgrStateFactory::getMultiTexState(cgrMultiTexState::tfnTexSche */ + + // SGI texture loading function. bool grLoadSGI(const char *fname, ssgTextureInfo* info) { @@ -222,6 +224,8 @@ cgrSGIHeader::cgrSGIHeader(const char *fname, ssgTextureInfo* info) bool grMakeMipMaps (GLubyte *image, int xsize, int ysize, int zsize, int mipmap) { + + if (!((xsize & (xsize-1))==0) || !((ysize & (ysize-1))==0)) { ulSetError ( UL_WARNING, "Map is not a power-of-two in size!" ) ; return false ; @@ -380,6 +384,7 @@ bool grMakeMipMaps (GLubyte *image, int xsize, int ysize, int zsize, int mipmap) GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *) texels[i] ) ; + /*int compressed; glGetTexLevelParameteriv(GL_TEXTURE_2D, map_level, GL_TEXTURE_COMPRESSED_ARB, &compressed); if (compressed == GL_TRUE) { @@ -398,6 +403,32 @@ bool grMakeMipMaps (GLubyte *image, int xsize, int ysize, int zsize, int mipmap) return true; } +void doAnisotropicFiltering(){ + int aniS; + float aniD; + + if(GfglFeatures::self().getSupported(GfglFeatures::AnisotropicFiltering)!=GfglFeatures::InvalidInt) + { + aniS = GfglFeatures::self().getSelected(GfglFeatures::AnisotropicFiltering); + + GLfloat fLargest; + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest); + + if(aniS ==1) + { + aniD = fLargest/2; + } + if(aniS==2) + { + aniD = fLargest; + } + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniD);/**/ + + + } +} + bool grLoadPngTexture (const char *fname, ssgTextureInfo* info) { GLubyte *tex; @@ -435,7 +466,11 @@ bool grLoadPngTexture (const char *fname, ssgTextureInfo* info) // tex = tex2; // #endif // WIN32 - return grMakeMipMaps(tex, w, h, 4, mipmap) == TRUE ? true : false; + bool res = grMakeMipMaps(tex, w, h, 4, mipmap) == TRUE ? true : false; + + doAnisotropicFiltering(); + + return res; } bool grLoadJpegTexture (const char *fname, ssgTextureInfo* info) @@ -462,5 +497,10 @@ bool grLoadJpegTexture (const char *fname, ssgTextureInfo* info) mipmap = doMipMap(fname, mipmap); - return grMakeMipMaps(tex, w, h, 4, mipmap) == TRUE ? true : false; + + bool res = grMakeMipMaps(tex, w, h, 4, mipmap) == TRUE ? true : false; + + doAnisotropicFiltering(); + + return res; } diff --git a/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp b/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp index 0ed937db2..84facca12 100644 --- a/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp +++ b/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp @@ -76,6 +76,18 @@ static int MultiTextureLabelId; static int MultiTextureLeftButtonId; static int MultiTextureRightButtonId; +//Anisotropic-filtering +static const char *AAnisotropicFilteringTexts[] = + {GFSCR_ATT_ANISOTROPICFILTERING_DISABLED, GFSCR_ATT_ANISOTROPICFILTERING_MEDIUM,GFSCR_ATT_ANISOTROPICFILTERING_HIGH}; +static const int NAnisotropicFiltering = + sizeof(AAnisotropicFilteringTexts) / sizeof(AAnisotropicFilteringTexts[0]); +static int NCurAnisotropicFilteringIndex = 0; + +static int AnisotropicFilteringLabelId; +static int AnisotropicFilteringLeftButtonId; +static int AnisotropicFilteringRightButtonId; + + // Multi-sampling (initialized in OpenGLMenuInit). static std::vector VecMultiSampleTexts; static int NMultiSamples = 0; @@ -113,6 +125,9 @@ static void onAccept(void *) GfglFeatures::self().select(GfglFeatures::BumpMapping, strcmp(ABumpMappingTexts[NCurBumpMappingIndex], GFSCR_ATT_BUMPMAPPING_ENABLED) ? false : true); + + GfglFeatures::self().select(GfglFeatures::AnisotropicFiltering, NCurAnisotropicFilteringIndex); + // Store settings from the GL features layer to the screen.xml file. GfglFeatures::self().storeSelection(); @@ -121,7 +136,7 @@ static void onAccept(void *) // But actually restart the game if the multi-sampling feature settings changed // (we can't change this without re-initializing the video mode). - if (GfglFeatures::self().isSelected(GfglFeatures::MultiSampling) != BMultiSamplingWasSelected + if (GfglFeatures::self().isSelected(GfglFeatures::MultiSampling) != BMultiSamplingWasSelected || GfglFeatures::self().getSelected(GfglFeatures::MultiSamplingSamples) != BPrevMultiSamplingSamples) { // Shutdown the user interface. @@ -129,7 +144,7 @@ static void onAccept(void *) // Restart the game. GfuiApp().restart(); - } + } } // Toggle texture compression state enabled/disabled. @@ -174,13 +189,20 @@ static void changeMaxTextureSizeState(void *vp) GfuiLabelSetText(ScrHandle, MaxTextureSizeLabelId, valuebuf); } -// Toggle texture compression state enabled/disabled. +// Toggle bumpmapping state enabled/disabled. static void changeBumpMappingState(void *vp) { NCurBumpMappingIndex = (NCurBumpMappingIndex + (int)(long)vp + NBumpMapping) % NBumpMapping; GfuiLabelSetText(ScrHandle, BumpMappingLabelId, ABumpMappingTexts[NCurBumpMappingIndex]); } +// Toggle anisotropic filtering state enabled/disabled. +static void changeAnisotropicFilteringState(void *vp) +{ + NCurAnisotropicFilteringIndex = (NCurAnisotropicFilteringIndex + (int)(long)vp + NAnisotropicFiltering) % NAnisotropicFiltering; + GfuiLabelSetText(ScrHandle, AnisotropicFilteringLabelId, AAnisotropicFilteringTexts[NCurAnisotropicFilteringIndex]); +} + static void onActivate(void * /* dummy */) { @@ -342,6 +364,23 @@ static void onActivate(void * /* dummy */) GfuiEnable(ScrHandle, BumpMappingRightButtonId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, BumpMappingLabelId, "Not supported"); } + + // Initialize current state and GUI from the GL features layer. + // 7) Anisotropic Filtering. + int ani_sup= GfglFeatures::self().getSupported(GfglFeatures::AnisotropicFiltering); + if (ani_sup!=GfglFeatures::InvalidInt) + { + NCurAnisotropicFilteringIndex = + GfglFeatures::self().getSelected(GfglFeatures::AnisotropicFiltering); + GfuiLabelSetText(ScrHandle, AnisotropicFilteringLabelId, + AAnisotropicFilteringTexts[NCurAnisotropicFilteringIndex]); + } + else + { + GfuiEnable(ScrHandle, AnisotropicFilteringLeftButtonId, GFUI_DISABLE); + GfuiEnable(ScrHandle, AnisotropicFilteringRightButtonId, GFUI_DISABLE); + GfuiLabelSetText(ScrHandle, AnisotropicFilteringLabelId, "Not supported"); + } } // OpenGL menu @@ -400,6 +439,16 @@ void* OpenGLMenuInit(void *prevMenu) changeBumpMappingState); BumpMappingLabelId = GfuiMenuCreateLabelControl(ScrHandle,hparmMenu,"BumpMappingLabel"); + // Anisotropic Filtering. + AnisotropicFilteringLeftButtonId = + GfuiMenuCreateButtonControl(ScrHandle, hparmMenu, "AnisotropicFilteringLeftArrowButton", (void*)-1, + changeAnisotropicFilteringState); + AnisotropicFilteringRightButtonId = + GfuiMenuCreateButtonControl(ScrHandle, hparmMenu, "AnisotropicFilteringRightArrowButton", (void*)+1, + changeAnisotropicFilteringState); + AnisotropicFilteringLabelId = GfuiMenuCreateLabelControl(ScrHandle,hparmMenu,"AnisotropicFilteringLabel"); + + GfuiMenuCreateButtonControl(ScrHandle,hparmMenu,"ApplyButton",NULL, onAccept); GfuiMenuCreateButtonControl(ScrHandle,hparmMenu,"CancelButton",prevMenu, GfuiScreenActivate);