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!
Like a spritebatch for vectors?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Like a spritebatch for vectors?
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
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Like a spritebatch for vectors?
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?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.
Re: Like a spritebatch for vectors?
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.
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
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Like a spritebatch for vectors?
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.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: Google [Bot] and 3 guests