Disable system level gamma management while in VR mode.

pull/615/head
madsbuvi 4 years ago
parent b96a832491
commit 9cfd71d601

@ -299,7 +299,7 @@ namespace MWGui
mShowOwned = Settings::Manager::getInt("show owned", "Game");
mVideoWrapper = new SDLUtil::VideoWrapper(window, viewer);
mVideoWrapper = new SDLUtil::VideoWrapper(window, viewer, MWBase::Environment::get().getVrMode() != true);
mVideoWrapper->setGammaContrast(Settings::Manager::getFloat("gamma", "Video"),
Settings::Manager::getFloat("contrast", "Video"));

@ -402,7 +402,7 @@ namespace MWVR
if (mMirrorTexture)
{
mMirrorTexture->bindFramebuffer(gc, GL_FRAMEBUFFER_EXT);
mMsaaResolveTexture->blit(gc, 0, 0, mMsaaResolveTexture->width(), mMsaaResolveTexture->height(), 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
mGammaResolveTexture->blit(gc, 0, 0, mGammaResolveTexture->width(), mGammaResolveTexture->height(), 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
mMirrorTexture->blit(gc, 0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}

@ -9,14 +9,16 @@
namespace SDLUtil
{
VideoWrapper::VideoWrapper(SDL_Window *window, osg::ref_ptr<osgViewer::Viewer> viewer)
VideoWrapper::VideoWrapper(SDL_Window *window, osg::ref_ptr<osgViewer::Viewer> viewer, bool shouldManageGamma)
: mWindow(window)
, mViewer(viewer)
, mGamma(1.f)
, mContrast(1.f)
, mShouldManageGamma(shouldManageGamma)
, mHasSetGammaContrast(false)
{
SDL_GetWindowGammaRamp(mWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
if(mShouldManageGamma)
SDL_GetWindowGammaRamp(mWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
}
VideoWrapper::~VideoWrapper()
@ -24,7 +26,7 @@ namespace SDLUtil
SDL_SetWindowFullscreen(mWindow, 0);
// If user hasn't touched the defaults no need to restore
if (mHasSetGammaContrast)
if (mShouldManageGamma && mHasSetGammaContrast)
SDL_SetWindowGammaRamp(mWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
}
@ -51,6 +53,9 @@ namespace SDLUtil
mHasSetGammaContrast = true;
if (!mShouldManageGamma)
return;
Uint16 red[256], green[256], blue[256];
for (int i = 0; i < 256; i++)
{

@ -18,7 +18,7 @@ namespace SDLUtil
class VideoWrapper
{
public:
VideoWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> viewer);
VideoWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> viewer, bool shouldManageGamma);
~VideoWrapper();
void setSyncToVBlank(bool sync);
@ -35,6 +35,7 @@ namespace SDLUtil
float mGamma;
float mContrast;
bool mShouldManageGamma;
bool mHasSetGammaContrast;
// Store system gamma ramp on window creation. Restore system gamma ramp on exit

Loading…
Cancel
Save