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

surface_save_part works in smaller window, but not in fullscreen

marbar

Member
I built a drawing game, and want the user to be able to save their image at the end. To do this, I used the simple code
GML:
    if mouse_check_button_pressed(mb_any){
        surface_save_part(controller.initialSurf,"screenShot.png",0,0,camera_get_view_width(controller.camera),camera_get_view_height(controller.camera));
    }
This works perfectly fine when the game is in the smaller window. However, when I switch to fullscreen, (using window_set_fullscreen(true);) the screenshots no longer work. The image file just says "It looks like the file was moved or renamed". Anyone know why this might be happening? I am on windows 10 btw
 

DaveInDev

Member
are you sure that controller.initialSurf is still existing ? I noticed that surfaces can sometimes disappear for a lot of reasons, which is confirmed by the manual :

First, you should realise that surfaces (except the application surface) are "volatile". This means that if the device or window loses focus or is minimised (good examples are when you ALT +Tab to different window and back again on Windows, or on an Android device when the app loses focus due to a call) then the surface may be destroyed. This is because it is stored only in the texture memory (VRAM) and may be overwritten when the target platform needs that memory for something else which means that you should always have some type of fail-safe code in place, usually with the surface_exists() function.
so switching to fullscreen may be a reason of this surface to be destroyed or altered...
 
Last edited:

marbar

Member
are you sure that controller.initialSurf is still existing ? I noticed that surfaces can sometimes disappear for a lot of reasons, which is confirmed by the manual :



so switching to fullscreen may be a reason of this surface to be destroyed or altered...
It's a good idea, but the surface is still being drawn so I know that it exists. Also screen_save doesn't work (and pulls up the same file not found message), which I don't think is dependent on surfaces.
 

DaveInDev

Member
I find it strange that it makes a warning about the file and not the graphics... I wonder what can differ from windowed to fullscreen, in a "file" perspective...
Could it be possible also that this screenshot could be accidentaly called multiple times at the same moment ?
Did you try to trigger it with something else than a mouse click (maybe a keypress), and using a flag, in a post-draw event (if it's not already the case)...
 
Top