Rendering flicker

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
chimmihc
Prole
Posts: 13
Joined: Mon Oct 19, 2015 6:32 am

Rendering flicker

Post by chimmihc »

So with my current project I am making it with two rendering levels. "world objects" and "screen objects", world objects are rendered relative to the "camera" object's orientation, screen objects are relative to the screen.

The camera effects on the world objects are handled with the graphics coordinate system functions, so to avoid doing a bunch of math to "reverse" the effects when rendering the screen objects I am just editing the love.run function.

Original:

Code: Select all

love.graphics.clear()
love.graphics.origin()
if love.draw then love.draw() end
love.graphics.present()
Mine:

Code: Select all

love.graphics.clear()
love.graphics.origin()
if draw then -- draw is a function that handles world object drawing
	draw()
	love.graphics.present()
end
if drawScreen then -- drawScreen is a function that handles screen object drawing
	love.graphics.origin() -- reset the camera effects
	drawScreen() -- draw them
	love.graphics.present() -- render them
end
Now, as is, only the world objects are rendered smoothly, the screen objects are flickering for some reason.

What is causing this? And how can it be fixed?
Version 0.9.2
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Rendering flicker

Post by Nixola »

Why can't you just do this?

Code: Select all

 function love.draw()
  draw() 
  lg.origin()
  drawScreen() 
end

Anyway, check out [wiki]love.graphics.push[/wiki] and [wiki]love.graphics.pop[/wiki], they might be useful ;)
If you need/want to keep the code that way, you need to call love.graphics.present only once, after all of the drawing is done
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
chimmihc
Prole
Posts: 13
Joined: Mon Oct 19, 2015 6:32 am

Re: Rendering flicker

Post by chimmihc »

Nixola wrote:If you need/want to keep the code that way, you need to call love.graphics.present only once, after all of the drawing is done
That actually fixed it, thanks. I wasn't sure if it the double rendering was needed or not so I just did it.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests