Code: Select all
function love.load()
enabled = false
translate = {x=0, y=0}
image = love.graphics.newImage("image.png")
fb = love.graphics.newFramebuffer(6000,6000)
imageSet = {}
for i=0, 10000, 1 do
local entry = {x=math.random(6000), y=math.random(6000)}
table.insert(imageSet, entry)
--alternative method to draw to framebuffer
fb:renderTo(
function()
love.graphics.draw(image,entry.x,entry.y)
end
)
--]]
end
--[[method to draw to framebuffer
love.graphics.setRenderTarget(fb)
for _,v in ipairs(imageSet) do
love.graphics.draw(image, v.x, v.y)
end
love.graphics.setRenderTarget()
--]]
end
function love.update(dt)
if love.keyboard.isDown("left") then
translate.x = translate.x + 1000*dt
elseif love.keyboard.isDown("right") then
translate.x = translate.x - 1000*dt
end
if love.keyboard.isDown("up") then
translate.y = translate.y + 1000*dt
elseif love.keyboard.isDown("down") then
translate.y = translate.y - 1000*dt
end
end
function love.draw()
love.graphics.push()
love.graphics.translate(translate.x, translate.y)
if enabled then
love.graphics.draw(fb,0,0)
love.graphics.pop()
love.graphics.print("Framebuffer rendering enabled",0,0)
else
for _,v in ipairs(imageSet) do
love.graphics.draw(image, v.x, v.y)
end
love.graphics.pop()
love.graphics.print("Framebuffer rendering disabled",0,0)
end
end
function love.keypressed(k)
if k==" " then
enabled = not enabled
end
end