Detecting proper framebuffers

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
Ertain
Citizen
Posts: 55
Joined: Fri Nov 19, 2010 9:38 pm
Location: Texas, U.S.A.

Detecting proper framebuffers

Post by Ertain »

Hello again, LÖVErs.

I have seen other posters struggle with actually detecting framebuffer support. Truthfully I'm trying to figure it out myself. So has anyone actually ironed out a surefire way to detect for framebuffers? Just using the function "love.graphics.newFramebuffer()" doesn't cut it. I have thought of detecting the version of LÖVE but that sure as heck doesn't work, either.
Booted, suited, and ready to get executed.
User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: Detecting proper framebuffers

Post by ishkabible »

just a hack i thought of that might work, if you use pcall you might be able to detect an error without the program shutting down. just an idea however, probably not the best way but certainly a way.
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Detecting proper framebuffers

Post by slime »

Yeah, using pcall should work great. As long as you use pcall correctly. ;)
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Detecting proper framebuffers

Post by Jasoco »

In my current project I use pcall to call the function that creates the buffers. Then if it's returned false with an error, I just use a workaround so the game continues but with less "awesomeness". Unfortunately I don't have an incompatible computer to test its failure mode on. Eventually I'll just ask someone here who doesn't have support to test it out.

But pcall should work. I believe it returns whatever the function returns as well as the text for the error.
The internet wrote:Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.
User avatar
Ertain
Citizen
Posts: 55
Joined: Fri Nov 19, 2010 9:38 pm
Location: Texas, U.S.A.

Re: Detecting proper framebuffers

Post by Ertain »

So I should use something like this?

Code: Select all

if pcall( love.graphics.newFramebuffer() ) then
-- Use the framebuffer here.
else
-- Use some other code here.
end
Booted, suited, and ready to get executed.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Detecting proper framebuffers

Post by BlackBulletIV »

No. The main problem is that you don't call love.graphics.newFramebuffer and give its results to pcall, you can the function to pcall, following by your desired arguments. pcall returns a status (true or false from memory - I do know it's false on failure) and then whatever the function returned.

So, more like this:

Code: Select all

status, fb = pcall(love.graphics.newFramebuffer, width, height)

if status then
  -- use fb
else
  -- do something else
end
User avatar
Ertain
Citizen
Posts: 55
Joined: Fri Nov 19, 2010 9:38 pm
Location: Texas, U.S.A.

Re: Detecting proper framebuffers

Post by Ertain »

Thanks, guys, I'll try that out.
*Tries that out*
Now if I could only get the frame rate under control (and get this nasty freeze-up solved).
Booted, suited, and ready to get executed.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Detecting proper framebuffers

Post by Lafolie »

You're not creating the framebuffer and doing a whole bunch of unnecessary drawing-related calls each loop are you? Some more information would allow us to help you with this buddy :)

BlackBulletIV is right in that it does return a boolean based on success. Actually, my code just checks if it exists.... I'm sure it just returns true or nil though.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Ertain
Citizen
Posts: 55
Joined: Fri Nov 19, 2010 9:38 pm
Location: Texas, U.S.A.

Re: Detecting proper framebuffers

Post by Ertain »

I think I am do some unnecessary drawing calls each update. Some of my functions still do drawing even when the enemy is off the screen. So I think I'll add code to see if they've left the screen and stop drawing them. That might alleviate the problem a little.

On one function I'm trying to draw several enemies on the screen and at the same time I'm moving their respective boundary circles (so as to see if they've collided. I'm using vrid's hardon collider).
Booted, suited, and ready to get executed.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Detecting proper framebuffers

Post by Lafolie »

Code: Select all

if enemy.x - enemy.sprite:getWidth() > 0 and enemy.x + enemy.sprite:getWidth() < love.graphics.getWidth()  and enemy.y - enemy.sprite:getHeight() > 0  and enemy.y + enemy.sprite:getHeight() < love.graphics.getHeight() then 
     enemy:draw() 
end
Something like that should help.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], pgimeno and 95 guests