Like a spritebatch for vectors?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
feelixe
Prole
Posts: 36
Joined: Tue Aug 20, 2013 10:29 am

Like a spritebatch for vectors?

Post by feelixe »

Hey! I'm making a game with alot om lines and rectangles, like a 1000 of each. The only thing they do is strech in Y and X and move ofcourse. So i thought of a canvas to make it more efficent, but then it's not vectorized. So i thought of a spritebatch, but thats only for textures.

Is there anything like a spritebatch but only for rectangles and line? Would really help, thanks! :awesome:
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Like a spritebatch for vectors?

Post by Nixola »

You can use a 1x1 white texture and scaling/rotation when adding it to a spritebatch. For example, Spritebatch:add(0, 0, -math.pi/2, 256, 1) would create a line, 256 pixels in length, rotated by -pi/2.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
feelixe
Prole
Posts: 36
Joined: Tue Aug 20, 2013 10:29 am

Re: Like a spritebatch for vectors?

Post by feelixe »

Nixola wrote:You can use a 1x1 white texture and scaling/rotation when adding it to a spritebatch. For example, Spritebatch:add(0, 0, -math.pi/2, 256, 1) would create a line, 256 pixels in length, rotated by -pi/2.
Thank you, but if i then draw the spritebatch and scale it the lines will get pixelated, since it's not a true vector. Any fix for that?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Like a spritebatch for vectors?

Post by Nixola »

I'd say scale the lines themselves when adding them to the batch instead of the whole spritebatch. I would try and come up with a demo or something (as well as testing it, as I am not completely sure it would work) but I currently can't.
P. S: clearing a spritebatch and putting everything back in it every frame is still faster than drawing each line separately with lg.rectangle.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Like a spritebatch for vectors?

Post by T-Bone »

Maybe you could use meshes? I haven't been playing around much with those, so I'm not sure they'll solve your problem but they do let you preload shapes to the GPU which sounds like pretty much what you'd want to do.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 209 guests