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

Copying application_surface to new surface causes weird visual issues

CraterHater

Member
Hey,

I am using the following code to copy the application_surface to a new surface so I can draw it to create a still background for my pause menu.

GML:
var w = surface_get_width(application_surface);
var h = surface_get_height(application_surface);

surface = surface_create(w,h);
surface_copy(surface, 0, 0, application_surface);
In order to draw it like so in the draw GUI event:
Code:
if(surface_exists(surface)){
    draw_surface(surface,0,0);
}
But see the differences. The most noticeable difference are the clouds and the trees.;

example1.pngexample2.png

How would I go about fixing this issue? Thanks!

EDIT: I noticed the differences seem really subtle in this post but when you are in fullscreen mode it really is quite apparent.
 
Surface alpha (which it looks like is the problem) is always a bit tricky to deal with. Give this a try, it might help:
Create Event:
Code:
surface = -1;
Draw GUI Event:
Code:
if (!surface_exists(surface)) {
  
   var w = surface_get_width(application_surface);
   var h = surface_get_height(application_surface);

   surface = surface_create(w,h);
   surface_set_target(surface);
      draw_clear_alpha(c_black,0);
   surface_reset_target();
   surface_copy(surface, 0, 0, application_surface);
}
draw_surface(surface,0,0);
EDIT:
Also, remember surfaces are volatile and can be destroyed at any moment, so you might want to save the surface to a buffer after you've created it, and only copy from the application_surface if that buffer doesn't exist, otherwise read from the buffer. However, I'm not sure if this will be a problem as I haven't tested how the surface being destroyed effects the application surface before the new surface is created and populated.
 

CraterHater

Member
Surface alpha (which it looks like is the problem) is always a bit tricky to deal with. Give this a try, it might help:
Create Event:
Code:
surface = -1;
Draw GUI Event:
Code:
if (!surface_exists(surface)) {
 
   var w = surface_get_width(application_surface);
   var h = surface_get_height(application_surface);

   surface = surface_create(w,h);
   surface_set_target(surface);
      draw_clear_alpha(c_black,0);
   surface_reset_target();
   surface_copy(surface, 0, 0, application_surface);
}
draw_surface(surface,0,0);
EDIT:
Also, remember surfaces are volatile and can be destroyed at any moment, so you might want to save the surface to a buffer after you've created it, and only copy from the application_surface if that buffer doesn't exist, otherwise read from the buffer. However, I'm not sure if this will be a problem as I haven't tested how the surface being destroyed effects the application surface before the new surface is created and populated.
Thank you for your answer but I don't think that did anything.
 

NightFrost

Member
Hm, was this the surface alpha problem that can be fixed by setting gpu_set_blendmode_ext(bm_one, bm_one); before the operation (and reset that with gpu_set_blendmode(bm_normal);). It's been a while.
 

CraterHater

Member
Hm, was this the surface alpha problem that can be fixed by setting gpu_set_blendmode_ext(bm_one, bm_one); before the operation (and reset that with gpu_set_blendmode(bm_normal);). It's been a while.
Doesn't seem to be the problem :K When I use your blendmode function the game looks like an overexposed photo.
 
Top