• 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!

window_get_width() gets incorrect

dormi

Member
Hi,

When I use the following code to display some text according to the view for the x position:

camera_get_view_x(view_camera[0]) + (window_get_width() / 2)

It works fine in windowed mode but when I switch to fullscreen mode it doesn't work correctly and displays the text off screen to the right.

It also does the same thing for the height.

Does anyone know what may be happening?

The values for camera_get_view_x(view_camera[0]) and window_get_width() look to be correct.

The full code is:

global.xview = camera_get_view_x(view_camera[0]);
global.yview = camera_get_view_y(view_camera[0]);

draw_set_color(c_black);
draw_set_font(fnt_large);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(global.xview + (window_get_width() / 2), global.yview + (window_get_height() / 2), "LEVEL COMPLETE");

Thank you
 

Joe Ellis

Member
I'm not sure but it might be that it keeps the window resolution the same in case you switch back from fullscreen.
To deal with it you could make a global variable "fullscreen" and set it true and false when switching.
Then change the code depending whether it is or not. For fullscreen display_get_width\height will work properly.
 

dormi

Member
I'm not sure but it might be that it keeps the window resolution the same in case you switch back from fullscreen.
To deal with it you could make a global variable "fullscreen" and set it true and false when switching.
Then change the code depending whether it is or not. For fullscreen display_get_width\height will work properly.
I have tried display_get_width/height and it's still the same.

Also, display_get_width and window_get_width return the same value when in fullscreen.

Thank you for trying to help though.
 

chamaeleon

Member
Is your problem due to your window having having a larger size as returned by window_get_width() and window_get_height() in fullscreen, compared to your windowed display? And given this, is it perhaps possible you don't scale up your application surface to match the new width and height? This would result in the half of the width and height appearing to be further to the right and down. Perhaps you should use view_wport[0]/2 and view_hport[0]/2 to get the center horizontally and vertically in room coordinates in the first view, for instance?
 
Top