NazGhuL
NazTaiL
Hi. Someone has this error running my asset on marketplace:
**********************************.
Entering main loop.
**********************************.
Texture #3 1024,2048
ERROR!!! :: Trying to set a surface target that does not exist.
GMS2 is running on OSX.
I suspect that the problem comes from places outside the draw event where I can get code like
It's hard to debug because on my side, everything works fine. (Windows 10)
Is it that bad to 'sketch' a surface outside the draw event.
The manual states:
**********************************.
Entering main loop.
**********************************.
Texture #3 1024,2048
ERROR!!! :: Trying to set a surface target that does not exist.
GMS2 is running on OSX.
I suspect that the problem comes from places outside the draw event where I can get code like
Code:
//create event
surf0 = surface_create(100, 100);
scr_update_surface_menu(surf0);//in there: draw_set, draw and reset_target
//step event
if(click_on_menu)
{
scr_remove_item();
scr_update_surface_menu(surf0);//in there: draw_set, draw and reset_target
}
//draw event
if(surface_exists(surf0)
{
draw_surface(surf0, x, y);
}
Is it that bad to 'sketch' a surface outside the draw event.
The manual states:
So you do??you should only create surfaces in the draw event. If you create a surface in the Create Event of an instance, you could potentially get the same index as theapplication_surface. This then can cause lots of problems and confusion as you think your using your own surface, but you are actually using the current render target. You should also always try to limit drawing to a surface in the draw event too, since due to the optimised way in which GameMaker Studio 2 draws to the screen, it is recommended that you keep all draw functions within the draw event - this includes clearing a surface when it is first created, etc... Drawing to a surface outside of the draw event is possible and may even be necessary for some effects, but it's not how it should be done.
Code:
//create event
mysurf = -1; ??? noone? 0?
keyboard_update = 0;
//step event
if(keyboard_check_pressed(vk_space))
{
keyboard_update = 1;
}
//draw event
if(!surface_exists(mysurf)
{
mysurf = surface_create(100, 100);
}
else
{
if(keyboard_update == 1)
{
scr_update_surface_menu(mysurf);//in there: draw_set, draw and reset_target
keyboard_update = 0;
}
draw_surface(mysurf, x, y);
}