Draw Code

RifleFire

Member
Hi, Does all code that draws things HAVE to be put IN an objects Draw Events or can it be elsewhere like in a script? Thanks.
RF
 

rytan451

Member
Theoretically, it should be possible to put draw code in a step event (for example), as long as you set a surface target. However, this can be hideously slow, so it's usually a good idea to avoid doing that.
 

chamaeleon

Member
Theoretically, it should be possible to put draw code in a step event (for example), as long as you set a surface target. However, this can be hideously slow, so it's usually a good idea to avoid doing that.
The caveats and warnings in the manual makes me leery of doing any drawing outside the draw events. Luckily for me, I guess, I have so far not encountered a case where I need to. But different people may have different requirements.
 

TsukaYuriko

☄️
Forum Staff
Moderator
It doesn't have to be in a Draw event. However, it doesn't make much sense to put it anywhere else. Doing so would most likely result in whatever you're drawing not ending up being visible, because the room's background will overwrite it. The exception to this is drawing to surfaces, but for those to be visible, you'd as well have to draw them to the screen in a Draw event further down the line.

That aside, the manual recommends handling drawing in the Draw event as the graphics pipeline is optimized for it to be done there. Drawing anywhere else therefore means you're on uncharted territory, and would be the rough equivalent of walking on a frozen lake.

Putting it in a script is fine as long as you then call the function defined by this script in a Draw event.
 
Top