- 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:
Mark Vejvoda
2011-12-23 08:20:54 +00:00
parent f38c8c9f63
commit 2e94c32d59
14 changed files with 103 additions and 22 deletions

View File

@@ -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}")

View File

@@ -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;

View File

@@ -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();

View File

@@ -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 ||

View File

@@ -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();
};

View File

@@ -25,7 +25,7 @@ Context::Context() {
stencilBits= 0;
hardware_acceleration=0;
fullscreen_anti_aliasing=0;
gammaValue=0;
}
}}//end namespace

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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());
}
}
}
}

View File

@@ -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();
}

View File

@@ -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}