Jump to content

SDL_SetWindowGammaRamp ERROR


weridetogether6
 Share

Recommended Posts

@Stan`  This code is more practical, it is simpler, it can effectively solve practical problems.

BTW: we should not delete those settings, should adjust it.

// The hDC DC handle, if NULL, uses the entire screen
// wR wG wB 0-255, default 128
BOOL SetBrightness(HDC hDC, int wR, int wG, int wB)
{
    BOOL bRet = FALSE;
    HDC hGammDC = hDC ? hDC : ::GetDC(NULL);
#pragma pack(push, 8)
    typedef struct _tagD3dGammaramp_t
    {
        WORDred[256];
        WORDgreen[256];
        WORDblue[256];
    } _D3DGAMMARAMP, *LP_D3DGAMMARAMP;
#pragma pack(pop)

    _D3DGAMMARAMP mGamRamp;
    memset(&mGamRamp, 0, sizeof(mGamRamp));
    for (int iIndex = 0; iIndex < 256; iIndex++)
    {
        mGamRamp.red[iIndex] = min(65535, iIndex * (wR + 128));
        mGamRamp.green[iIndex] = min(65535, iIndex * (wG + 128));
        mGamRamp.blue[iIndex] = min(65535, iIndex * (wB + 128));
    }
    LPVOID lpRamp = &mGamRamp;
    bRet = SetDeviceGammaRamp(hGammDC, lpRamp);
    if (hDC == NULL && hGammDC)
    {
        ::ReleaseDC(NULL, hGammDC);
    }
    return bRet;
}

 

Link to comment
Share on other sites

@gameboy that code will not work, nor will the previous examples you posted do either. Some are C not C++ which isn't a problem by itself, but we don't code in C anywhere, some are not cross platform, example 

#include <windows.h>

Will only work on windows.

Nobody actually needs to change the gamma in the game, you can do it using external software if you need to.

Also, when posting code snippets, please use the code tools from the forums. It's unreadable otherwise. Thanks.

 

29 minutes ago, weridetogether6 said:

It's fixed now cheers

Did a re installation fix it ?

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...