forked from teamnwah/openmw-tes3coop
increase robustness for gamma to persist in the system;
use GMST strings for gamma interface
This commit is contained in:
parent
50c64af63a
commit
60a74d5eb8
4 changed files with 32 additions and 15 deletions
|
@ -208,6 +208,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
|||
|
||||
OMW::Engine::~Engine()
|
||||
{
|
||||
mOgre->restoreWindowGammaRamp();
|
||||
mEnvironment.cleanup();
|
||||
delete mScriptContext;
|
||||
delete mOgre;
|
||||
|
@ -358,8 +359,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
windowSettings.icon = "openmw.png";
|
||||
std::string aa = settings.getString("antialiasing", "Video");
|
||||
windowSettings.fsaa = (aa.substr(0, 4) == "MSAA") ? aa.substr(5, aa.size()-5) : "0";
|
||||
windowSettings.gamma = Settings::Manager::getFloat("gamma", "General");
|
||||
windowSettings.contrast = Settings::Manager::getFloat("contrast", "General");
|
||||
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
|
||||
settings.getBool("minimize on focus loss", "Video") ? "1" : "0");
|
||||
|
@ -384,6 +383,8 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
// Create sound system
|
||||
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
|
||||
|
||||
mOgre->setWindowGammaContrast(Settings::Manager::getFloat("gamma", "General"), Settings::Manager::getFloat("contrast", "General"));
|
||||
|
||||
if (!mSkipMenu)
|
||||
{
|
||||
std::string logo = mFallbackMap["Movies_Company_Logo"];
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MyGUI type="Layout" version="3.2.0">
|
||||
<Widget type="Window" skin="MW_Window" position="0 0 400 505" layer="Windows" name="_Main">
|
||||
<Widget type="Window" skin="MW_Window" position="0 0 400 530" layer="Windows" name="_Main">
|
||||
<Property key="MinSize" value="430 446"/>
|
||||
<Widget type="TabControl" skin="TabControl" position="8 8 368 430" align="Stretch" name="SettingsTab">
|
||||
<Widget type="TabControl" skin="TabControl" position="8 8 368 455" align="Stretch" name="SettingsTab">
|
||||
<Property key="ButtonAutoWidth" value="true"/>
|
||||
<Widget type="TabItem" skin="" position="4 32 360 308">
|
||||
<Property key="Caption" value=" #{sPrefs} "/>
|
||||
|
@ -214,7 +214,7 @@
|
|||
</Widget>
|
||||
<Widget type="TabItem" skin="" position="4 32 360 308">
|
||||
<Property key="Caption" value=" #{sVideo} "/>
|
||||
<Widget type="TabControl" skin="TabControlInner" position="4 4 352 390" align="Stretch">
|
||||
<Widget type="TabControl" skin="TabControlInner" position="4 4 352 420" align="Stretch">
|
||||
<Property key="ButtonAutoWidth" value="true"/>
|
||||
<Widget type="TabItem" skin="" position="0 28 352 268" align="Stretch">
|
||||
<Property key="Caption" value=" Video "/>
|
||||
|
@ -293,7 +293,7 @@
|
|||
<Property key="TextAlign" value="Right"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="0 268 329 18" align="Left Top" name="GammaText">
|
||||
<Property key="Caption" value="Gamma Correction"/>
|
||||
<Property key="Caption" value="#{sGamma_Correction}"/>
|
||||
</Widget>
|
||||
<Widget type="MWScrollBar" skin="MW_HScroll" position="0 292 329 18" align="HStretch Top" name="GammaSlider">
|
||||
<Property key="Range" value="10000"/>
|
||||
|
@ -305,10 +305,18 @@
|
|||
<UserString key="SettingMin" value="0.1"/>
|
||||
<UserString key="SettingMax" value="3.0"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="0 314 329 18" align="Left Top" name="ContrastText">
|
||||
<Widget type="TextBox" skin="SandText" position="0 316 329 18" align="Left Top">
|
||||
<Property key="Caption" value="#{sDark_Gamma}"/>
|
||||
<Property key="TextAlign" value="Left"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="0 316 329 18" align="Right Top">
|
||||
<Property key="Caption" value="#{sLight_Gamma}"/>
|
||||
<Property key="TextAlign" value="Right"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="0 338 329 18" align="Left Top" name="ContrastText">
|
||||
<Property key="Caption" value="Contrast"/>
|
||||
</Widget>
|
||||
<Widget type="MWScrollBar" skin="MW_HScroll" position="0 336 329 18" align="HStretch Top" name="ContrastSlider">
|
||||
<Widget type="MWScrollBar" skin="MW_HScroll" position="0 362 329 18" align="HStretch Top" name="ContrastSlider">
|
||||
<Property key="Range" value="10000"/>
|
||||
<Property key="Page" value="300"/>
|
||||
<UserString key="SettingType" value="Slider"/>
|
||||
|
@ -496,7 +504,7 @@
|
|||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="320 440 56 24" align="Right Bottom" name="OkButton">
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="320 465 56 24" align="Right Bottom" name="OkButton">
|
||||
<Property key="ExpandDirection" value="Left"/>
|
||||
<Property key="Caption" value="#{sOK}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -26,8 +26,7 @@ using namespace OEngine::Render;
|
|||
OgreRenderer::~OgreRenderer()
|
||||
{
|
||||
cleanup();
|
||||
// restore system gamma ramp
|
||||
SDL_SetWindowGammaRamp(mSDLWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
|
||||
restoreWindowGammaRamp();
|
||||
}
|
||||
|
||||
void OgreRenderer::cleanup()
|
||||
|
@ -145,7 +144,6 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
|||
mWindow = helper.getWindow();
|
||||
|
||||
SDL_GetWindowGammaRamp(mSDLWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
|
||||
setWindowGammaContrast(settings.gamma, settings.contrast);
|
||||
|
||||
// create the semi-transparent black background texture used by the GUI.
|
||||
// has to be created in code with TU_DYNAMIC_WRITE_ONLY param
|
||||
|
@ -171,6 +169,8 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
|||
|
||||
void OgreRenderer::setWindowGammaContrast(float gamma, float contrast)
|
||||
{
|
||||
if (mSDLWindow == NULL) return;
|
||||
|
||||
Uint16 red[256], green[256], blue[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
|
@ -184,7 +184,16 @@ void OgreRenderer::setWindowGammaContrast(float gamma, float contrast)
|
|||
|
||||
red[i] = green[i] = blue[i] = value;
|
||||
}
|
||||
SDL_SetWindowGammaRamp(mSDLWindow, red, green, blue);
|
||||
if (SDL_SetWindowGammaRamp(mSDLWindow, red, green, blue) < 0)
|
||||
std::cout << "Couldn't set gamma: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
|
||||
void OgreRenderer::restoreWindowGammaRamp()
|
||||
{
|
||||
if (mSDLWindow != NULL)
|
||||
{
|
||||
SDL_SetWindowGammaRamp(mSDLWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
|
||||
}
|
||||
}
|
||||
|
||||
void OgreRenderer::adjustCamera(float fov, float nearClip)
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace OEngine
|
|||
int screen;
|
||||
std::string fsaa;
|
||||
std::string icon;
|
||||
float gamma;
|
||||
float contrast;
|
||||
};
|
||||
|
||||
class WindowSizeListener
|
||||
|
@ -101,6 +99,7 @@ namespace OEngine
|
|||
void createWindow(const std::string &title, const WindowSettings& settings);
|
||||
|
||||
void setWindowGammaContrast(float gamma, float contrast);
|
||||
void restoreWindowGammaRamp();
|
||||
|
||||
/// Set up the scene manager, camera and viewport
|
||||
void adjustCamera(
|
||||
|
|
Loading…
Reference in a new issue