Posted 16 March 2013 - 02:49 AM
I've been working on making a display buffer. However, the method I have used actually reduces the frame rate.
Just drawing the character I averaged 195 FPS, doing the buffer calculations I got 150FPS. Now, that is a large margin, especially considering that there was only about 100 characters on the screen.
Here is the code I am using to draw my buffer (note that a 'pixel' contains 3 indexes, character, text colour and background colour)
So essentially, what I am asking is, is it actually slower to use a buffer or have I just made a bad implementation (most likely)
Just drawing the character I averaged 195 FPS, doing the buffer calculations I got 150FPS. Now, that is a large margin, especially considering that there was only about 100 characters on the screen.
Here is the code I am using to draw my buffer (note that a 'pixel' contains 3 indexes, character, text colour and background colour)
for y,row in pairs(Drawing.Buffer) do
for x,pixel in pairs(row) do
--this needs to be fixed, ive done some benchmarks and...
--this method averaged 150-160 fps
--just drawing it averaged 190-200fps
local shouldDraw = false
local hasBackBuffer = true
if Drawing.BackBuffer[y] == nil or Drawing.BackBuffer[y][x] == nil or #Drawing.BackBuffer[y][x] ~= 3 then
hasBackBuffer = false
end
if hasBackBuffer and Drawing.BackBuffer[y][x][1] == Drawing.Buffer[y][x][1] and Drawing.BackBuffer[y][x][2] == Drawing.Buffer[y][x][2] and Drawing.BackBuffer[y][x][3] == Drawing.Buffer[y][x][3] then
shouldDraw = false
end
if shouldDraw then
term.setBackgroundColour(pixel[3])
term.setTextColour(pixel[2])
term.setCursorPos(x, y)
term.write(pixel[1])
end
end
end
Drawing.BackBuffer = Drawing.Buffer
So essentially, what I am asking is, is it actually slower to use a buffer or have I just made a bad implementation (most likely)