How to NOT clear the background automatically

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
robd
Prole
Posts: 2
Joined: Sun Jul 07, 2024 3:08 pm

How to NOT clear the background automatically

Post by robd »

I'm trying to teach a creative coding course using love2d instead of processing or p5js as I have done in the past. A common thing that we do is draw to a canvas repeatedly, without clearing the canvas between frames. For games, it makes sense that the background is automatically cleared each frame in love2d - is there a way to disable that behavior?

Thanks!
Rob
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How to NOT clear the background automatically

Post by slime »

You can use a Canvas for that, by drawing to the canvas every frame without explicitly calling love.graphics.clear.

It is technically possible to modify love.run to not clear the screen backbuffer as well, but I strongly recommend you not do that. The screen backbuffer is double-buffered by the OS on most systems, which means it keeps different copies for different frames so you won't have the behaviour you'd expect. The OS will also trash the contents of the backbuffer when the user does different things (like covering the app window with another, or minimizing it, etc.)
Post Reply

Who is online

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