Spritebatch doesn't speed up things?
Posted: Sat Jan 04, 2014 3:25 pm
Hi people,
When I run below codes I get similar FPS. Shouldn't I get more when using a spritebatch considering it's single draw call vs 200 per frame?
Second question, when I look at wiki examples about spritebatch I've noticed that bind() and unbind() are not used. When should I use them exactly? In below examples it didn't make any difference.
Thanks
When I run below codes I get similar FPS. Shouldn't I get more when using a spritebatch considering it's single draw call vs 200 per frame?
Second question, when I look at wiki examples about spritebatch I've noticed that bind() and unbind() are not used. When should I use them exactly? In below examples it didn't make any difference.
Thanks
Code: Select all
function love.load()
image = love.graphics.newImage("sprite.png")
sb = love.graphics.newSpriteBatch(image, 250)
q1 = love.graphics.newQuad(0, 0, 128, 128, 256, 256)
q2 = love.graphics.newQuad(0, 128, 128, 128, 256, 256)
q3 = love.graphics.newQuad(128, 0, 128, 128, 256, 256)
q4 = love.graphics.newQuad(128, 128, 128, 128, 256, 256)
end
function love.update(dt)
sb:clear()
for i = 1, 50, 1 do
sb:add(q1, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
sb:add(q2, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
sb:add(q3, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
sb:add(q4, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
end
end
function love.draw()
love.graphics.draw(sb)
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 0, 0)
end
Code: Select all
function love.load()
image = love.graphics.newImage("sprite.png")
sb = love.graphics.newSpriteBatch(image, 250)
q1 = love.graphics.newQuad(0, 0, 128, 128, 256, 256)
q2 = love.graphics.newQuad(0, 128, 128, 128, 256, 256)
q3 = love.graphics.newQuad(128, 0, 128, 128, 256, 256)
q4 = love.graphics.newQuad(128, 128, 128, 128, 256, 256)
end
function love.update(dt)
end
function love.draw()
for i = 1, 50, 1 do
love.graphics.draw(image, q1, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
love.graphics.draw(image, q2, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
love.graphics.draw(image, q3, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
love.graphics.draw(image, q4, math.random(0, love.window.getWidth()), math.random(0, love.window.getHeight()))
end
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS()), 0, 0)
end