Change Textures On Demand / Sleep Margin at Runtime?

obscene

Member
So just noticing that these settings are actually stored by GM in an INI file in the install directory...

[Windows]
CreateTexturesOnDemand=0
AlternateSyncMethod=1
VertexBufferMethod=0
SleepMargin=16

Alternate sync and vertex method of course there are functions for, but not sleep margin and textures on demand. So I'm thinking about trying to include this INI file and then allow the user to adjust the settings in-game.

I assume that changing these settings would require a game restart to take effect, but otherwise this should work, right?

Or am I crazy.
 
I

icuurd12b42

Guest
If the file is in the sandbox part of the game you should be able to write to it. All these sound interesting to play with but I have no idea if it would yield catastrophic results. they do warrant some explanation...

@Mike, sorry to ping you on this but there is no documentation on these and knowing what they do and what are proper values for those would be useful. I think they should be documented since our users may ask what these do and may offer possible tweak for users having trouble running the game maybe? like the command line argument allows to do?
 

Murzy

Member
Umm, I believe these values are configurable from the IDE. They were added to v1.4.1763 or some version right before it.



EDIT: Oh, you probably meant changing them at runtime. Not 100% sure what kind of use cases for that there would be, though.

What these actually do, though, is a bit of a mystery to me. I believe that the sleep margin is somehow related to the drawing loop. But I have no clue what the "Create textures on demand" option does, but one would assume that the texture pages are created on the fly or something like that.

In any case, these are probably best when left at their default values :D
 

rIKmAN

Member
"Create Textures On Demand" means that GMS will not load all graphics at the start of the game, and will only load texture pages into memory when a sprite from a page is drawn.

There are functions in GMS2 to cache/flush texture pages which can be used to manage things much better now, I would assume they were also added to 1.4 though I haven't kept up with the EA releases since I got 2.0 so best to check the release notes and manual to make sure.
 

RangerX

Member
The sleep margin is for helping GMS steps to be in synch with your computer's.
It's apparently very useful on some newer Win10 machines.
 

obscene

Member
I clarified the topic title a bit, but I know what the settings do I'm just curious as to if I'll cause a trainwreck trying to allow the user access to the settings in-game.

I'll probably test this very shortly actually...
 
I

icuurd12b42

Guest
the sleep margin could be useful too if your game is efficient, it puts the game thread to sleep and reduce the cpu stress instead of having it (mainly) wait in the tight loop
 
A

amusudan

Guest
Developer of Bunker Busters here, sorry but I really have no idea! :)
 

obscene

Member
Well, I've ran into a roadblock. You can certainly get the values from the INI the FIRST TIME you read the file...

Code:
if ( file_exists("Options.ini") )
    {
    ini_open("Options.ini");
    obj_controller_system.sleep_margin=ini_read_real("Windows","SleepMargin",0);
    obj_controller_system.textures_on_demand=ini_read_real("Windows","CreateTexturesOnDemand",1);
    ini_close();
    }
And then you can write the file...

Code:
if ( file_exists("Options.ini") )
    {
    ini_open("Options.ini");
    ini_write_real("Windows","SleepMargin",obj_controller_system.sleep_margin);
    ini_write_real("Windows","CreateTexturesOnDemand",obj_controller_system.textures_on_demand);
    ini_close();
    }
But that doesn't write to the original INI and instead saves a separate INI file in the same folder as my saves, screenshots, etc. (users/appdata/whatever) instead of the one in the installation folder.

When the game is loaded, my variables are populated with the ones from the new INI file and so my changes appear to have been loaded, but the executable pulled from the original file which still has the original values and so my changes have no effect. :(

I also tried to include the file but the results are always the same, writing the file will not overwrite the original.
 
I

icuurd12b42

Guest
I should have thought of that... so nope for sandbox reason
 
B

brokenjava

Guest
So like most things in GM documentation why is the community in the dark about UI settings? Surely there is someone at yoyo that could explain in detail and breadth what these mystery options are for. As for sleep margin I thought it had something todo with mobile power saving. But if you could dynamically change it that would be great. Let the user decide if they want a portable cook stove while "gaming" or maybe they are fine with a retarded experience.
 

obscene

Member
So like most things in GM documentation why is the community in the dark about UI settings? Surely there is someone at yoyo that could explain in detail and breadth what these mystery options are for. As for sleep margin I thought it had something todo with mobile power saving. But if you could dynamically change it that would be great. Let the user decide if they want a portable cook stove while "gaming" or maybe they are fine with a retarded experience.

They are not mystery options...

Create Textures on Demand - Checking this will make the windows target work like all the other targets, ie: texture pages will be loaded into memory on demand and can be flushed again when required. This can cause a few milliseconds of pause in your game as the texture pages are loaded, and so should be optimised such that the textures required for a level are loaded at the start of the room to minimise impact.
he final option is for setting the Windows Sleep Margin. This option is related to reducing stuttering when running your game on specific systems. Basically, if your game is running faster than your room speed GameMaker: Studio will "sleep" for the remaining time, but this sleep can be quite inaccurate and you can often end of sleeping for longer than necessary, causing your frame to take longer which causes stuttering. To get around this we can sleep for less time, then sit in a tight loop for the remainder of the time to make it more accurate - although the problem with sitting in a loop is that it causes CPU usage to increase, which in turn can cause your CPU temperatures to rise and your fan to run faster. By default, this value is set to 1, and in 99.99% of the cases you'll be fine with this, but for low end machines or for machines with a lot of background processes running this may not be an ideal solution and a value of 5 or 10 may be required. Note though that this is very much a system specific configuration and what works on your build machine may not be appropriate for another user, and as such if in doubt leave it set to 1.
https://docs.yoyogames.com/source/dadiospice/001_advanced use/global game settings/windows tab.html

They are totally editable by the creator in the global game settings, and by end-user too but require them to edit Options.ini which is what I was hoping to circumvent. Looks like Sam's dll is probably the best solution.
 

Mike

nobody important
GMC Elder
Pretty sure that file is only used by the compiler......

As to sandboxing.

Any file you read comes from the sandbox

If you write to a file you've read from the sandbox, it goes into the save area.
(This is because 1. You want to be able to reset a game without a user having to reinstall it. 2. on devices like Android, the file is compressed in a JAR, you can't write to it. 3. On machines like windows, you can't write to places like Program Files either)

When you try and open a file, it always tries to read from the save area first so that it'll get any modified files. This means to the program, it'll seem as though it read the file and wrote changes back.
 
B

brokenjava

Guest
They are totally editable by the creator in the global game settings, and by end-user too but require them to edit Options.ini which is what I was hoping to circumvent. Looks like Sam's dll is probably the best solution.
Have you tried modifying these while the game is running/restarting is it even worth the effort to fight the tyranny of the defaults?

^ unintentional pun ?
No just a sarcastic comment to derail the tense situation we have here. Pun wait for it

I'm just curious as to if I'll cause a trainwreck trying to allow
Intended.
 
Top