mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.
--HG-- branch : minor
This commit is contained in:
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Canvas *luax_checkcanvas(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Canvas>(L, idx, "Canvas", GRAPHICS_CANVAS_T);
|
||||
return luax_checktype<Canvas>(L, idx, GRAPHICS_CANVAS_ID);
|
||||
}
|
||||
|
||||
int w_Canvas_renderTo(lua_State *L)
|
||||
@@ -65,7 +65,7 @@ int w_Canvas_renderTo(lua_State *L)
|
||||
int w_Canvas_newImageData(lua_State *L)
|
||||
{
|
||||
Canvas *canvas = luax_checkcanvas(L, 1);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
|
||||
int x = luaL_optint(L, 2, 0);
|
||||
int y = luaL_optint(L, 3, 0);
|
||||
int w = luaL_optint(L, 4, canvas->getWidth());
|
||||
@@ -74,7 +74,7 @@ int w_Canvas_newImageData(lua_State *L)
|
||||
love::image::ImageData *img = nullptr;
|
||||
luax_catchexcept(L, [&](){ img = canvas->newImageData(image, x, y, w, h); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, img);
|
||||
img->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_canvas(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Canvas", functions);
|
||||
return luax_register_type(L, GRAPHICS_CANVAS_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Font *luax_checkfont(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
|
||||
return luax_checktype<Font>(L, idx, GRAPHICS_FONT_ID);
|
||||
}
|
||||
|
||||
int w_Font_getHeight(lua_State *L)
|
||||
@@ -186,7 +186,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_font(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Font", functions);
|
||||
return luax_register_type(L, GRAPHICS_FONT_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -203,7 +203,7 @@ int w_newImage(lua_State *L)
|
||||
bool releasedata = false;
|
||||
|
||||
// Convert to ImageData / CompressedData, if necessary.
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
|
||||
{
|
||||
love::image::Image *image = Module::getInstance<love::image::Image>(Module::M_IMAGE);
|
||||
if (image == nullptr)
|
||||
@@ -229,10 +229,10 @@ int w_newImage(lua_State *L)
|
||||
// Lua's GC won't release the image data, so we should do it ourselves.
|
||||
releasedata = true;
|
||||
}
|
||||
else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_T))
|
||||
cdata = luax_checktype<love::image::CompressedData>(L, 1, "CompressedData", IMAGE_COMPRESSED_DATA_T);
|
||||
else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_ID))
|
||||
cdata = luax_checktype<love::image::CompressedData>(L, 1, IMAGE_COMPRESSED_DATA_ID);
|
||||
else
|
||||
data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
data = luax_checktype<love::image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
|
||||
|
||||
if (!data && !cdata)
|
||||
return luaL_error(L, "Error creating image (could not load data.)");
|
||||
@@ -258,7 +258,7 @@ int w_newImage(lua_State *L)
|
||||
return luaL_error(L, "Could not load image.");
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, image);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, image);
|
||||
image->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ int w_newQuad(lua_State *L)
|
||||
float sh = (float) luaL_checknumber(L, 6);
|
||||
|
||||
Quad *quad = instance()->newQuad(v, sw, sh);
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quad);
|
||||
luax_pushtype(L, GRAPHICS_QUAD_ID, quad);
|
||||
quad->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ int w_newFont(lua_State *L)
|
||||
Font *font = nullptr;
|
||||
|
||||
// Convert to Rasterizer, if necessary.
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_T))
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
|
||||
{
|
||||
std::vector<int> idxs;
|
||||
for (int i = 0; i < lua_gettop(L); i++)
|
||||
@@ -294,14 +294,14 @@ int w_newFont(lua_State *L)
|
||||
luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newRasterizer");
|
||||
}
|
||||
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
|
||||
|
||||
luax_catchexcept(L, [&]() {
|
||||
font = instance()->newFont(rasterizer, instance()->getDefaultFilter()); }
|
||||
);
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, font);
|
||||
font->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -312,32 +312,32 @@ int w_newImageFont(lua_State *L)
|
||||
Texture::Filter filter = instance()->getDefaultFilter();
|
||||
|
||||
// Convert to ImageData if necessary.
|
||||
if (luax_istype(L, 1, GRAPHICS_IMAGE_T))
|
||||
if (luax_istype(L, 1, GRAPHICS_IMAGE_ID))
|
||||
{
|
||||
Image *i = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
Image *i = luax_checktype<Image>(L, 1, GRAPHICS_IMAGE_ID);
|
||||
filter = i->getFilter();
|
||||
love::image::ImageData *id = i->getImageData();
|
||||
if (!id)
|
||||
return luaL_argerror(L, 1, "Image must not be compressed.");
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, id);
|
||||
lua_replace(L, 1);
|
||||
}
|
||||
|
||||
// Convert to Rasterizer if necessary.
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_T))
|
||||
if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
|
||||
{
|
||||
luaL_checkstring(L, 2);
|
||||
int idxs[] = {1, 2};
|
||||
luax_convobj(L, idxs, 2, "font", "newImageRasterizer");
|
||||
}
|
||||
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
|
||||
|
||||
// Create the font.
|
||||
Font *font = instance()->newFont(rasterizer, filter);
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, font);
|
||||
font->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ int w_newSpriteBatch(lua_State *L)
|
||||
[&](){ t = instance()->newSpriteBatch(texture, size, usage); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, t);
|
||||
luax_pushtype(L, GRAPHICS_SPRITE_BATCH_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -376,7 +376,7 @@ int w_newParticleSystem(lua_State *L)
|
||||
[&](){ t = instance()->newParticleSystem(texture, int(size)); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
|
||||
luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -401,7 +401,7 @@ int w_newCanvas(lua_State *L)
|
||||
if (canvas == nullptr)
|
||||
return luaL_error(L, "Canvas not created, but no error thrown. I don't even...");
|
||||
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, canvas);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, canvas);
|
||||
canvas->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ int w_newShader(lua_State *L)
|
||||
try
|
||||
{
|
||||
Shader *shader = instance()->newShader(source);
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
|
||||
shader->release();
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
@@ -585,7 +585,7 @@ int w_newMesh(lua_State *L)
|
||||
if (tex)
|
||||
t->setTexture(tex);
|
||||
|
||||
luax_pushtype(L, "Mesh", GRAPHICS_MESH_T, t);
|
||||
luax_pushtype(L, GRAPHICS_MESH_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -603,7 +603,7 @@ int w_newText(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ t = instance()->newText(font, text); });
|
||||
}
|
||||
|
||||
luax_pushtype(L, "Text", GRAPHICS_TEXT_T, t);
|
||||
luax_pushtype(L, GRAPHICS_TEXT_ID, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -682,14 +682,14 @@ int w_getBackgroundColor(lua_State *L)
|
||||
int w_setNewFont(lua_State *L)
|
||||
{
|
||||
int ret = w_newFont(L);
|
||||
Font *font = luax_checktype<Font>(L, -1, "Font", GRAPHICS_FONT_T);
|
||||
Font *font = luax_checktype<Font>(L, -1, GRAPHICS_FONT_ID);
|
||||
instance()->setFont(font);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_setFont(lua_State *L)
|
||||
{
|
||||
Font *font = luax_checktype<Font>(L, 1, "Font", GRAPHICS_FONT_T);
|
||||
Font *font = luax_checktype<Font>(L, 1, GRAPHICS_FONT_ID);
|
||||
instance()->setFont(font);
|
||||
return 0;
|
||||
}
|
||||
@@ -699,7 +699,7 @@ int w_getFont(lua_State *L)
|
||||
Font *f = nullptr;
|
||||
luax_catchexcept(L, [&](){ f = instance()->getFont(); });
|
||||
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -913,13 +913,13 @@ int w_isWireframe(lua_State *L)
|
||||
|
||||
int w_newScreenshot(lua_State *L)
|
||||
{
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
|
||||
bool copyAlpha = luax_optboolean(L, 1, false);
|
||||
love::image::ImageData *i = 0;
|
||||
|
||||
luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i);
|
||||
i->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -971,7 +971,7 @@ int w_getCanvas(lua_State *L)
|
||||
|
||||
for (Canvas *c : canvases)
|
||||
{
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, c);
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ int w_getShader(lua_State *L)
|
||||
{
|
||||
Shader *shader = instance()->getShader();
|
||||
if (shader)
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
@@ -1172,10 +1172,10 @@ int w_draw(lua_State *L)
|
||||
Quad *quad = nullptr;
|
||||
int startidx = 2;
|
||||
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_T))
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
|
||||
{
|
||||
texture = luax_checktexture(L, 1);
|
||||
quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
|
||||
quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
|
||||
startidx = 3;
|
||||
}
|
||||
else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
|
||||
@@ -1184,7 +1184,7 @@ int w_draw(lua_State *L)
|
||||
}
|
||||
else
|
||||
{
|
||||
drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
|
||||
drawable = luax_checktype<Drawable>(L, 1, GRAPHICS_DRAWABLE_ID);
|
||||
startidx = 2;
|
||||
}
|
||||
|
||||
@@ -1595,7 +1595,7 @@ extern "C" int luaopen_love_graphics(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "graphics";
|
||||
w.flags = MODULE_GRAPHICS_T;
|
||||
w.type = MODULE_GRAPHICS_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Image *luax_checkimage(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
|
||||
return luax_checktype<Image>(L, idx, GRAPHICS_IMAGE_ID);
|
||||
}
|
||||
|
||||
int w_Image_setMipmapFilter(lua_State *L)
|
||||
@@ -96,18 +96,12 @@ int w_Image_getData(lua_State *L)
|
||||
if (i->isCompressed())
|
||||
{
|
||||
love::image::CompressedData *t = i->getCompressedData();
|
||||
if (t)
|
||||
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
love::image::ImageData *t = i->getImageData();
|
||||
if (t)
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -134,7 +128,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_image(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Image", functions);
|
||||
return luax_register_type(L, GRAPHICS_IMAGE_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace opengl
|
||||
|
||||
Mesh *luax_checkmesh(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Mesh>(L, idx, "Mesh", GRAPHICS_MESH_T);
|
||||
return luax_checktype<Mesh>(L, idx, GRAPHICS_MESH_ID);
|
||||
}
|
||||
|
||||
int w_Mesh_setVertex(lua_State *L)
|
||||
@@ -265,9 +265,9 @@ int w_Mesh_getTexture(lua_State *L)
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
|
||||
else
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
|
||||
@@ -368,7 +368,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_mesh(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Mesh", functions);
|
||||
return luax_register_type(L, GRAPHICS_MESH_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace opengl
|
||||
|
||||
ParticleSystem *luax_checkparticlesystem(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<ParticleSystem>(L, idx, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T);
|
||||
return luax_checktype<ParticleSystem>(L, idx, GRAPHICS_PARTICLE_SYSTEM_ID);
|
||||
}
|
||||
|
||||
int w_ParticleSystem_clone(lua_State *L)
|
||||
@@ -51,7 +51,7 @@ int w_ParticleSystem_clone(lua_State *L)
|
||||
ParticleSystem *clone = nullptr;
|
||||
luax_catchexcept(L, [&](){ clone = t->clone(); });
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, clone);
|
||||
luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, clone);
|
||||
clone->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -71,9 +71,9 @@ int w_ParticleSystem_getTexture(lua_State *L)
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
|
||||
else
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
|
||||
@@ -596,7 +596,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
|
||||
{
|
||||
lua_rawgeti(L, 2, i);
|
||||
|
||||
Quad *q = luax_checktype<Quad>(L, -1, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad *q = luax_checktype<Quad>(L, -1, GRAPHICS_QUAD_ID);
|
||||
quads.push_back(q);
|
||||
|
||||
lua_pop(L, 1);
|
||||
@@ -606,7 +606,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
|
||||
{
|
||||
for (int i = 2; i <= lua_gettop(L); i++)
|
||||
{
|
||||
Quad *q = luax_checktype<Quad>(L, i, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad *q = luax_checktype<Quad>(L, i, GRAPHICS_QUAD_ID);
|
||||
quads.push_back(q);
|
||||
}
|
||||
}
|
||||
@@ -624,7 +624,7 @@ int w_ParticleSystem_getQuads(lua_State *L)
|
||||
|
||||
for (int i = 0; i < (int) quads.size(); i++)
|
||||
{
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quads[i]);
|
||||
luax_pushtype(L, GRAPHICS_QUAD_ID, quads[i]);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
|
||||
@@ -784,7 +784,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_particlesystem(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "ParticleSystem", functions);
|
||||
return luax_register_type(L, GRAPHICS_PARTICLE_SYSTEM_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace opengl
|
||||
|
||||
Shader *luax_checkshader(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Shader>(L, idx, "Shader", GRAPHICS_SHADER_T);
|
||||
return luax_checktype<Shader>(L, idx, GRAPHICS_SHADER_ID);
|
||||
}
|
||||
|
||||
int w_Shader_getWarnings(lua_State *L)
|
||||
@@ -308,7 +308,7 @@ int w_Shader_send(lua_State *L)
|
||||
// Texture (Image or Canvas).
|
||||
p = (Proxy *) lua_touserdata(L, 3);
|
||||
|
||||
if (p->flags[GRAPHICS_TEXTURE_ID])
|
||||
if (typeFlags[p->type][GRAPHICS_TEXT_ID])
|
||||
return w_Shader_sendTexture(L);
|
||||
|
||||
break;
|
||||
@@ -381,7 +381,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_shader(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Shader", functions);
|
||||
return luax_register_type(L, GRAPHICS_SHADER_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace opengl
|
||||
|
||||
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T);
|
||||
return luax_checktype<SpriteBatch>(L, idx, GRAPHICS_SPRITE_BATCH_ID);
|
||||
}
|
||||
|
||||
int w_SpriteBatch_add(lua_State *L)
|
||||
@@ -45,9 +45,9 @@ int w_SpriteBatch_add(lua_State *L)
|
||||
Quad *quad = nullptr;
|
||||
int startidx = 2;
|
||||
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_T))
|
||||
if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
|
||||
{
|
||||
quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
|
||||
quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
|
||||
startidx = 3;
|
||||
}
|
||||
else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
|
||||
@@ -83,9 +83,9 @@ int w_SpriteBatch_set(lua_State *L)
|
||||
Quad *quad = nullptr;
|
||||
int startidx = 3;
|
||||
|
||||
if (luax_istype(L, 3, GRAPHICS_QUAD_T))
|
||||
if (luax_istype(L, 3, GRAPHICS_QUAD_ID))
|
||||
{
|
||||
quad = luax_totype<Quad>(L, 3, "Quad", GRAPHICS_QUAD_T);
|
||||
quad = luax_totype<Quad>(L, 3, GRAPHICS_QUAD_ID);
|
||||
startidx = 4;
|
||||
}
|
||||
else if (lua_isnil(L, 3) && !lua_isnoneornil(L, 4))
|
||||
@@ -140,9 +140,9 @@ int w_SpriteBatch_getTexture(lua_State *L)
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
|
||||
else
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
|
||||
@@ -241,7 +241,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_spritebatch(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "SpriteBatch", functions);
|
||||
return luax_register_type(L, GRAPHICS_SPRITE_BATCH_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -33,9 +33,7 @@ namespace opengl
|
||||
|
||||
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx);
|
||||
int w_SpriteBatch_add(lua_State *L);
|
||||
int w_SpriteBatch_addg(lua_State *L);
|
||||
int w_SpriteBatch_set(lua_State *L);
|
||||
int w_SpriteBatch_setg(lua_State *L);
|
||||
int w_SpriteBatch_clear(lua_State *L);
|
||||
int w_SpriteBatch_flush(lua_State *L);
|
||||
int w_SpriteBatch_setTexture(lua_State *L);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace opengl
|
||||
|
||||
Text *luax_checktext(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Text>(L, idx, "Text", GRAPHICS_TEXT_T);
|
||||
return luax_checktype<Text>(L, idx, GRAPHICS_TEXT_ID);
|
||||
}
|
||||
|
||||
int w_Text_set(lua_State *L)
|
||||
@@ -139,7 +139,7 @@ int w_Text_getFont(lua_State *L)
|
||||
{
|
||||
Text *t = luax_checktext(L, 1);
|
||||
Font *f = t->getFont();
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
|
||||
luax_pushtype(L, GRAPHICS_FONT_ID, f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_text(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Text", functions);
|
||||
return luax_register_type(L, GRAPHICS_TEXT_ID, functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace graphics
|
||||
|
||||
Quad *luax_checkquad(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
|
||||
return luax_checktype<Quad>(L, idx, GRAPHICS_QUAD_ID);
|
||||
}
|
||||
|
||||
int w_Quad_setViewport(lua_State *L)
|
||||
@@ -73,7 +73,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_quad(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, "Quad", functions);
|
||||
return luax_register_type(L, GRAPHICS_QUAD_ID, functions);
|
||||
}
|
||||
|
||||
} // graphics
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace graphics
|
||||
|
||||
Texture *luax_checktexture(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Texture>(L, idx, "Texture", GRAPHICS_TEXTURE_T);
|
||||
return luax_checktype<Texture>(L, idx, GRAPHICS_TEXTURE_ID);
|
||||
}
|
||||
|
||||
int w_Texture_getWidth(lua_State *L)
|
||||
|
||||
Reference in New Issue
Block a user