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

Dealing With Surfaces Only Behaving How I Want With Breakpoints

OliverSB

Member
surface_copy_part(selectedData, 0, 0, surf_canvas, _x1, _y1, abs(rect_w), abs(rect_h));

surface_set_target(surf_canvas);
gpu_set_blendmode(bm_subtract);
draw_rectangle(_x1, _y1, _x2, _y2, false);
gpu_set_blendmode(bm_normal);
surface_reset_target();

So why does this code leave me with blank graphics in selectedData if there is no breakpoints but if there is a breakpoint then it has no problem copying over and behaves exactly how I want it to?
 

Yal

šŸ§ *penguin noises*
GMC Elder
What color is the rectangle? If it's white, it'll erase everything.
 

TheouAegis

Member
When do you refresh surf_canvas? Does surf_canvas still retain the cutout before this code is called again? Because then you're just copying empty space over every step later until surf_canvas gets refreshed.
 

OliverSB

Member
With breakpoints, does it behave correctly all the way through, or only at certain points?
I have tried different breakpoints were the mouse is released. And it works fine.
When do you refresh surf_canvas? Does surf_canvas still retain the cutout before this code is called again? Because then you're just copying empty space over every step later until surf_canvas gets refreshed.
The cutoff is not retained in the selectedData surface but is for surf_canvas when using breakpoints. This is the way I intend it to work. But disabling this breakpoint causes the cutoff to be applied to the selectedData copy of the surface too.
 

TheouAegis

Member
I have tried different breakpoints were the mouse is released. And it works fine.

The cutoff is not retained in the selectedData surface but is for surf_canvas when using breakpoints. This is the way I intend it to work. But disabling this breakpoint causes the cutoff to be applied to the selectedData copy of the surface too.
I think flyingsaucer was asking if the surfaces are fine step after step after step. When it stops for a breakpoint the first time, everything should be fine. Then hit RUN and let it get to the that same breakpoint on the next step. Is everything still fine on the 2nd step? And 3rd? And 4th? And so on?

What I was asking ties into that. You are copying the cutout portion of surf_canvas before you cut it out. Ok, fine. But on the next step, are you still copying surf_canvas again but before you ever refreshed it?

This sounds like it's for a paint program or something. Are you using _pressed or _released mouse checks?
 

OliverSB

Member
I think flyingsaucer was asking if the surfaces are fine step after step after step. When it stops for a breakpoint the first time, everything should be fine. Then hit RUN and let it get to the that same breakpoint on the next step. Is everything still fine on the 2nd step? And 3rd? And 4th? And so on?

What I was asking ties into that. You are copying the cutout portion of surf_canvas before you cut it out. Ok, fine. But on the next step, are you still copying surf_canvas again but before you ever refreshed it?

This sounds like it's for a paint program or something. Are you using _pressed or _released mouse checks?
It is fine step after step because not only do the graphics show up in the debugger upon breakpoint but they draw and show as intended in my paint program continiously. Drawing graphics on to the surface will even work without breakpoints.
 

OliverSB

Member
I think flyingsaucer was asking if the surfaces are fine step after step after step. When it stops for a breakpoint the first time, everything should be fine. Then hit RUN and let it get to the that same breakpoint on the next step. Is everything still fine on the 2nd step? And 3rd? And 4th? And so on?

What I was asking ties into that. You are copying the cutout portion of surf_canvas before you cut it out. Ok, fine. But on the next step, are you still copying surf_canvas again but before you ever refreshed it?

This sounds like it's for a paint program or something. Are you using _pressed or _released mouse checks?
I have now added debug code that waits 2 steps before erasing from surfCanvas and it works when I wait 2 steps.

Is there any technique I should be using like threading to get this to work without a workaround? Is this how GameMaker is meant to behave or is this a bug in how surfaces get updated?

if !variable_instance_exists(id, "drawSurfCanvasCutout") drawSurfCanvasCutout = false;

if drawSurfCanvasCutout {
drawSurfCanvasCutout ++;
if drawSurfCanvasCutout == 3 { // Set this check to '== 2' for 2 step wait and it won't work.
drawSurfCanvasCutout = false;
surface_set_target(surf_canvas);
gpu_set_blendmode(bm_subtract);
draw_rectangle(lx, ly, lx1+lw, ly+lw, false);
gpu_set_blendmode(bm_normal);
surface_reset_target();
}
}
 
Top