From ef46331c394974fad415c0d2de87a55beac7239c Mon Sep 17 00:00:00 2001 From: Gillou68310 Date: Mon, 6 Jul 2015 13:58:51 +0200 Subject: [PATCH] Add config option to change polygon offset values --- src/Config.cpp | 5 +++++ src/Config.h | 5 +++++ src/OpenGL.cpp | 10 ++++++++-- src/mupenplus/Config_mupenplus.cpp | 13 +++++++++++++ src/mupenplus/MupenPlusAPIImpl.cpp | 4 ++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index 2d1f38e4..da0cb02c 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -35,6 +35,11 @@ void Config::resetToDefaults() generalEmulation.enableHWLighting = 0; generalEmulation.enableCustomSettings = 1; generalEmulation.hacks = 0; +#ifdef ANDROID + generalEmulation.forcePolygonOffset = 0; + generalEmulation.polygonOffsetFactor = 0.0f; + generalEmulation.polygonOffsetUnits = 0.0f; +#endif frameBufferEmulation.enable = 1; frameBufferEmulation.copyDepthToRDRAM = 1; diff --git a/src/Config.h b/src/Config.h index f4d52792..c12d7fba 100644 --- a/src/Config.h +++ b/src/Config.h @@ -45,6 +45,11 @@ struct Config u32 enableHWLighting; u32 enableCustomSettings; u32 hacks; +#ifdef ANDROID + u32 forcePolygonOffset; + f32 polygonOffsetFactor; + f32 polygonOffsetUnits; +#endif } generalEmulation; enum Aspect { diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp index 484db451..aaf1c059 100644 --- a/src/OpenGL.cpp +++ b/src/OpenGL.cpp @@ -1298,8 +1298,14 @@ void OGLRender::_initStates() glDisable( GL_POLYGON_OFFSET_FILL ); glDepthFunc( GL_ALWAYS ); glDepthMask( FALSE ); - } else - glPolygonOffset( -3.0f, -3.0f ); + } else { +#ifdef ANDROID + if(config.generalEmulation.forcePolygonOffset != 0) + glPolygonOffset(config.generalEmulation.polygonOffsetFactor, config.generalEmulation.polygonOffsetUnits); + else +#endif + glPolygonOffset(-3.0f, -3.0f); + } OGLVideo & ogl = video(); glViewport(0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight()); diff --git a/src/mupenplus/Config_mupenplus.cpp b/src/mupenplus/Config_mupenplus.cpp index 171cd2e5..29c84e9d 100644 --- a/src/mupenplus/Config_mupenplus.cpp +++ b/src/mupenplus/Config_mupenplus.cpp @@ -66,6 +66,14 @@ bool Config_SetDefault() assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableHWLighting", config.generalEmulation.enableHWLighting, "Enable hardware per-pixel lighting."); assert(res == M64ERR_SUCCESS); +#ifdef ANDROID + res = ConfigSetDefaultBool(g_configVideoGliden64, "ForcePolygonOffset", config.generalEmulation.forcePolygonOffset, "If true, use polygon offset values specified below"); + assert(res == M64ERR_SUCCESS); + res = ConfigSetDefaultFloat(g_configVideoGliden64, "PolygonOffsetFactor", config.generalEmulation.polygonOffsetFactor, "Specifies a scale factor that is used to create a variable depth offset for each polygon"); + assert(res == M64ERR_SUCCESS); + res = ConfigSetDefaultFloat(g_configVideoGliden64, "PolygonOffsetUnits", config.generalEmulation.polygonOffsetUnits, "Is multiplied by an implementation-specific value to create a constant depth offset"); + assert(res == M64ERR_SUCCESS); +#endif //#Frame Buffer Settings:" res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFBEmulation", config.frameBufferEmulation.enable, "Enable frame and|or depth buffer emulation."); assert(res == M64ERR_SUCCESS); @@ -173,6 +181,11 @@ void Config_LoadConfig() config.generalEmulation.enableNoise = ConfigGetParamBool(g_configVideoGliden64, "EnableNoise"); config.generalEmulation.enableLOD = ConfigGetParamBool(g_configVideoGliden64, "EnableLOD"); config.generalEmulation.enableHWLighting = ConfigGetParamBool(g_configVideoGliden64, "EnableHWLighting"); +#ifdef ANDROID + config.generalEmulation.forcePolygonOffset = ConfigGetParamBool(g_configVideoGliden64, "ForcePolygonOffset"); + config.generalEmulation.polygonOffsetFactor = ConfigGetParamFloat(g_configVideoGliden64, "PolygonOffsetFactor"); + config.generalEmulation.polygonOffsetUnits = ConfigGetParamFloat(g_configVideoGliden64, "PolygonOffsetUnits"); +#endif //#Frame Buffer Settings:" config.frameBufferEmulation.enable = ConfigGetParamBool(g_configVideoGliden64, "EnableFBEmulation"); config.frameBufferEmulation.copyToRDRAM = ConfigGetParamBool(g_configVideoGliden64, "EnableCopyColorToRDRAM"); diff --git a/src/mupenplus/MupenPlusAPIImpl.cpp b/src/mupenplus/MupenPlusAPIImpl.cpp index dd0d310c..e244356a 100644 --- a/src/mupenplus/MupenPlusAPIImpl.cpp +++ b/src/mupenplus/MupenPlusAPIImpl.cpp @@ -18,9 +18,11 @@ ptr_ConfigDeleteSection ConfigDeleteSection = NULL; ptr_ConfigSaveSection ConfigSaveSection = NULL; ptr_ConfigSaveFile ConfigSaveFile = NULL; ptr_ConfigSetDefaultInt ConfigSetDefaultInt = NULL; +ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat = NULL; ptr_ConfigSetDefaultBool ConfigSetDefaultBool = NULL; ptr_ConfigSetDefaultString ConfigSetDefaultString = NULL; ptr_ConfigGetParamInt ConfigGetParamInt = NULL; +ptr_ConfigGetParamFloat ConfigGetParamFloat = NULL; ptr_ConfigGetParamBool ConfigGetParamBool = NULL; ptr_ConfigGetParamString ConfigGetParamString = NULL; @@ -51,9 +53,11 @@ m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle) ConfigSaveSection = (ptr_ConfigSaveSection)DLSYM(_CoreLibHandle, "ConfigSaveSection"); ConfigSaveFile = (ptr_ConfigSaveFile)DLSYM(_CoreLibHandle, "ConfigSaveFile"); ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt)DLSYM(_CoreLibHandle, "ConfigSetDefaultInt"); + ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat)DLSYM(_CoreLibHandle, "ConfigSetDefaultFloat"); ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool)DLSYM(_CoreLibHandle, "ConfigSetDefaultBool"); ConfigSetDefaultString = (ptr_ConfigSetDefaultString)DLSYM(_CoreLibHandle, "ConfigSetDefaultString"); ConfigGetParamInt = (ptr_ConfigGetParamInt)DLSYM(_CoreLibHandle, "ConfigGetParamInt"); + ConfigGetParamFloat = (ptr_ConfigGetParamFloat)DLSYM(_CoreLibHandle, "ConfigGetParamFloat"); ConfigGetParamBool = (ptr_ConfigGetParamBool)DLSYM(_CoreLibHandle, "ConfigGetParamBool"); ConfigGetParamString = (ptr_ConfigGetParamString)DLSYM(_CoreLibHandle, "ConfigGetParamString");