Add missing files

This commit is contained in:
vrld
2011-07-24 14:08:11 +02:00
parent 24a52f056b
commit 7b6836466e
5 changed files with 461 additions and 1 deletions
@@ -0,0 +1,117 @@
#include "wrap_PixelEffect.h"
#include "wrap_Image.h"
#include "wrap_Framebuffer.h"
#include <string>
namespace love
{
namespace graphics
{
namespace opengl
{
PixelEffect * luax_checkpixeleffect(lua_State * L, int idx)
{
return luax_checktype<PixelEffect>(L, idx, "PixelEffect", GRAPHICS_PIXELEFFECT_T);
}
int w_PixelEffect_getWarnings(lua_State * L)
{
PixelEffect * effect = luax_checkpixeleffect(L, 1);
lua_pushstring(L, effect->getWarnings().c_str());
return 1;
}
int w_PixelEffect_sendFloat(lua_State * L)
{
size_t count = lua_gettop(L) - 2;
PixelEffect * effect = luax_checkpixeleffect(L, 1);
const char* name = luaL_checkstring(L, 2);
if (count < 1 || count > 4)
return luaL_error(L, "Invalid variable count (expected 1-4, got %d).", count);
float values[4] = {0,0,0,0};
for (int i = 0; i < count; ++i)
values[i] = luaL_checknumber(L, i+1 + 2);
try {
effect->sendFloat(name, count, values);
} catch(love::Exception& e) {
luaL_error(L, e.what());
}
return 0;
}
int w_PixelEffect_sendMatrix(lua_State * L)
{
size_t count = lua_gettop(L) - 3;
PixelEffect * effect = luax_checkpixeleffect(L, 1);
const char* name = luaL_checkstring(L, 2);
int size = luaL_checkinteger(L, 3);
if (size < 2 || size > 4)
return luaL_error(L, "Invalid matrix size: %dx%d (only 2x2, 3x3 and 4x4 matrices are supported).", count, count);
float values[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
for (int i = 0; i < count; ++i)
values[i] = luaL_checknumber(L, i+1 + 3);
try {
effect->sendFloat(name, size, values);
} catch(love::Exception& e) {
luaL_error(L, e.what());
}
return 0;
}
int w_PixelEffect_sendImage(lua_State * L)
{
PixelEffect * effect = luax_checkpixeleffect(L, 1);
const char* name = luaL_checkstring(L, 2);
Image* img = luax_checkimage(L, 3);
try {
effect->sendImage(name, *img);
} catch(love::Exception& e) {
luaL_error(L, e.what());
}
return 0;
}
int w_PixelEffect_sendFramebuffer(lua_State * L)
{
PixelEffect * effect = luax_checkpixeleffect(L, 1);
const char* name = luaL_checkstring(L, 2);
Framebuffer* fb = luax_checkfbo(L, 3);
try {
effect->sendFramebuffer(name, *fb);
} catch(love::Exception& e) {
luaL_error(L, e.what());
}
return 0;
}
static const luaL_Reg functions[] = {
{ "getWarnings", w_PixelEffect_getWarnings },
{ "sendFloat", w_PixelEffect_sendFloat },
{ "sendMatrix", w_PixelEffect_sendMatrix },
{ "sendImage", w_PixelEffect_sendImage },
{ "sendFramebuffer", w_PixelEffect_sendFramebuffer },
{ 0, 0 }
};
int luaopen_pixeleffect(lua_State * L)
{
return luax_register_type(L, "PixelEffect", functions);
}
} // opengl
} // graphics
} // love