Most of the time, one just needs to draw fixed rectangles from a texture. It's a very uncommon operation to draw a variable rectangle from a texture. If you need to draw just one such quad, you can probably use newQuad every frame (not tested - YMMV), but if you need to do that multiple times, maybe you can use a shader instead.
Edit: I get 880 FPS with this program. I'm curious as to what performance others see.
Code: Select all
local img
local lg = love.graphics
local t = {}
function love.load()
img = love.graphics.newImage("image1.jpg")
img:setWrap("repeat", "repeat")
love.window.setMode(640,480, {vsync=false})
lg.setDefaultFilter("nearest","nearest")
for i = 1, 12 do
local tt = {}
tt.x = love.math.random(0, 639)
tt.y = love.math.random(0, 479)
tt.vx = love.math.random() * 150 - 75
tt.vy = love.math.random() * 150 - 75
t[i] = tt
end
end
function love.update(dt)
for i = 1, 12 do
local tt = t[i]
tt.x = (tt.x + tt.vx * dt) % 640
tt.y = (tt.y + tt.vy * dt) % 480
end
end
function love.draw()
i = 1
for y = 0, 479, 160 do
for x = 0, 639, 160 do
lg.draw(img, lg.newQuad(t[i].x, t[i].y, 160, 160, 640, 480), x, y)
i = i + 1
end
end
lg.print(string.format("FPS=%d mem=%d",love.timer.getFPS(), collectgarbage("count")))
end
function love.keypressed(k)
if k == "escape" then love.event.quit() end
end