How to use Framebuffer:renderTo() properly

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

Re: How to use Framebuffer:renderTo() properly

Post by TechnoCat »

Implementation error I'm guessing?
User avatar
adrix89
Party member
Posts: 135
Joined: Fri Oct 15, 2010 10:58 am

Re: How to use Framebuffer:renderTo() properly

Post by adrix89 »

tentus wrote:I did before posting (sorry I didn't mention that). Same result. I could whip up a screenshot if that would help?
What video card do you have? might be that you don't actually have framebuffers
I use Workflowy but you can check out Dynalist as its the better offer.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by vrld »

adrix89 wrote:What video card do you have? might be that you don't actually have framebuffers
In that case the error message should read Not supported by your OpenGL implementation or May not be supported by your OpenGL implementation. The error in implementation error can be caused by a lot of things, but is most of the time because (1) the graphics card did something unexpected or (2) the system's OpenGL implementation is incomplete/wrong. Either way, there is not much one can do about it :(
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by tentus »

Like I said, I tested this on my work machine, so video card is practically nonexistent.
I guess I'm just SOL, short of using ImageData:paste as it was never meant to be used?
Attachments
fb.png
fb.png (33.8 KiB) Viewed 7063 times
Kurosuke needs beta testers
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by vrld »

As it says in the error message: Framebuffers are not supported on your computer. I guess your graphics chip is too old... :P
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by tentus »

Huh, I would have thought a Intel(R) 82945G Express Chipset Family would be up to it. :( I'll do some playing around with drivers, see what I can rig up.

In the meantime, is there a way to test for fb support in love.load, so that we can jump to a more elegant error screen? I hate showing blue screens.

Edit: man, intel's driver distribution is more rubbish than I recall. I know exactly what I want, why won't they give me a link?
Kurosuke needs beta testers
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by bmelts »

The blue screens are just LÖVE's custom way of handling any Lua errors it receives. It's simple enough to intercept the errors before they get to that level, using Lua's built-in pcall and xpcall functions. So you'd probably want something like this:

Code: Select all

fb = pcall(love.graphics.newFramebuffer, scene.width, scene.height)
if not fb then
   -- set up your program so that love.draw shows a nicer error screen
else
   -- continue doing awesome normal loady things
end
User avatar
benloran
Prole
Posts: 19
Joined: Tue Jul 05, 2011 4:52 pm

Re: How to use Framebuffer:renderTo() properly

Post by benloran »

TechnoCat wrote:Now that 0.7.0 is released and framebuffers are window dimension independent.
Here is a framebuffer example. They are very cool.

Code: Select all

function love.load()
  enabled = false
  image = love.graphics.newImage("image.png")
  
  translate = {x=0, y=0}
  scene = {}
  scene.width = 2048
  scene.height = 2048
  
  --Iniitialize framebuffer
  fb = love.graphics.newFramebuffer(scene.width, scene.height)
  
  --Create random objects placed everywhere
  imageSet = {}
  for i = 1, 10000 do
    local entry = {}
    entry.x = math.random(scene.width-128)
    entry.y = math.random(scene.height-128)
    imageSet[i] = entry
  end
  
  --Draw them to the framebuffers
  -- This is my preferable method
  love.graphics.setRenderTarget(fb)
  for _,v in ipairs(imageSet) do
    love.graphics.draw(image, v.x, v.y)
  end
  love.graphics.setRenderTarget()
  --]]
  --[[ This is the other method
  fb:renderTo(
      function()
        for _,v in ipairs(imageSet) do
          love.graphics.draw(image, v.x, v.y)
        end
      end
  )
  --]]
end


function love.update(dt)
  if love.keyboard.isDown("left") then
    translate.x = translate.x + 1000*dt
  elseif love.keyboard.isDown("right") then
    translate.x = translate.x - 1000*dt
  end
  
  if love.keyboard.isDown("up") then
    translate.y = translate.y + 1000*dt
  elseif love.keyboard.isDown("down") then
    translate.y = translate.y - 1000*dt
  end 
end

function love.draw()
  love.graphics.push()
  love.graphics.translate(translate.x, translate.y)
  if enabled then
    love.graphics.draw(fb, 0, 0)
  else
    for _,v in ipairs(imageSet) do
      love.graphics.draw(image, v.x, v.y)
    end
  end
  love.graphics.pop()
  
  fps = love.timer.getFPS()
  if enabled then
    love.graphics.setCaption(fps.." Framebuffer rendering enabled",0,0)
  else
    love.graphics.setCaption(fps.." Framebuffer rendering disabled",0,0)
  end
end

function love.keypressed(k)
  if k==" " then
    enabled = not enabled
  end
end
(I know this thread is kind of old, but...)

I've been playing around with this demo (thanks by the way, it's very informative). What I don't understand is why the edges of the images look different depending on whether they're drawn to the frame buffer first or straight to the screen.

When drawn to the frame buffer, the alphas appear to not be blending correctly at the edges. I tried explicitly setting the blend mode to 'alpha' after setting the render target to the frame buffer, but that made no difference.

Here's what I mean:

no framebuffer:
Image

framebuffer:
Image

difference:
Image

Is anyone else seeing this, or is it just me? Anyone know what's going on?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by Robin »

Yeah, I get the same. No idea why, but there you have it.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by Jasoco »

What color is the background? As I've mentioned before and have had a discussion about the inability for Löve to do it, but this would not be a problem if FrameBuffers could support alpha transparency. The edges around those circles are because FB's can't do alpha. Only solid or transparent like a GIF. Not alpha like a PNG. Sucks. But I'm more a 16-bit homage person so none of my graphics really have alpha edges.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 68 guests