From b3c221caf108f71e9d247191c14918c730bd6ece Mon Sep 17 00:00:00 2001 From: torcs-ng Date: Sun, 4 Oct 2015 01:04:51 +0000 Subject: [PATCH] - Moved Graphic Engine selector (ssggraph/OsgGraph) in OpenGL config menu git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6158 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 9b6578a210450f95efd06aec0d97543f2854a1f8 Former-commit-id: f102e79f750aa97a757fb3aeaa63e2204b9279a9 --- src/drivers/CMakeLists.txt | 4 +- .../legacymenu/confscreens/openglconfig.cpp | 71 ++++++++++++++++++- .../legacymenu/confscreens/simuconfig.cpp | 54 -------------- 3 files changed, 73 insertions(+), 56 deletions(-) diff --git a/src/drivers/CMakeLists.txt b/src/drivers/CMakeLists.txt index de5e1351..8878d530 100644 --- a/src/drivers/CMakeLists.txt +++ b/src/drivers/CMakeLists.txt @@ -14,7 +14,9 @@ IF(NOT OPTION_OFFICIAL_ONLY) # Work-in-progress. SD_ADD_SUBDIRECTORY(shadow) - SD_ADD_SUBDIRECTORY(replay) + IF(OPTION_3RDPARTY_SQLITE3) + SD_ADD_SUBDIRECTORY(replay) + ENDIF() # Obsolete (as robot samples). #SD_ADD_SUBDIRECTORY(bt) diff --git a/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp b/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp index 84facca1..0c568f94 100644 --- a/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp +++ b/src/modules/userinterface/legacymenu/confscreens/openglconfig.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "legacymenu.h" #include "openglconfig.h" @@ -87,6 +88,13 @@ static int AnisotropicFilteringLabelId; static int AnisotropicFilteringLeftButtonId; static int AnisotropicFilteringRightButtonId; +/* list of available graphic engine */ +static const int DefaultGraphicVersion = 1; +static const char *GraphicSchemeList[] = {RM_VAL_MOD_SSGRAPH, RM_VAL_MOD_OSGGRAPH}; +static const char *GraphicDispNameList[] = {"ssggraph", "OsgGraph"}; +static const int NbGraphicScheme = sizeof(GraphicSchemeList) / sizeof(GraphicSchemeList[0]); +static int CurGraphicScheme = DefaultGraphicVersion; + // Multi-sampling (initialized in OpenGLMenuInit). static std::vector VecMultiSampleTexts; @@ -97,6 +105,8 @@ static int MultiSampleLabelId; static int MultiSampleLeftButtonId; static int MultiSampleRightButtonId; +static int GraphicSchemeId; + // GUI screen handles. static void *ScrHandle = NULL; static void *PrevHandle = NULL; @@ -130,7 +140,15 @@ static void onAccept(void *) // Store settings from the GL features layer to the screen.xml file. GfglFeatures::self().storeSelection(); - + + char buf[1024]; + snprintf(buf, sizeof(buf), "%s%s", GfLocalDir(), RACE_ENG_CFG); + void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT); + + GfParmSetStr(paramHandle, RM_SECT_MODULES, RM_ATTR_MOD_GRAPHIC, GraphicSchemeList[CurGraphicScheme]); + GfParmWriteFile(NULL, paramHandle, "raceengine"); + GfParmReleaseHandle(paramHandle); + // Return to previous screen. GfuiScreenActivate(PrevHandle); @@ -203,6 +221,28 @@ static void changeAnisotropicFilteringState(void *vp) GfuiLabelSetText(ScrHandle, AnisotropicFilteringLabelId, AAnisotropicFilteringTexts[NCurAnisotropicFilteringIndex]); } +/* Change the graphc engine version (but only show really available modules) */ +static void +onChangeGraphicVersion(void *vp) +{ + char buf[1024]; + + if (!vp) + return; + + const int oldGraphicVersion = CurGraphicScheme; + do + { + CurGraphicScheme = (CurGraphicScheme + NbGraphicScheme + (int)(long)vp) % NbGraphicScheme; + + snprintf(buf, sizeof(buf), "%smodules/graphic/%s.%s", GfLibDir(), GraphicSchemeList[CurGraphicScheme], DLLEXT); + } + while (!GfFileExists(buf) && CurGraphicScheme != oldGraphicVersion); + + GfuiLabelSetText(ScrHandle, GraphicSchemeId, GraphicDispNameList[CurGraphicScheme]); +} + + static void onActivate(void * /* dummy */) { @@ -381,11 +421,14 @@ static void onActivate(void * /* dummy */) GfuiEnable(ScrHandle, AnisotropicFilteringRightButtonId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, AnisotropicFilteringLabelId, "Not supported"); } + + GfuiLabelSetText(ScrHandle, GraphicSchemeId, GraphicDispNameList[CurGraphicScheme]); } // OpenGL menu void* OpenGLMenuInit(void *prevMenu) { + const char *graphicSchemeName; // Has screen already been created? if (ScrHandle) return ScrHandle; @@ -395,6 +438,27 @@ void* OpenGLMenuInit(void *prevMenu) ScrHandle = GfuiScreenCreate((float*)NULL, NULL, onActivate, NULL, (tfuiCallback)NULL, 1); void *hparmMenu = GfuiMenuLoad("opengloptionsmenu.xml"); GfuiMenuCreateStaticControls(ScrHandle, hparmMenu); + + //Initialize current Graphic Engine + // ssggraph / OsgGraph + char buf[1024]; + snprintf(buf, sizeof(buf), "%s%s", GfLocalDir(), RACE_ENG_CFG); + + void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT); + + // graphic engine + graphicSchemeName = GfParmGetStr(paramHandle, RM_SECT_MODULES, RM_ATTR_MOD_GRAPHIC, GraphicSchemeList[1]); + for (int i = 0; i < NbGraphicScheme; i++) + { + if (strcmp(graphicSchemeName, GraphicSchemeList[i]) == 0) + { + CurGraphicScheme = i; + break; + } + } + + GfParmWriteFile(NULL, paramHandle, "raceengine"); + GfParmReleaseHandle(paramHandle); // Texture compression. TextureCompLeftButtonId = @@ -448,6 +512,11 @@ void* OpenGLMenuInit(void *prevMenu) changeAnisotropicFilteringState); AnisotropicFilteringLabelId = GfuiMenuCreateLabelControl(ScrHandle,hparmMenu,"AnisotropicFilteringLabel"); + GraphicSchemeId = GfuiMenuCreateLabelControl(ScrHandle, hparmMenu, "graphiclabel"); +#ifndef OFFICIAL_ONLY + GfuiMenuCreateButtonControl(ScrHandle, hparmMenu, "graphicleftarrow", (void*)-1, onChangeGraphicVersion); + GfuiMenuCreateButtonControl(ScrHandle, hparmMenu, "graphicrightarrow", (void*)1, onChangeGraphicVersion); +#endif GfuiMenuCreateButtonControl(ScrHandle,hparmMenu,"ApplyButton",NULL, onAccept); GfuiMenuCreateButtonControl(ScrHandle,hparmMenu,"CancelButton",prevMenu, GfuiScreenActivate); diff --git a/src/modules/userinterface/legacymenu/confscreens/simuconfig.cpp b/src/modules/userinterface/legacymenu/confscreens/simuconfig.cpp index 5642bb78..92488f99 100644 --- a/src/modules/userinterface/legacymenu/confscreens/simuconfig.cpp +++ b/src/modules/userinterface/legacymenu/confscreens/simuconfig.cpp @@ -74,13 +74,6 @@ static const char *CooldownSchemeList[] = {RM_VAL_ON, RM_VAL_OFF}; static const int NbCooldownSchemes = sizeof(CooldownSchemeList) / sizeof(CooldownSchemeList[0]); static int CurCooldownScheme = 0; // On -/* list of available graphic engine */ -static const int DefaultGraphicVersion = 1; -static const char *GraphicSchemeList[] = {RM_VAL_MOD_SSGRAPH, RM_VAL_MOD_OSGGRAPH}; -static const char *GraphicDispNameList[] = {"ssggraph", "OsgGraph"}; -static const int NbGraphicScheme = sizeof(GraphicSchemeList) / sizeof(GraphicSchemeList[0]); -static int CurGraphicScheme = DefaultGraphicVersion; - /* gui label ids */ static int SimuVersionId; static int MultiThreadSchemeId; @@ -91,8 +84,6 @@ static int StartPausedSchemeId; static int CooldownSchemeId; -static int GraphicSchemeId; - /* gui screen handles */ static void *ScrHandle = NULL; static void *PrevScrHandle = NULL; @@ -106,7 +97,6 @@ static void loadSimuCfg(void) const char *replayRateSchemeName; const char *startPausedSchemeName; const char *cooldownSchemeName; - const char *graphicSchemeName; int i; @@ -194,17 +184,6 @@ static void loadSimuCfg(void) } } - // graphic engine - graphicSchemeName = GfParmGetStr(paramHandle, RM_SECT_MODULES, RM_ATTR_MOD_GRAPHIC, GraphicSchemeList[1]); - for (i = 0; i < NbGraphicScheme; i++) - { - if (strcmp(graphicSchemeName, GraphicSchemeList[i]) == 0) - { - CurGraphicScheme = i; - break; - } - } - GfParmReleaseHandle(paramHandle); GfuiLabelSetText(ScrHandle, SimuVersionId, SimuVersionDispNameList[CurSimuVersion]); @@ -217,11 +196,6 @@ static void loadSimuCfg(void) #endif GfuiLabelSetText(ScrHandle, StartPausedSchemeId, StartPausedSchemeList[CurStartPausedScheme]); GfuiLabelSetText(ScrHandle, CooldownSchemeId, CooldownSchemeList[CurCooldownScheme]); - GfuiLabelSetText(ScrHandle, GraphicSchemeId, GraphicSchemeList[CurGraphicScheme]); - -#ifdef OFFICIAL_ONLY - GfuiEnable(ScrHandle, GraphicSchemeId, GFUI_DISABLE); -#endif } @@ -238,7 +212,6 @@ static void storeSimuCfg(void * /* dummy */) GfParmSetStr(paramHandle, RM_SECT_RACE_ENGINE, RM_ATTR_REPLAY_RATE, ReplaySchemeList[CurReplayScheme]); GfParmSetStr(paramHandle, RM_SECT_RACE_ENGINE, RM_ATTR_STARTPAUSED, StartPausedSchemeList[CurStartPausedScheme]); GfParmSetStr(paramHandle, RM_SECT_RACE_ENGINE, RM_ATTR_COOLDOWN, CooldownSchemeList[CurCooldownScheme]); - GfParmSetStr(paramHandle, RM_SECT_MODULES, RM_ATTR_MOD_GRAPHIC, GraphicSchemeList[CurGraphicScheme]); GfParmWriteFile(NULL, paramHandle, "raceengine"); GfParmReleaseHandle(paramHandle); @@ -268,27 +241,6 @@ onChangeSimuVersion(void *vp) GfuiLabelSetText(ScrHandle, SimuVersionId, SimuVersionDispNameList[CurSimuVersion]); } -/* Change the graphc engine version (but only show really available modules) */ -static void -onChangeGraphicVersion(void *vp) -{ - char buf[1024]; - - if (!vp) - return; - - const int oldGraphicVersion = CurGraphicScheme; - do - { - CurGraphicScheme = (CurGraphicScheme + NbGraphicScheme + (int)(long)vp) % NbGraphicScheme; - - snprintf(buf, sizeof(buf), "%smodules/graphic/%s.%s", GfLibDir(), GraphicSchemeList[CurGraphicScheme], DLLEXT); - } - while (!GfFileExists(buf) && CurGraphicScheme != oldGraphicVersion); - - GfuiLabelSetText(ScrHandle, GraphicSchemeId, GraphicDispNameList[CurGraphicScheme]); -} - /* Change the multi-threading scheme */ static void onChangeMultiThreadScheme(void *vp) @@ -393,12 +345,6 @@ SimuMenuInit(void *prevMenu) GfuiMenuCreateButtonControl(ScrHandle, menuDescHdle, "cooldownleftarrow", (void*)-1, onChangeCooldownScheme); GfuiMenuCreateButtonControl(ScrHandle, menuDescHdle, "cooldownrightarrow", (void*)1, onChangeCooldownScheme); - GraphicSchemeId = GfuiMenuCreateLabelControl(ScrHandle, menuDescHdle, "graphiclabel"); -#ifndef OFFICIAL_ONLY - GfuiMenuCreateButtonControl(ScrHandle, menuDescHdle, "graphicleftarrow", (void*)-1, onChangeGraphicVersion); - GfuiMenuCreateButtonControl(ScrHandle, menuDescHdle, "graphicrightarrow", (void*)1, onChangeGraphicVersion); -#endif - GfuiMenuCreateButtonControl(ScrHandle, menuDescHdle, "ApplyButton", PrevScrHandle, storeSimuCfg); GfuiMenuCreateButtonControl(ScrHandle, menuDescHdle, "CancelButton", PrevScrHandle, GfuiScreenActivate);