Windows [Closed, bug reported] Game crashes on sprite_add_from_surface

W

Wraithious

Guest
Hello, In my game I have an alarm event that makes a surface and draws stuff, then adds a sub image to a sprite from the surface, but it crashes the game hard (like crashes windows, no error message reported from game maker) so I ran it in the debugger and it crashes at the first call to sprite_add_from_surface. All other variables up to that point all have the correct/expected values, and I have added the sprites in the resource tree like normal, they are not imported from a file. Here is my alarm code:
Code:
///Captain's log stardate 20171018 - Make pages
num=sprite_get_number(spr_content);
num2=sprite_get_number(invertNo);
num3=sprite_get_number(invertYes);
spr=sprite_create_from_surface(application_surface,0,0,736,414,0,0,0,0);

sur=surface_create(394,294);
surface_set_target(sur);
draw_clear_alpha(-1,0);
if(sprite_exists(spr))
{global.maxpage+=1;
draw_sprite_ext(spr,0,0,0,0.535,0.71,0,-1,1);
draw_set_color(c_white);
draw_text(191,278,"("+string(global.maxpage)+")");
surface_reset_target();
sprite_add_from_surface(spr_content, sur, 0, 0, 394, 294, 0, 0);  //CRASHES windows here
sprite_add_from_surface(invertNo, sur, 0, 0, 197, 294, 0, 0);
sprite_add_from_surface(invertNo, sur, 197, 0, 197, 294, 0, 0);
surface_free(sur);

sur=surface_create(394,294);
surface_set_target(sur);
draw_clear_alpha(-1,0);
draw_sprite_ext(spr,0,0,0,0.535*-1,0.71,0,-1,1);
surface_reset_target();
sprite_add_from_surface(invertYes, sur, 197, 0, 197, 294, 0, 0);
sprite_add_from_surface(invertYes, sur, 0, 0, 197, 294, 0, 0);
surface_free(sur);

sprite_save_strip(spr_content, "spr_content.png");
sprite_save_strip(invertNo, "invertNo.png");
sprite_save_strip(invertYes, "invertYes.png");
}
Does anyone know what I might be doing wrong?
 
Last edited by a moderator:
W

Wraithious

Guest
Wow, so I commented everything out completely and put this in the alarm event:
Code:
sprite_add_from_surface(spr_content, application_surface, 0, 0, 394, 294, 0, 0);
and it crashes the game in the same way, before I file a bug report can anyone please confirm this?
I tried it this way too to make sure, same problem:
Code:
if(surface_exists(application_surface))
{
sprite_add_from_surface(spr_content, application_surface, 0, 0, 394, 294, 0, 0);
}
 

Fern

Member
Your crash is the result of adding a sprite from a surface you are currently still targeting. At least that's what I can tell from your code. sprite_add_from_surface() has worked fine for the past few years.
 
W

Wraithious

Guest
Your crash is the result of adding a sprite from a surface you are currently still targeting. At least that's what I can tell from your code. sprite_add_from_surface() has worked fine for the past few years.
No, I reset the target before calling sprite_add_from_surface
Code:
surface_reset_target();
sprite_add_from_surface(invertYes, sur, 197, 0, 197, 294, 0, 0);
sprite_add_from_surface(invertYes, sur, 0, 0, 197, 294, 0, 0);
surface_free(sur);
And then, as I showed, I tried it all by itself with no other code, still crashes.
 

Fern

Member
What version of Game Maker are you using? Also is the surface smaller than your max texture page size?
 
W

Wraithious

Guest
@Seabass (The Human) Im using early access 1.99.551, and my texture pages are set to 2048x2048, in the first test (original) the surface created was 1472x294, so that one was smaller, the second test I used the application surface which should be 736x414, at least that's my room size and background size, so that is also smaller than my texture page size.
 

Fern

Member
Hmm, perhaps they really did break sprite_add_from_surface(). That just seems really odd because they didn't touch the function for GMS 2.
 
Top