• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Retrieve display data on 2nd monitor

Slyddar

Member
When running dual displays, if a windowed GMS2 game is dragged across to the 2nd monitor, and I use the display functions, it returns the information from the primary monitor still. Does anyone know if it's possible to access the secondary monitor dimensions, size, etc. using display_get_width/height ?
 

gnysek

Member
From what I remember, to get display info about second screen, the only way is to:
- use window_get_visible_rects() as @chamaeleon says, used together with args: window_get_x(), window_get_y(), window_get_width(),window_get_height()
- to detect on which window you are now, every monitor have group of 8 indexes in array (so two monitors = 16 keys in array) - monitor on which game is will have sum of first 4 arguments in group > 0 (be aware that game can be on two monitors at once, and they can have different resolutions!)
- display width of n-th monitor is: data[4*n+5] - data[4*n+4]
- display heightof n-th monitor is: data[4*n+7] - data[4*n+6]

For example, number of displays can be get by writing:
GML:
return array_length(window_get_visible_rects(0,0,1,1))/8;
 

Slyddar

Member
Thanks guys. Was kind of hoping for a magical set_primary_display() function lol, a guy can dream can't he?
I'll look into your suggestions though, cheers.
 

gnysek

Member
Not sure why GMS doesn't have it, but with above you can force second monitor, I'm using it in my game. Just be aware that lot of window functions doesn't update until next few frames, and might not work in 1st frame of game, so it's always good to give few frames to apply another changes (beware to not create a loop which applies them every x frames forever...).
 
Top