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.
Detecting proper framebuffers
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Detecting proper framebuffers
Booted, suited, and ready to get executed.
- ishkabible
- Party member
- Posts: 241
- Joined: Sat Oct 23, 2010 7:34 pm
- Location: Kansas USA
Re: Detecting proper framebuffers
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.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Detecting proper framebuffers
Yeah, using pcall should work great. As long as you use pcall correctly.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Detecting proper framebuffers
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.
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.
Re: Detecting proper framebuffers
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.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Detecting proper framebuffers
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:
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
Re: Detecting proper framebuffers
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).
*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.
Re: Detecting proper framebuffers
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.
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.
Re: Detecting proper framebuffers
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).
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.
Re: Detecting proper framebuffers
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
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.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests