mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Move fbo:grab() to love.graphics.setRenderTarget( fbo ) Move fbo:stop() to love.graphics.setRenderTarget( nil ) Rename fbo:render( func ) to fbo:renderTo( func )
This commit is contained in:
@@ -11,51 +11,29 @@ namespace opengl
|
||||
return luax_checktype<Framebuffer>(L, idx, "Framebuffer", GRAPHICS_FRAMEBUFFER_T);
|
||||
}
|
||||
|
||||
int w_Framebuffer_render(lua_State * L)
|
||||
int w_Framebuffer_renderTo(lua_State * L)
|
||||
{
|
||||
// As startGrab() clears the framebuffer, better not allow
|
||||
// grabbing inside another grabbing
|
||||
if (Framebuffer::current != NULL) {
|
||||
Framebuffer::bindDefaultBuffer();
|
||||
return luaL_error(L, "Current render target not the default framebuffer!");
|
||||
}
|
||||
|
||||
Framebuffer * fbo = luax_checkfbo(L, 1);
|
||||
if (!lua_isfunction(L, 2))
|
||||
return luaL_error(L, "Need a function to render to fbo");
|
||||
|
||||
// prevent nesting
|
||||
if (!fbo->grab()) {
|
||||
fbo->stop(); // stop grabbing so errormessage is shown
|
||||
return luaL_error(L, "Framebuffer:grab(): Cannot grab screen. Be sure to match every Framebuffer:grab() with Framebuffer:stop().");
|
||||
}
|
||||
|
||||
fbo->startGrab();
|
||||
lua_settop(L, 2); // make sure the function is on top of the stack
|
||||
lua_call(L, 0, 0);
|
||||
fbo->stopGrab();
|
||||
|
||||
// fbo can be stopped in function.
|
||||
if (!fbo->stop())
|
||||
return luaL_error(L, "Framebuffer:render(): Screengrabbing already stopped.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Framebuffer_grab(lua_State * L)
|
||||
{
|
||||
Framebuffer * fbo = luax_checkfbo(L, 1);
|
||||
// prevent nesting
|
||||
if (!fbo->grab()) {
|
||||
fbo->stop(); // stop grabbing so errormessage is shown
|
||||
return luaL_error(L, "Framebuffer:grab(): Cannot grab screen. Be sure to match every Framebuffer:grab() with Framebuffer:stop().");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Framebuffer_stop(lua_State * L)
|
||||
{
|
||||
Framebuffer * fbo = luax_checkfbo(L, 1);
|
||||
if (!fbo->stop())
|
||||
return luaL_error(L, "Framebuffer:stop(): Screengrabbing already stopped.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "render", w_Framebuffer_render },
|
||||
{ "grab", w_Framebuffer_grab },
|
||||
{ "stop", w_Framebuffer_stop },
|
||||
{ "renderTo", w_Framebuffer_renderTo },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user