1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-10-04 22:26:30 +00:00

Disable system level gamma management while in VR mode.

This commit is contained in:
madsbuvi 2021-03-11 19:09:17 +01:00
parent b96a832491
commit 9cfd71d601
4 changed files with 12 additions and 6 deletions

View file

@ -299,7 +299,7 @@ namespace MWGui
mShowOwned = Settings::Manager::getInt("show owned", "Game"); 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"), mVideoWrapper->setGammaContrast(Settings::Manager::getFloat("gamma", "Video"),
Settings::Manager::getFloat("contrast", "Video")); Settings::Manager::getFloat("contrast", "Video"));

View file

@ -402,7 +402,7 @@ namespace MWVR
if (mMirrorTexture) if (mMirrorTexture)
{ {
mMirrorTexture->bindFramebuffer(gc, GL_FRAMEBUFFER_EXT); 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); gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
mMirrorTexture->blit(gc, 0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); mMirrorTexture->blit(gc, 0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
} }

View file

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

View file

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