My pleasure. 8-)rude wrote: Thanks for ruining the surprise
Allright ... I guess we need both streaming texture updates and render-to-texture.
For dynamic textures, how about:
Code: Select all
-- Amazing 2x2 white image.
white = {
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
}
-- Create some buffer with size 2x2.
buffer = love.graphics.newBuffer( 2, 2 )
-- At any time you can read pixels:
color = buffer:getPixel(0, 1)
-- Update certain pixels:
buffer:setPixel(0, 1, 128, 0, 0, 255)
-- Or update all pixels:
buffer:replace(white)
-- Texture will update automatically if changed.
love.graphics.draw(buffer, x, y)
Code: Select all
buffer = love.graphics.newBuffer( 2, 2 )
love.graphics.setTarget(buffer)
love.graphics.setPixel(1, 1, color) -- Rendered to texture.
love.graphics.draw(image, 0, 0) -- Rendered to texture.
love.graphics.setTarget(love.target_screen) -- "buffer" is uploaded to GPU here.
love.graphics.draw(buffer, 50, 50) -- Rendered to screen.