mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-12 21:47:11 +03:00
Merge remote-tracking branch 'mrcheko/master'
This commit is contained in:
commit
ec1df719fe
7 changed files with 90 additions and 5 deletions
|
@ -23,6 +23,11 @@
|
|||
using namespace Ogre;
|
||||
using namespace OEngine::Render;
|
||||
|
||||
OgreRenderer::~OgreRenderer()
|
||||
{
|
||||
cleanup();
|
||||
restoreWindowGammaRamp();
|
||||
}
|
||||
|
||||
void OgreRenderer::cleanup()
|
||||
{
|
||||
|
@ -140,6 +145,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
|||
helper.setWindowIcon(settings.icon);
|
||||
mWindow = helper.getWindow();
|
||||
|
||||
SDL_GetWindowGammaRamp(mSDLWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
|
||||
|
||||
// create the semi-transparent black background texture used by the GUI.
|
||||
// has to be created in code with TU_DYNAMIC_WRITE_ONLY param
|
||||
|
@ -163,6 +169,35 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
|||
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
float k = i/256.0f;
|
||||
k = (k - 0.5f) * contrast + 0.5f;
|
||||
k = pow(k, 1.f/gamma);
|
||||
k *= 256;
|
||||
float value = k*256;
|
||||
if (value > 65535) value = 65535;
|
||||
else if (value < 0) value = 0;
|
||||
|
||||
red[i] = green[i] = blue[i] = value;
|
||||
}
|
||||
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)
|
||||
{
|
||||
mCamera->setNearClipDistance(nearClip);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue