System.Gamma won't display any gamma adjustment (800x600x32)

Started by LostTrainDude, Sat 03/01/2015 16:37:16

Previous topic - Next topic

LostTrainDude

Some people have noticed me that they had some difficulties playing my latest MAGS entry because of the brightness.

EDIT: I'm using AGS 3.3.0. Didn't mention it before.

I tried to bind System.Gamma adjustment to two different keys (i.e. eKey4 and eKey5) and also tried to implement a slider within a GUI (where System.Gamma = sldGamma.Value).

The game has a 800x600 resolution with 32-bit colours.

This is my GlobalScript code. While it seems that the code itself is working, the game won't show not even the slightest change in brightness (of course the game is full screen).

Am I missing something? Or did I just mess up something with the sprite\background imports (all PNG files, by the way)?

Code: ags

//GlobalScript.asc

function on_key_press(eKeyCode keycode) {
    if (keycode == eKey4) {
        if (System.SupportsGammaControl) {
            cEgo.Say("It works!"); // Just to test if it works or not
            if (System.Gamma > 0) { // if System.Gamma is less than 0 the game crashes
                System.Gamma -= 5;
            }
        } else {
          cEgo.Say("It doesn't work!"); // Just to test if it works or not
        }
    }

    if (keycode == eKey5) {
        if (System.SupportsGammaControl) {
            cEgo.Say("It works!"); // Just to test if it works or not
            if (System.Gamma < 200) { // if System.Gamma is greater than 200 the game crashes
                System.Gamma += 5;
            }
        } else {
          cEgo.Say("It doesn't work!"); // Just to test if it works or not
        }
    }
}


I think that maybe is related to the Colour depth, since I found that there are some issues with that in some areas of the documentation. For instance:
QuoteAdvanced Room Features > Lighting effects
Light levels only work when the character's graphic is at the same colour depth as the background (ie. a 256-colour character in a hi-colour game won't get lightened).

Thanks a million!
"We do not stop playing because we grow old, we grow old because we stop playing."

Adventurer 007

LostTrainDude:

   Just a quick thought, are you running full screen mode?

Cross-Platform Support
Windows: Full-screen only
MS-DOS: No
Linux: No
MacOS: No

Another thought try just setting the value to 200 to validate it can change:
Code: ags
if (System.SupportsGammaControl) {
  System.Gamma = 200;
}

LostTrainDude

#2
Yes, it's full screen (to test this I'm building the EXE every time).

I tried your code both in the on_key_press and game_start functions but still doesn't work.
Again, I think that there's nothing wrong with the code itself, since putting the cEgo.Say() to tell me whether the system supports Gamma or not, actually turns out to be functional.

I can confirm this because, if I run the game within the AGS Editor, cEgo says that it doesn't support Gamma Control (like it should) while, if I run the full screen build, it says that it supports that.

Thanks a lot for your help!
"We do not stop playing because we grow old, we grow old because we stop playing."

Adeel

#3
The default value of Gamma is 100. And you're basing your conditions on the increment or decrements of 5... So far, so good. You also mention that you're using Slider. Can you please show the code for your slider? I assume that you've set it to max 40 value with each value incrementing/decrementing by 5.

Is there a warning log present? My guess is that you may have some sort of 'protection' which doesn't allow applications to change the Gamma (or overrides the gamma change to the default one which you may have set in that 'protective' program)?

Finally, have you tried sending that build to your testers to nullify the possibility that it works for others but doesn't for you (for some unknown reason)? I just tested your code on a default game and it works as it should. If you don't mind, can you send me a test build of your game to me?

I apologize if I don't make any sense or seem to be ranting. These possibilities just occurred in my mind and I thought that I should share them with you.

LostTrainDude

The slider has an extremely simple code (which may be wrong):

Code: ags

function repeatedly_execute()
{
  System.Gamma = sldGamma.Value;
  String g = String.Format("%d", System.Gamma);
  cEgo.SayBackground(g); // To keep easily track of the Gamma value
}


And in its Properties it has a MaxValue of 200, a MinValue of 0 and a Value of 100.

You're actually making me notice that I've only tested it on two Windows 8 systems. I didn't have time to find anybody to test it anywhere else, unfortunately. I'm sending you a link via PM :) Thanks a lot!

Regarding the warning log. I don't think that I see any: not in the Compiled folder, not in the main project folder, not in the Savegames folders.
"We do not stop playing because we grow old, we grow old because we stop playing."

Adeel

#5
Thank you for sending me the test build. I think I got the gist of what the problem actually is.

You're setting the Gamma Value exactly same to the Slider's value. This means that if we try to change the Gamma without changing the slider's value (i.e. via keyboard shortcut), it gets reset to the value of the slider. And, this too, happens at 40 game cycles or 1/40th of a second. This is why you are unable to see any change in Gamma (if you use the shortcut buttons). Had you not set the code in repeated_execture(), you would have gotten the error a long time ago (because of the conditions you set in the previous piece of code).

This code, however, does work with the slider. The screen does get bright and dark appropriately for me (as it should).

Here, try this:

- Set the max. value of the slider to 40 and value to 20:


- Double Click on the slider (on the GUI in Editor) and it will provide you with a bind-ed function (like it does with buttons). Put this code inside that function. In my case:
Code: ags
function sldGamma_OnChange(GUIControl *control)
{
    System.Gamma = sldGamma.Value * 5; //By multiplying it with 5, we ensure that it doesn't break your previous piece of code
}


- Remove the code from the repeatedly_execute()

This will solve the problem where the value of Gamma gets overridden with the value of Slider. If the code doesn't produce any error nor it seems to work for you, please send me a test build and I'll gladly test it out for you.

E: If it helps, I'm running Windows 7 32-bit.

LostTrainDude

I hope I didn't miss anything :)

I've commented the code I've previously posted (both in repeatedly_execute and in on_key_press) and followed your instructions for the slider. So the only code I have that deals with Gamma is the sldGamma_OnChange function.

Still no results (at least, here on Win8) :\

Just for the sake of testing, after that, I even tried putting a System.Gamma = 0 in the game_start function and still nothing seems to happen.
"We do not stop playing because we grow old, we grow old because we stop playing."

Adventurer 007

#7
So I cannot run the game engine in full screen via VMWARE. Not sure if this is due to a lack of drivers or if just doesn't work.  So I cannot test this feature.

[snip .. removed posted code..]
too early in the morning on that one. sorry.

-Adventurer 007

Adeel

#8
No, no. You don't need to comment out the code in on_key_press. The way I've set the slider to work, it ensures that it is compatible with your on_key_press. Can you please share a test build with me?

Also, to make sure that slider's value syncs if you change the value of Gamme via keyboard shortcut. Please put this line in your on_key_press code:
Code: ags
sldGamma.Value = System.Gamma / 5;


Like this:

Code: ags
    if (keycode == eKey4) {
        if (System.SupportsGammaControl) {
            cEgo.Say("It works!"); // Just to test if it works or not
            if (System.Gamma > 0) { // if System.Gamma is less than 0 the game crashes
                System.Gamma -= 5;
                sldGamma.Value = System.Gamma / 5; //sync the slider
            }
        } else {
          cEgo.Say("It doesn't work!"); // Just to test if it works or not
        }
    }
 
    if (keycode == eKey5) {
        if (System.SupportsGammaControl) {
            cEgo.Say("It works!"); // Just to test if it works or not
            if (System.Gamma < 200) { // if System.Gamma is greater than 200 the game crashes
                System.Gamma += 5;
                sldGamma.Value = System.Gamma / 5; //Sync the slider
            }
        } else {
          cEgo.Say("It doesn't work!"); // Just to test if it works or not
        }
    }


E: Adventure 007: Don't worry. I've already addressed your concern. Sorry if I wasn't clear on this. :-[

EE: The problem with the game being unable to change Gamma in Windows 8 isn't specific to AGS. Try setting the compatibility of your game to Windows 7.

LostTrainDude

Still no joy, unfortunately.

I've uncommented and fixed the code in on_key_press as you suggested and while it seems to "cooperate" with the slider, the two of them still won't display anything on the screen. I tried also using a Windows 7 compatibility, without luck :(

I'm sending you the build just in case :) Still, thanks a million for all your efforts!
"We do not stop playing because we grow old, we grow old because we stop playing."

SMF spam blocked by CleanTalk