Change Textures On Demand / Sleep Margin at Runtime?

Discussion in 'Programming' started by obscene, Jul 4, 2017.

  1. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,424
    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.
     
  2. lolslayer

    lolslayer Member

    Joined:
    Jun 23, 2016
    Posts:
    689
    I think that the creators of bunker busters know this, let's summon them.
     
  3. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    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?
     
  4. Murzy

    Murzy Member

    Joined:
    Jul 28, 2016
    Posts:
    24
    Umm, I believe these values are configurable from the IDE. They were added to v1.4.1763 or some version right before it.

    [​IMG]

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

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,510
    "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.
     
  6. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    The Windows Tab would be a good place to mention the ini entries and what values relate to what setting
     
  7. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,594
    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.
     
  8. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,424
    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...
     
  9. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,594
    I'll be much interested in your results
     
  10. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    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
     
  11. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    Developer of Bunker Busters here, sorry but I really have no idea! :)
     
  12. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,424
    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.
     
  13. Samuel Venable

    Samuel Venable Time Killer

    Joined:
    Sep 13, 2016
    Posts:
    1,262
    obscene likes this.
  14. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    I should have thought of that... so nope for sandbox reason
     
  15. brokenjava

    brokenjava Member

    Joined:
    Nov 18, 2016
    Posts:
    83
    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.
     
  16. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    ^ unintentional pun ?
     
  17. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,424

    They are not mystery options...

    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.
     
    Samuel Venable likes this.
  18. Mike

    Mike nobody important GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    2,355
    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.
     
    obscene likes this.
  19. brokenjava

    brokenjava Member

    Joined:
    Nov 18, 2016
    Posts:
    83
    Have you tried modifying these while the game is running/restarting is it even worth the effort to fight the tyranny of the defaults?

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

    Intended.
     
  20. brokenjava

    brokenjava Member

    Joined:
    Nov 18, 2016
    Posts:
    83
    There we go problem solved no reading of doc's required. Ask a simple question get a simple answer.
     
  21. Samuel Venable

    Samuel Venable Time Killer

    Joined:
    Sep 13, 2016
    Posts:
    1,262
    Oh tartar sauce...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice