GML draw_surface() before or after surface_reset_target()?

K

Keynes

Guest
surface_index=surface_create(256,256);

if (!surface_exists(surface_index))
{
surface_index=surface_create(256,256);
}

surface_set_target(surface_index);
draw_button(0,0,100,100,true);
surface_reset_target();
draw_surface(surface_index,200,200);


Hi folks, I put the above code in the Draw event of an object. It turns out to be working. But if I switch draw_surface and surface_reset, nothing gets drawn.
Why is this? From what I know according to the manual, draw_surface outputs what's in the surface to the screen and surface reset set the future target back to the screen. I can't see how the order of them make a difference.
 
Last edited by a moderator:

Simon Gust

Member
Everything between surface_set_target() and surface_reset_target() is drawn to the surface, so essentially you're drawing the surface on itself and not to the screen.
 
Top