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!
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
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?
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
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.