First import and review of vrld's patch

This commit is contained in:
Bart van Strien
2010-08-10 16:23:11 +02:00
parent 310a50ba2f
commit 8362e86627
9 changed files with 292 additions and 31 deletions
+58
View File
@@ -0,0 +1,58 @@
#include "wrap_Fbo.h"
namespace love
{
namespace graphics
{
namespace opengl
{
Fbo * luax_checkfbo(lua_State * L, int idx)
{
return luax_checktype<Fbo>(L, idx, "Fbo", GRAPHICS_FBO_T);
}
int w_Fbo_render(lua_State * L)
{
Fbo * fbo = luax_checkfbo(L, 1);
if (!lua_isfunction(L, 2))
return luaL_error(L, "Need a function to render to fbo");
fbo->bind();
lua_settop(L, 2); // make sure the function is on top of the stack
lua_pcall(L, 0, 0, 0);
fbo->unbind();
return 0;
}
int w_Fbo_bind(lua_State * L)
{
Fbo * fbo = luax_checkfbo(L, 1);
fbo->bind();
return 0;
}
int w_Fbo_unbind(lua_State * L)
{
Fbo * fbo = luax_checkfbo(L, 1);
fbo->unbind();
return 0;
}
static const luaL_Reg functions[] = {
{ "render", w_Fbo_render },
{ "bind", w_Fbo_bind },
{ "unbind", w_Fbo_unbind },
{ 0, 0 }
};
int luaopen_fbo(lua_State * L)
{
return luax_register_type(L, "Fbo", functions);
}
} // opengl
} // graphics
} // love