Linking/merging drawings

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
citrus_psyche
Prole
Posts: 1
Joined: Sun Oct 26, 2014 2:49 pm

Linking/merging drawings

Post by citrus_psyche »

Hi guys,

I've just started working with LOVE and I have one small question.

Is it possible to draw multiple objects as one? For example, instead of doing
love.graphics.rectangle( "fill", x1, y1, width1, height1)
love.graphics.rectangle( "fill", x2, y2, width2, height2),
I want to draw both rectangle with just one line of code, by pre-defining them somehow, like
double_rectangle = rectangle1 + rectangle2
draw double_rectangle
I'm asking because I'm working with multiple stacked rectangles of different transparencies and drawing them every frame is very CPU-intensive.

Hope you can help!
User avatar
DaedalusYoung
Party member
Posts: 407
Joined: Sun Jul 14, 2013 8:04 pm

Re: Linking/merging drawings

Post by DaedalusYoung »

If they're static, you can draw them to a Canvas, then draw the Canvas to screen.
caldur
Prole
Posts: 20
Joined: Tue Mar 13, 2012 3:30 pm

Re: Linking/merging drawings

Post by caldur »

Love doesn't have a built-in "shape batch" so to speak, but you can use Mesh to pack the vertices and draw them with one draw call... requires a little extra work though.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Linking/merging drawings

Post by Plu »

You can also wrap them into a function, and call that for the actual drawing.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests