Page 1 of 1

love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 12:26 am
by napco
I've read in the wiki that in the love 0.6.0 version we'll be able to rewrite the main loop... So... Could we use the love.graphics.present() function to draw only a part of the screen, using the so called dirty rects technique?

Re: love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 1:24 am
by TechnoCat
Where can I find an explanation on dirty rectangles?

Re: love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 2:46 am
by osgeld
http://www.gamedev.net/dict/term.asp?TermID=501
A method of updating only the changed parts of the screen. The screen is divided up into rectangles and only rectangles that have changes are makred "dirty" and then are redrawn to clean them up. Increases drawing speed as less is drawn.

Re: love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 4:13 am
by TechnoCat
I guess this would be utilizing 0.6.0's frames.

Re: love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 6:42 am
by Pliskin09
it'd be good if something like this could be handled by the engine. perhaps you'd enable it in the config file or something like that

Re: love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 11:23 am
by napco
Yes, i think Frames would help, but with love.graphics.present() the entire screen will always be redrawn every frame. If we could pass a list of rectangles to the function so that other parts of the screen not included in the list won't be redrawn, we could speed up 2d games a bit... For example: If in a 2d tile based game without map scrolling i move the player by one tile down, instead of redrawing the entire screen, i would pass to the function only a rect including 2 tiles: the origin of the movement and the arrival.

Re: love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 1:50 pm
by TechnoCat
I think this is what you are looking for?

Version 0.6.0
Also planned are FrameBuffers.

fb = love.graphics.newFrameBuffer( width, height )
love.graphics.setFrameBuffer( fb )
love.graphics.draw( image, x, y ) -- draws into fb.
love.graphics.setFrameBuffer() -- Change back to screen.
love.graphics.draw( fb, 0, 0, 0, 2, 2) -- Draw the framebuffer to the screen (scaled).

Further, we have Frames:

frame = love.graphics.newFrame( image, x, y, w, h )
love.graphics.draw( frame, x, y, angle, sx, sy, ox, oy )

-- API:
frame = love.graphics.newFrame( image ) -- Entire image (not directly useful).
frame = love.graphics.newFrame( image, x, y, w, h ) -- Part of image.
frame = love.graphics.newFrame( image, s0,t0,s1,t1,s2,t2,s3,t3 ) -- Custom texels entire image.
frame = love.graphics.newFrame( image, x, y, w, h, s0,t0,s1,t1,s2,t2,s3,t3 ) -- Custom texels part of image.
frame:flip( x, y ) -- Flips the frame horizontally (x=true) and/or vertically (y=true)
love.graphics.draw(frame, x, y, angle, sx, sy, ox, oy)

Re: love.graphics.present() + dirty rects?

Posted: Thu Aug 20, 2009 2:52 pm
by bartbes
About that: frames were renamed to quads.

Re: love.graphics.present() + dirty rects?

Posted: Sat Aug 22, 2009 11:13 am
by rude
Just avoid love.graphics.clear, and overwrite the area you want to update each frame.

Re: love.graphics.present() + dirty rects?

Posted: Tue Sep 22, 2009 3:51 pm
by drvillain
what kind of preformace boost are you getting using frames + quads?