Jump to content

SDL_SetWindowGammaRamp ERROR


weridetogether6
 Share

Recommended Posts

Hey, a issue I have been suffering with for awhile now. when I start the game up this error pops up in the left hand corner (SDL_SetWindowGammaRamp)

after that I start a multiplayer game then this pops up [115.236] Out-Of-Sync on turn1...…..[115.236] Players: Name of Player..... [115.236] Dumping state to C:\Users\AppData\local\0ad\logs\oos_dump.txt

 

any ideas how to fix

Link to comment
Share on other sites

  On 15/06/2019 at 1:12 PM, vladislavbelov said:

Hi @weridetogether6 and welcome to the forum!

Are you able to compile the game from sources? Also could you post specs of your computer? You can find it at log folder: GameDataPaths (wiki).

Expand  

Thanks vladislavbelov, I'm not very proficient in computers. When you ask me to compile the game is that some sort of program? And with the specs is that found in my computer or in the folder i installed 0AD? 

Thanks for getting back to my forum.

Link to comment
Share on other sites

Welcome to the forum compiling from source means running the source code though a compiler(on Windows Visual Studio)that coverts the raw source code into a binary file that can actually run under that operating system.The computer spec can be found in a text file called system_info.txt that is the games log folder that you can find using that link to GameDataPaths that vlad provided.

Enjoy the Choice :)

Link to comment
Share on other sites

(generated 2019-06-15 11:36:07 UTC)

OS             : Win8.1  (6.3.9200)
CPU            : x86, Intel Core i7       Q 740  @ 1.73GHz (1x4x2), 1.73 GHz
Memory         : 8192 MiB; 5223 MiB free
Graphics Card  : NVIDIA GeForce GTX 460M/PCIe/SSE2
OpenGL Drivers : 4.6.0 NVIDIA 388.57; nvoglv32.dll (23.21.13.8857)
Video Mode     : 1920x1080:32
Sound Card     : OpenAL Soft on Speakers (Realtek High Definition Audio); OpenAL Soft on Realtek Digital Output (Realtek High Definition Audio); 
Sound Drivers  : 1.1 ALSOFT 1.17.1

do you need any more info?

 

Link to comment
Share on other sites

  Reveal hidden contents

 

Link to comment
Share on other sites

@Angen, @Stan`  I found a way to solve this problem, but I don't know where to put it.

BOOL WINAPI GetDevice Gamma Ramp            HDC hDC,            LPVOID lpRamp            ) BOOL WINAPI Set Device Gamma Ramp (HDC hDC, LPVOID lpRamp); where lpRamp points to a 3 x 256 WORD array with gradients that need Gamma correction, such as void * lpGamma = NULL;            WORD gMap [3] [256]= {0};            LpGamma = & gMap;            HDC HDC = GetDC (NULL);            GetDeviceGamma Ramp (hdc, lpGamma); // Get the current Gamma            For (INT I = 0; I < 256; i+)            {            GMap [0] = 256*i;            GMap [1] = 256*i;            GMap [2] = 256*i;            }            SetDeviceGamma Ramp (hdc, lpGamma); // Set to Standard Gamma

 

Link to comment
Share on other sites

// Adjust brightness parameter 0 - 100 Setting Successfully Returns 0 Setting Failure Returns Negative Number 
Int SetGamma(int bright)
{
    Void *lpGamma = NULL;
    Int iArray Value;
    WORD gMap[3][256] = {0};
    LpGamma = &gMap;
    HDC HDC = GetDC(NULL);
    If(NULL = hdc) Return - 1;
    For(int I = 0; I < 256; i +)
    {
        IArrayValue = i * (bright + 128);
        If(iArray Value > 65535) IArrayValue = 65535;
        GMap[0][i] = GMap[1][i] = GMap[2][i] = (WORD)iArray Value;
    }
    If(FALSE = SetDeviceGamma Ramp(hdc, lpGamma)) Return - 2;
    Return 0;
}

 

Link to comment
Share on other sites

@Stan`  I wrote a piece of code that might be able to adjust and correct the gamma on the display.

 

Class header file : (gammaramp.h)

#ifndef GAMMARAMP_H_
#define GAMMARAMP_H_
/*
CGammaRamp class
Encapsulates the Gamma Ramp API and changes the brightness of
the entire screen.
*/
                        class CGammaRamp
{
protected:
    HMODULE hGDI32;
    HDC hScreenDC;
    typedef BOOL(WINAPI *Type_SetDeviceGammaRamp)(HDC hDC, LPVOID lpRamp);
    Type_SetDeviceGammaRamp pGetDeviceGammaRamp;
    Type_SetDeviceGammaRamp pSetDeviceGammaRamp;
public:
    CGammaRamp();
    ~CGammaRamp();
    BOOL LoadLibrary();
    void FreeLibrary();
    BOOL LoadLibraryIfNeeded();
    BOOL SetDeviceGammaRamp(HDC hDC, LPVOID lpRamp);
    BOOL GetDeviceGammaRamp(HDC hDC, LPVOID lpRamp);
    BOOL SetBrightness(HDC hDC, WORD wBrightness);
};
#endif
 Class C++ File : (gammaramp.cpp)
#include <windows.h>
#include "gammaramp.h"
                 /* CGammaRamp class
Encapsulates the Gamma Ramp API and changes the brightness of
the entire screen.
*/
                 CGammaRamp::CGammaRamp()
{
    //Initialize all variables.
    hGDI32 = NULL;
    hScreenDC = NULL;
    pGetDeviceGammaRamp = NULL;
    pSetDeviceGammaRamp = NULL;
}
CGammaRamp::~CGammaRamp()
{
    FreeLibrary();
}
BOOL CGammaRamp::LoadLibrary()
{
    BOOL bReturn = FALSE;
    FreeLibrary();
    //Load the GDI library.
    hGDI32 = ::LoadLibrary("gdi32.dll");
    if (hGDI32 != NULL)
    {
        //Get the addresses of GetDeviceGammaRamp and SetDeviceGammaRamp API functions.
        pGetDeviceGammaRamp =
            (Type_SetDeviceGammaRamp)GetProcAddress(hGDI32, "GetDeviceGammaRamp");
        pSetDeviceGammaRamp =
            (Type_SetDeviceGammaRamp)GetProcAddress(hGDI32, "SetDeviceGammaRamp");
        //Return TRUE only if these functions exist.
        if (pGetDeviceGammaRamp == NULL || pSetDeviceGammaRamp == NULL)
            FreeLibrary();
        else
            bReturn = TRUE;
    }
    return bReturn;
}
void CGammaRamp::FreeLibrary()
{
    //Free the GDI library.
    if (hGDI32 != NULL)
    {
        ::FreeLibrary(hGDI32);
        hGDI32 = NULL;
    }
}
BOOL CGammaRamp::LoadLibraryIfNeeded()
{
    BOOL bReturn = FALSE;
    if (hGDI32 == NULL)
        LoadLibrary();
    if (pGetDeviceGammaRamp != NULL && pSetDeviceGammaRamp != NULL)
        bReturn = TRUE;
    return bReturn;
}
BOOL CGammaRamp::SetDeviceGammaRamp(HDC hDC, LPVOID lpRamp)
{
    //Call to SetDeviceGammaRamp only if this function is successfully loaded.
    if (LoadLibraryIfNeeded())
    {
        return pSetDeviceGammaRamp(hDC, lpRamp);
    }
    else
        return FALSE;
}
BOOL CGammaRamp::GetDeviceGammaRamp(HDC hDC, LPVOID lpRamp)
{
    //Call to GetDeviceGammaRamp only if this function is successfully loaded.
    if (LoadLibraryIfNeeded())
    {
        return pGetDeviceGammaRamp(hDC, lpRamp);
    }
    else
        return FALSE;
}
BOOL CGammaRamp::SetBrightness(HDC hDC, WORD wBrightness)
{
    /*
Changes the brightness of the entire screen.
This function may not work properly in some video cards.
The wBrightness value should be a number between 0 and 255.
128 = Regular brightness
above 128 = brighter
below 128 = darker
If hDC is NULL, SetBrightness automatically load and release
the display device context for you.
*/
    BOOL bReturn = FALSE;
    HDC hGammaDC = hDC;
    //Load the display device context of the entire screen if hDC is NULL.
    if (hDC == NULL)
        hGammaDC = GetDC(NULL);
    if (hGammaDC != NULL)
    {
        //Generate the 256-colors array for the specified wBrightness value.
        WORD GammaArray[3][256];
        for (int iIndex = 0; iIndex < 256; iIndex++)
        {
            int iArrayValue = iIndex * (wBrightness + 128);
            if (iArrayValue > 65535)
                iArrayValue = 65535;
            GammaArray[0][iIndex] =
                GammaArray[1][iIndex] =
                    GammaArray[2][iIndex] = (WORD)iArrayValue;
        }
        //Set the GammaArray values into the display device context.
        bReturn = SetDeviceGammaRamp(hGammaDC, GammaArray);
    }
    if (hDC == NULL)
        ReleaseDC(NULL, hGammaDC);
    return bReturn;
}

Example for using the CGammaRamp class:

#include <windows.h>
#include "gammaramp.h"

int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
    //Example for changing the brightness with CGammaRamp class:
    //Be aware that this exmaple may not work properly in all
    //Video cards.
    CGammaRamp GammaRamp;
    //Make the screen darker:
    GammaRamp.SetBrightness(NULL, 64);
    //Wait 3 seconds:
    Sleep(3000);
    //Return back to normal:
    GammaRamp.SetBrightness(NULL, 128);
    return 0;
}

 

Link to comment
Share on other sites

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...