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

GameMaker [SOLVED] Pause screen with surfaces as background

Hello there!,
I am having some difficulties with surfaces when trying to use them as background; first of all, I'd like to use the draw gui event for that instead of the regular draw event.

Then, there are two methods I am considering which are to create a sprite from the application surface, or to directly copy the application surface (which I would prefer). The problem is that when I try to do this methods, the first one just doesn't scale correctly (not even in the regular draw event), and the second one has a little bit of misplacement that needs adjustment in some way I haven't figured out...

The code for the surface is:
Code:
surface_width = surface_get_width(application_surface);
surface_height = surface_get_height(application_surface);

surface = surface_create(surface_width, surface_height);
surface_copy(surface, 0, 0, application_surface);
and then at the Draw GUI event:
Code:
if (surface_exists(surface)) {
    draw_surface(surface, 0, 0);
}
(I free the surface after using it)

The problem with this is that it draws ULTRA zoomed in, and I don't understand why...

Could anyone advise me?, or suggest a better way?

Thank you very much!




Edit: Solution found
What I did was to draw it on the regular draw event:

End Step:
Code:
gpu_set_blendmode_ext(bm_one, bm_one);
surface = surface_create(camera_get_view_width(0), camera_get_view_height(0));
surface_copy(surface, view_xport[0], view_yport[0], application_surface);
gpu_set_blendmode(bm_normal);
Draw:
Code:
if (surface_exists(surface)) {
draw_surface_ext(surface, surface_x, surface_y, surface_xscale, surface_yscale, 0, c_white, 1);
}
where paused_x/y are the view_x/yport, and
Code:
surface_xscale = view_wport[0] / camera_get_view_width(0);
surface_yscale = view_hport[0] / camera_get_view_height(0);
 
Last edited:

jonjons

Member
The problem with this is that it draw ULTRA zoomed in, and I don't understand why...
This also happens to me. In my case i have an option to change the game resolution.
Try using the same resolution for the drawGui event and for the apllication surface. Then you can test the new surface see if its still zoomed. In my case the base resolution ive set for my game is 480x272 ( in level editor viewPorts ad cameras )
 
S

Sureño

Guest
Try drawing it in the post_draw event rather than the gui event - if you draw it in the gui event you might have a different resolution you need to account for.
Hello!
Very very late but I was checking your post because I ran into the same issue so I leave a solution for when you have a different resolution of the gui:

//Get the dimensions of the gui:
var gui_w = display_get_gui_width();
var gui_h = display_get_gui_height();

//Calculate the difference between the two:
var surface_ratio_x = gui_w/surface_get_width(application_surface);
var surface_ratio_y = gui_h/surface_get_height(application_surface);

//Apply the proper scaling when drawing the surface:
draw_surface_ext(your_surface,0,0,surface_ratio_x,surface_ratio_y,0,c_white,1);

Just in case someone comes and finds it useful :)
 
Top