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.
Re: Detecting proper framebuffers
Thanks, man, I've been meaning to rewrite that function.
Booted, suited, and ready to get executed.
Re: Detecting proper framebuffers
Why not patching the love API with a internal error catching ?
Something like :
Something like :
Code: Select all
if not love.graphics.newFramebufferOriginal then
love.graphics.newFramebufferOriginal = love.graphics.newFramebuffer
love.graphics.newFramebuffer = function(...)
local ok, ret = pcall(love.graphics.newFramebufferOriginal(...))
if ok then
return ret
end
return nil
end
end
My projects current projects : dragoon-framework (includes lua-newmodule, lua-provide, lovemodular, , classcommons2, and more ...)
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Detecting proper framebuffers
Remember! pcall operates like this:
not
It could also be more cleanly done like:
Code: Select all
pcall(func, args, ...)
Code: Select all
pcall(func(args, ...))
Code: Select all
local original = love.graphics.newFramebuffer
function love.graphics.newFramebuffer(...)
local ok, ret = pcall(original, ...)
return ok and ret or nil
end
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Detecting proper framebuffers
I actually had a library that wrapped functions (and even tables) with a single command.. I think it was on the old wiki though..
Re: Detecting proper framebuffers
Showoff.bartbes wrote:I actually had a library that wrapped functions (and even tables) with a single command.. I think it was on the old wiki though..
But really, how did that work? *is interested*
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
Probably something like this:
Code: Select all
function pwrap(func)
return function(...)
local ret = {pcall(func, ...)}
local ok = table.remove(ret, 1)
if not ok then return nil, ret[1] end
return unpack(ret)
end
end
-- call it like so:
love.graphics.newFramebuffer = pwrap(love.graphics.newFramebuffer)
Who is online
Users browsing this forum: Bing [Bot], slime and 4 guests