Legacy GM Best Way to Draw Shapes?

H

Heropants

Guest
Hi, I know in the past I've used functions like "draw_circle" (etc.) and have never noticed it breaking the vertex batch. However, I just noticed that every time I use any sort of function to draw a shape, it breaks the vertex batch. For instance, if I have 20 objects that all have "draw_rectangle_color" in their draw event, the vertex batch number in the debugging overlay will increase by 20.

Obviously this makes drawing shapes with the draw shape functions worthless unless I'm just drawing a few. Am I just using these functions wrong? Does anyone have any other ideas on how I might draw shapes that are meant to alter their size in game (I'm using these shapes like hp bars over the enemies, etc.).

Just as a note, I have had only 1 object draw all the shapes for 20 different objects in it's draw event to see if that kept all the shapes in one vertex batch. But I got the same results as if all 20 objects drew the shape in their own draw event.

Thanks in advance!
 
A

anomalous

Guest
I've always followed these rules:

If it's not affecting FPS, no issue.
If affecting FPS, use sprites.

For health bars and such, it should all be sprites IMO, they are fixed and you draw them so they can be stretched in X, or "show sprite part", or otherwise dynamically shown but still a static sprite. Just make some basic sprites in the sprite editor. You can easily add gradients or buttonize them, which makes them typically look better than draw_rect anyway. It's overkill but on some fancier windows that need to stretch with sprites, you can use something like a slice9 arrangement (look it up), allowing you to stretch a roundrect without distorting the edges, for example.

For fairly static drawings using primitives, you can always draw them to a surface, then just draw the surface. This has initial overhead time and memory, but if you don't often need to draw them again, it solves the issue. I do not think that's appropriate here.
 
H

Heropants

Guest
I've always followed these rules:

If it's not affecting FPS, no issue.
If affecting FPS, use sprites.

For health bars and such, it should all be sprites IMO, they are fixed and you draw them so they can be stretched in X, or "show sprite part", or otherwise dynamically shown but still a static sprite. Just make some basic sprites in the sprite editor. You can easily add gradients or buttonize them, which makes them typically look better than draw_rect anyway. It's overkill but on some fancier windows that need to stretch with sprites, you can use something like a slice9 arrangement (look it up), allowing you to stretch a roundrect without distorting the edges, for example.

For fairly static drawings using primitives, you can always draw them to a surface, then just draw the surface. This has initial overhead time and memory, but if you don't often need to draw them again, it solves the issue. I do not think that's appropriate here.
Thanks, that makes sense. I've hesitated just creating sprites for all the shapes since I'm still mostly in the developing state and have been switching around a lot of things so it's been nice to have the flexibility of the draw shape functions. I wanted to make sure before I wrote a couple of scripts to replace the draw shape functions that I wasn't simply using them wrong.

Thanks Anomalous!
 
Top