Re: Teaser for a game I'm working on...
Posted: Fri Apr 01, 2011 6:28 am
I don't suppose that would help me if I need a specific number of buffers but the computer only allows a couple and the pcall still passes the test.
You could put the creation of framebuffers in a function (in a loop or whatever), and pcall that function. If it fails, you know you don't have enough framebuffers and you need to fall back to something else.Jasoco wrote:I don't suppose that would help me if I need a specific number of buffers but the computer only allows a couple and the pcall still passes the test.
And if it succeeds, I won't have to call it again, right?Robin wrote:You could put the creation of framebuffers in a function (in a loop or whatever), and pcall that function. If it fails, you know you don't have enough framebuffers and you need to fall back to something else.Jasoco wrote:I don't suppose that would help me if I need a specific number of buffers but the computer only allows a couple and the pcall still passes the test.
Code: Select all
success, result = pcall(createBuffers)
Code: Select all
success, result = pcall(createBuffers())
Code: Select all
--from
error("Demo")
--to
pcall(error, "Demo")
Code: Select all
function createBuffers()
fb = {
floor = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
objects = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
osd = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
rays = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
scroll = gr.newFramebuffer(math.max(g.w,512), math.max(g.h,512))
}
for i, f in pairs(fb) do
f:setFilter("nearest", "nearest")
end
return true
end