mirror of
https://github.com/glest/glest-source.git
synced 2025-08-08 09:26:27 +02:00
- added ability to check if compiler supports SSE and if not fallback to X87 for streflop.
- added ability for clients to specify gamma override value for drivers which support it
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
include(CheckFunctionExists)
|
||||
include(AddFileDependencies)
|
||||
|
||||
macro(special_add_library lib)
|
||||
if (WIN32)
|
||||
add_library(${lib} STATIC ${ARGN})
|
||||
else (WIN32)
|
||||
add_library(${lib} SHARED ${ARGN})
|
||||
endif (WIN32)
|
||||
endmacro(special_add_library)
|
||||
#macro(special_add_library lib)
|
||||
# if (WIN32)
|
||||
# add_library(${lib} STATIC ${ARGN})
|
||||
# else (WIN32)
|
||||
# add_library(${lib} SHARED ${ARGN})
|
||||
# endif (WIN32)
|
||||
#endmacro(special_add_library)
|
||||
|
||||
macro(special_check_for_sse _max_sse_level_desired)
|
||||
set(${_max_sse_level_desired})
|
||||
@@ -78,6 +78,9 @@ macro(special_check_for_sse _max_sse_level_desired)
|
||||
set(SSE_FLAGS "-msse -mfpmath=sse")
|
||||
message(STATUS "Found SSE extensions, using flags: ${SSE_FLAGS}")
|
||||
endif()
|
||||
|
||||
add_definitions(${SSE_FLAGS})
|
||||
|
||||
elseif(MSVC)
|
||||
check_cxx_source_runs("
|
||||
#include <emmintrin.h>
|
||||
@@ -96,6 +99,8 @@ macro(special_check_for_sse _max_sse_level_desired)
|
||||
message(STATUS "Found SSE2 extensions")
|
||||
set(SSE_FLAGS "/arch:SSE2 /fp:fast -D__SSE__ -D__SSE2__" )
|
||||
endif()
|
||||
|
||||
add_definitions(${SSE_FLAGS})
|
||||
endif()
|
||||
endmacro(special_check_for_sse)
|
||||
|
||||
|
@@ -212,7 +212,7 @@ void fatal(const char *s, ...) // failure exit
|
||||
if(SDL_WasInit(SDL_INIT_VIDEO)) {
|
||||
SDL_ShowCursor(1);
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
SDL_SetGamma(1, 1, 1);
|
||||
//SDL_SetGamma(1, 1, 1);
|
||||
}
|
||||
#ifdef WIN32
|
||||
LPWSTR wstr = Ansi2WideString(errText.c_str());
|
||||
@@ -2802,6 +2802,29 @@ int glestMain(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SET_GAMMA]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SET_GAMMA]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SET_GAMMA]),&foundParamIndIndex);
|
||||
}
|
||||
string paramValue = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(paramValue,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
string settings = paramPartTokens[1];
|
||||
printf("Forcing gamma [%s]\n",settings.c_str());
|
||||
|
||||
float newGammaValue = strToFloat(settings);
|
||||
config.setFloat("GammaValue",newGammaValue);
|
||||
}
|
||||
else {
|
||||
printf("\nInvalid missing gamma setting specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
//printParameterHelp(argv[0],false);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Set some statics based on ini entries
|
||||
SystemFlags::ENABLE_THREADED_LOGGING = config.getBool("ThreadedLogging","true");
|
||||
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
||||
|
@@ -609,7 +609,12 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
window->initGl(config.getInt("ColorBits"), config.getInt("DepthBits"), config.getInt("StencilBits"),config.getBool("HardwareAcceleration","false"),config.getBool("FullScreenAntiAliasing","false"));
|
||||
window->initGl(config.getInt("ColorBits"),
|
||||
config.getInt("DepthBits"),
|
||||
config.getInt("StencilBits"),
|
||||
config.getBool("HardwareAcceleration","false"),
|
||||
config.getBool("FullScreenAntiAliasing","false"),
|
||||
config.getFloat("GammaValue","0.0"));
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -742,7 +747,12 @@ void Program::resetSoundSystem() {
|
||||
void Program::reInitGl() {
|
||||
if(window != NULL) {
|
||||
Config &config= Config::getInstance();
|
||||
window->initGl(config.getInt("ColorBits"), config.getInt("DepthBits"), config.getInt("StencilBits"),config.getBool("HardwareAcceleration","false"),config.getBool("FullScreenAntiAliasing","false"));
|
||||
window->initGl(config.getInt("ColorBits"),
|
||||
config.getInt("DepthBits"),
|
||||
config.getInt("StencilBits"),
|
||||
config.getBool("HardwareAcceleration","false"),
|
||||
config.getBool("FullScreenAntiAliasing","false"),
|
||||
config.getFloat("GammaValue","0.0"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -348,9 +348,9 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
|
||||
ENDIF()
|
||||
|
||||
# FIXME: hackish...
|
||||
IF(WANT_STREFLOP)
|
||||
SET(STREFLOP_PROPERTIES "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32")
|
||||
ENDIF()
|
||||
# IF(WANT_STREFLOP)
|
||||
# SET(STREFLOP_PROPERTIES "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32")
|
||||
# ENDIF()
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(${MG_SOURCE_FILES} PROPERTIES COMPILE_FLAGS
|
||||
"${PLATFORM_SPECIFIC_DEFINES} ${STREFLOP_PROPERTIES} ${CXXFLAGS}")
|
||||
|
@@ -31,6 +31,7 @@ protected:
|
||||
uint32 stencilBits;
|
||||
int8 hardware_acceleration;
|
||||
int8 fullscreen_anti_aliasing;
|
||||
float gammaValue;
|
||||
|
||||
public:
|
||||
Context();
|
||||
@@ -41,12 +42,14 @@ public:
|
||||
uint32 getStencilBits() const {return stencilBits;}
|
||||
int8 getHardware_acceleration() const { return hardware_acceleration; }
|
||||
int8 getFullscreen_anti_aliasing() const { return fullscreen_anti_aliasing; }
|
||||
float getGammaValue() const { return gammaValue; }
|
||||
|
||||
void setColorBits(uint32 colorBits) {this->colorBits= colorBits;}
|
||||
void setDepthBits(uint32 depthBits) {this->depthBits= depthBits;}
|
||||
void setStencilBits(uint32 stencilBits) {this->stencilBits= stencilBits;}
|
||||
void setHardware_acceleration(int8 value) { hardware_acceleration = value; }
|
||||
void setFullscreen_anti_aliasing(int8 value) { fullscreen_anti_aliasing = value; }
|
||||
void setGammaValue(float value) { gammaValue = value; }
|
||||
|
||||
virtual void init()= 0;
|
||||
virtual void end()= 0;
|
||||
|
@@ -51,7 +51,9 @@ public:
|
||||
PlatformContextGl();
|
||||
virtual ~PlatformContextGl();
|
||||
|
||||
virtual void init(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing);
|
||||
virtual void init(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration, bool fullscreen_anti_aliasing,
|
||||
float gammaValue);
|
||||
virtual void end();
|
||||
|
||||
virtual void makeCurrent();
|
||||
|
@@ -64,6 +64,7 @@ const char *GAME_ARGS[] = {
|
||||
"--colorbits",
|
||||
"--depthbits",
|
||||
"--fullscreen",
|
||||
"--set-gamma",
|
||||
|
||||
"--use-font",
|
||||
"--font-basesize",
|
||||
@@ -115,10 +116,13 @@ enum GAME_ARG_TYPE {
|
||||
GAME_ARG_USE_COLORBITS,
|
||||
GAME_ARG_USE_DEPTHBITS,
|
||||
GAME_ARG_USE_FULLSCREEN,
|
||||
GAME_ARG_SET_GAMMA,
|
||||
|
||||
GAME_ARG_USE_FONT,
|
||||
GAME_ARG_FONT_BASESIZE,
|
||||
GAME_ARG_VERBOSE_MODE
|
||||
GAME_ARG_VERBOSE_MODE,
|
||||
|
||||
GAME_ARG_END
|
||||
};
|
||||
|
||||
void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
||||
@@ -323,6 +327,10 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
||||
printf("\n \t\tWhere x either true or false");
|
||||
printf("\n \t\texample: %s %s=true",extractFileFromDirectoryPath(argv0).c_str(),GAME_ARGS[GAME_ARG_USE_FULLSCREEN]);
|
||||
|
||||
printf("\n%s=x\t\t\toverride the video gamma (contrast) value.",GAME_ARGS[GAME_ARG_SET_GAMMA]);
|
||||
printf("\n \t\tWhere x a floating point value");
|
||||
printf("\n \t\texample: %s %s=1.5",extractFileFromDirectoryPath(argv0).c_str(),GAME_ARGS[GAME_ARG_SET_GAMMA]);
|
||||
|
||||
printf("\n%s=x\t\t\toverride the font to use.",GAME_ARGS[GAME_ARG_USE_FONT]);
|
||||
printf("\n \t\tWhere x is the path and name of a font file supported");
|
||||
printf("\n \t\t by freetype2.");
|
||||
@@ -365,6 +373,13 @@ bool hasCommandArgument(int argc, char** argv,const string argName, int *foundIn
|
||||
int mainSetup(int argc, char **argv) {
|
||||
bool haveSpecialOutputCommandLineOption = false;
|
||||
|
||||
const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]);
|
||||
if(knownArgCount != GAME_ARG_END) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"Internal arg count mismatch knownArgCount = %d, GAME_ARG_END = %d",knownArgCount,GAME_ARG_END);
|
||||
throw runtime_error("");
|
||||
}
|
||||
|
||||
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true ||
|
||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true ||
|
||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true ||
|
||||
|
@@ -29,7 +29,9 @@ private:
|
||||
ContextGl context;
|
||||
|
||||
public:
|
||||
void initGl(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing);
|
||||
void initGl(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration, bool fullscreen_anti_aliasing,
|
||||
float gammaValue);
|
||||
void makeCurrentGl();
|
||||
void swapBuffersGl();
|
||||
};
|
||||
|
@@ -25,7 +25,7 @@ Context::Context() {
|
||||
stencilBits= 0;
|
||||
hardware_acceleration=0;
|
||||
fullscreen_anti_aliasing=0;
|
||||
|
||||
gammaValue=0;
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -32,7 +32,10 @@ ContextGl::ContextGl() : Context() {
|
||||
}
|
||||
|
||||
void ContextGl::init() {
|
||||
pcgl.init(colorBits, depthBits, stencilBits, (hardware_acceleration != 0), (fullscreen_anti_aliasing != 0));
|
||||
|
||||
pcgl.init(colorBits, depthBits, stencilBits,
|
||||
(hardware_acceleration != 0), (fullscreen_anti_aliasing != 0),
|
||||
gammaValue);
|
||||
}
|
||||
|
||||
ContextGl::~ContextGl() {
|
||||
|
@@ -1587,6 +1587,11 @@ bool changeVideoMode(int resW, int resH, int colorBits, int ) {
|
||||
|
||||
void restoreVideoMode(bool exitingApp) {
|
||||
//SDL_Quit();
|
||||
if(exitingApp == true && SDL_WasInit(SDL_INIT_VIDEO)) {
|
||||
SDL_ShowCursor(1);
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
SDL_SetGamma(1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int getScreenW() {
|
||||
|
@@ -50,7 +50,9 @@ PlatformContextGl::~PlatformContextGl() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing) {
|
||||
void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration,
|
||||
bool fullscreen_anti_aliasing, float gammaValue) {
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -209,7 +211,15 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
|
||||
//fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
||||
|
||||
int bufferSize = (resW * resH * BaseColorPickEntity::COLOR_COMPONENTS);
|
||||
BaseColorPickEntity::init(bufferSize);
|
||||
BaseColorPickEntity::init(bufferSize);
|
||||
|
||||
if(gammaValue != 0.0) {
|
||||
//printf("Attempting to call SDL_SetGamma using value %f\n", gammaValue);
|
||||
|
||||
if (SDL_SetGamma(gammaValue, gammaValue, gammaValue) < 0) {
|
||||
printf("WARNING, SDL_SetGamma failed using value %f [%s]\n", gammaValue,SDL_GetError());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,12 +22,15 @@ namespace Shared{ namespace Platform{
|
||||
// class WindowGl
|
||||
// =====================================================
|
||||
|
||||
void WindowGl::initGl(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing){
|
||||
void WindowGl::initGl(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration, bool fullscreen_anti_aliasing,
|
||||
float gammaValue) {
|
||||
context.setColorBits(colorBits);
|
||||
context.setDepthBits(depthBits);
|
||||
context.setStencilBits(stencilBits);
|
||||
context.setHardware_acceleration(hardware_acceleration);
|
||||
context.setFullscreen_anti_aliasing(fullscreen_anti_aliasing);
|
||||
context.setGammaValue(gammaValue);
|
||||
|
||||
context.init();
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
SET(STREFLOP_SRC ${STREFLOP_GLOBBED_CPP})
|
||||
# use SSE unconditionally (FIXME?)
|
||||
SET_SOURCE_FILES_PROPERTIES(${STREFLOP_SRC} PROPERTIES COMPILE_FLAGS "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32 -O3 ${CXXFLAGS}")
|
||||
#SET_SOURCE_FILES_PROPERTIES(${STREFLOP_SRC} PROPERTIES COMPILE_FLAGS "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32 -O3 ${CXXFLAGS}")
|
||||
|
||||
ADD_LIBRARY(streflop STATIC EXCLUDE_FROM_ALL
|
||||
${STREFLOP_SRC}
|
||||
|
Reference in New Issue
Block a user