love.graphics.present() + dirty rects?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
napco
Party member
Posts: 129
Joined: Fri Jun 12, 2009 9:28 pm
Location: Ital... ehm...

love.graphics.present() + dirty rects?

Post 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?
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

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

Post by TechnoCat »

Where can I find an explanation on dirty rectangles?
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

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

Post 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.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

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

Post by TechnoCat »

I guess this would be utilizing 0.6.0's frames.
User avatar
Pliskin09
Citizen
Posts: 89
Joined: Fri Jul 24, 2009 8:30 am

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

Post 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
User avatar
napco
Party member
Posts: 129
Joined: Fri Jun 12, 2009 9:28 pm
Location: Ital... ehm...

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

Post 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.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

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

Post 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)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post by bartbes »

About that: frames were renamed to quads.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

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

Post by rude »

Just avoid love.graphics.clear, and overwrite the area you want to update each frame.
drvillain
Prole
Posts: 3
Joined: Tue Sep 22, 2009 4:58 am

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

Post by drvillain »

what kind of preformace boost are you getting using frames + quads?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests