mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Added many comments, and changed function names for wrapper functions.
This commit is contained in:
@@ -28,7 +28,7 @@ namespace opengl
|
||||
{
|
||||
static Graphics * instance = 0;
|
||||
|
||||
int _wrap_checkMode(lua_State * L)
|
||||
int w_checkMode(lua_State * L)
|
||||
{
|
||||
int w = luaL_checkint(L, 1);
|
||||
int h = luaL_checkint(L, 2);
|
||||
@@ -37,7 +37,7 @@ namespace opengl
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_setMode(lua_State * L)
|
||||
int w_setMode(lua_State * L)
|
||||
{
|
||||
int w = luaL_checkint(L, 1);
|
||||
int h = luaL_checkint(L, 2);
|
||||
@@ -48,66 +48,66 @@ namespace opengl
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_toggleFullscreen(lua_State * L)
|
||||
int w_toggleFullscreen(lua_State * L)
|
||||
{
|
||||
luax_pushboolean(L, instance->toggleFullscreen());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_reset(lua_State * L)
|
||||
int w_reset(lua_State * L)
|
||||
{
|
||||
instance->reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_clear(lua_State * L)
|
||||
int w_clear(lua_State * L)
|
||||
{
|
||||
instance->clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_present(lua_State * L)
|
||||
int w_present(lua_State * L)
|
||||
{
|
||||
instance->present();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_setCaption(lua_State * L)
|
||||
int w_setCaption(lua_State * L)
|
||||
{
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
instance->setCaption(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getCaption(lua_State * L)
|
||||
int w_getCaption(lua_State * L)
|
||||
{
|
||||
return instance->getCaption(L);
|
||||
}
|
||||
|
||||
int _wrap_getWidth(lua_State * L)
|
||||
int w_getWidth(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, instance->getWidth());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_getHeight(lua_State * L)
|
||||
int w_getHeight(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, instance->getHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_isCreated(lua_State * L)
|
||||
int w_isCreated(lua_State * L)
|
||||
{
|
||||
luax_pushboolean(L, instance->isCreated());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_getModes(lua_State * L)
|
||||
int w_getModes(lua_State * L)
|
||||
{
|
||||
return instance->getModes(L);
|
||||
}
|
||||
|
||||
int _wrap_setScissor(lua_State * L)
|
||||
int w_setScissor(lua_State * L)
|
||||
{
|
||||
if(lua_gettop(L) == 0)
|
||||
{
|
||||
@@ -124,22 +124,22 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getScissor(lua_State * L)
|
||||
int w_getScissor(lua_State * L)
|
||||
{
|
||||
return instance->getScissor(L);
|
||||
}
|
||||
|
||||
int _wrap_newImage(lua_State * L)
|
||||
int w_newImage(lua_State * L)
|
||||
{
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_strtofile(L, 1);
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// Convert to ImageData, if necessary.
|
||||
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
luax_convobj(L, 1, "image", "newImageData");
|
||||
|
||||
love::image::ImageData * data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", LOVE_IMAGE_IMAGE_DATA_BITS);
|
||||
love::image::ImageData * data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
|
||||
// Create the image.
|
||||
Image * image = instance->newImage(data);
|
||||
@@ -149,26 +149,26 @@ namespace opengl
|
||||
|
||||
|
||||
// Push the type.
|
||||
luax_newtype(L, "Image", LOVE_GRAPHICS_IMAGE_BITS, (void*)image);
|
||||
luax_newtype(L, "Image", GRAPHICS_IMAGE_T, (void*)image);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_newGlyph(lua_State * L)
|
||||
int w_newGlyph(lua_State * L)
|
||||
{
|
||||
love::font::GlyphData * data = luax_checktype<love::font::GlyphData>(L, 1, "GlyphData", LOVE_FONT_GLYPH_DATA_BITS);
|
||||
love::font::GlyphData * data = luax_checktype<love::font::GlyphData>(L, 1, "GlyphData", FONT_GLYPH_DATA_T);
|
||||
|
||||
// Create the image.
|
||||
Glyph * t = new Glyph(data);
|
||||
t->load();
|
||||
|
||||
// Push the type.
|
||||
luax_newtype(L, "Glyph", LOVE_GRAPHICS_GLYPH_BITS, (void*)t);
|
||||
luax_newtype(L, "Glyph", GRAPHICS_GLYPH_T, (void*)t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_newFrame(lua_State * L)
|
||||
int w_newFrame(lua_State * L)
|
||||
{
|
||||
int x = luaL_checkint(L, 1);
|
||||
int y = luaL_checkint(L, 2);
|
||||
@@ -182,28 +182,28 @@ namespace opengl
|
||||
if (frame == 0)
|
||||
return luaL_error(L, "Could not create frame.");
|
||||
|
||||
luax_newtype(L, "Frame", LOVE_GRAPHICS_FRAME_BITS, (void*)frame);
|
||||
luax_newtype(L, "Frame", GRAPHICS_FRAME_T, (void*)frame);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_newFont(lua_State * L)
|
||||
int w_newFont(lua_State * L)
|
||||
{
|
||||
|
||||
Data * d = 0;
|
||||
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_strtofile(L, 1);
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
{
|
||||
// Check the value.
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
d = file->read();
|
||||
}
|
||||
else if(luax_istype(L, 1, LOVE_DATA_BITS))
|
||||
else if(luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
d = luax_checktype<Data>(L, 1, "Data", LOVE_DATA_BITS);
|
||||
d = luax_checktype<Data>(L, 1, "Data", DATA_T);
|
||||
}
|
||||
|
||||
// Second optional parameter can be a number:
|
||||
@@ -214,23 +214,23 @@ namespace opengl
|
||||
if(font == 0)
|
||||
return luaL_error(L, "Could not load the font");
|
||||
|
||||
luax_newtype(L, "Font", LOVE_GRAPHICS_FONT_BITS, (void*)font);
|
||||
luax_newtype(L, "Font", GRAPHICS_FONT_T, (void*)font);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_newImageFont(lua_State * L)
|
||||
int w_newImageFont(lua_State * L)
|
||||
{
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_strtofile(L, 1);
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// Convert to Image, if necessary.
|
||||
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
luax_convobj(L, 1, "graphics", "newImage");
|
||||
|
||||
// Check the value.
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
|
||||
const char * glyphs = luaL_checkstring(L, 2);
|
||||
|
||||
@@ -239,22 +239,22 @@ namespace opengl
|
||||
if(font == 0)
|
||||
return luaL_error(L, "Could not load the font");
|
||||
|
||||
luax_newtype(L, "Font", LOVE_GRAPHICS_FONT_BITS, (void*)font);
|
||||
luax_newtype(L, "Font", GRAPHICS_FONT_T, (void*)font);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_newSpriteBatch(lua_State * L)
|
||||
int w_newSpriteBatch(lua_State * L)
|
||||
{
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
int size = luaL_optint(L, 2, 1000);
|
||||
int usage = luaL_optint(L, 3, SpriteBatch::USAGE_DYNAMIC);
|
||||
SpriteBatch * t = instance->newSpriteBatch(image, size, usage);
|
||||
luax_newtype(L, "SpriteBatch", LOVE_GRAPHICS_SPRITE_BATCH_BITS, (void*)t);
|
||||
luax_newtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, (void*)t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_setColor(lua_State * L)
|
||||
int w_setColor(lua_State * L)
|
||||
{
|
||||
Color c;
|
||||
c.r = (unsigned char)luaL_checkint(L, 1);
|
||||
@@ -265,7 +265,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getColor(lua_State * L)
|
||||
int w_getColor(lua_State * L)
|
||||
{
|
||||
Color c = instance->getColor();
|
||||
lua_pushinteger(L, c.r);
|
||||
@@ -275,7 +275,7 @@ namespace opengl
|
||||
return 4;
|
||||
}
|
||||
|
||||
int _wrap_setBackgroundColor(lua_State * L)
|
||||
int w_setBackgroundColor(lua_State * L)
|
||||
{
|
||||
Color c;
|
||||
c.r = (unsigned char)luaL_checkint(L, 1);
|
||||
@@ -286,7 +286,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getBackgroundColor(lua_State * L)
|
||||
int w_getBackgroundColor(lua_State * L)
|
||||
{
|
||||
Color c = instance->getBackgroundColor();
|
||||
lua_pushinteger(L, c.r);
|
||||
@@ -296,35 +296,35 @@ namespace opengl
|
||||
return 4;
|
||||
}
|
||||
|
||||
int _wrap_setFont(lua_State * L)
|
||||
int w_setFont(lua_State * L)
|
||||
{
|
||||
// The second parameter is an optional int.
|
||||
int size = luaL_optint(L, 2, 12);
|
||||
|
||||
// If the first parameter is a string, convert it to a file.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_strtofile(L, 1);
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// If the first parameter is a File, use another setFont function.
|
||||
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
{
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
instance->setFont(file->read(), size);
|
||||
return 0;
|
||||
}
|
||||
else if(luax_istype(L, 1, LOVE_DATA_BITS))
|
||||
else if(luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
Data * data = luax_checktype<Data>(L, 1, "Data", LOVE_DATA_BITS);
|
||||
Data * data = luax_checktype<Data>(L, 1, "Data", DATA_T);
|
||||
instance->setFont(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Font * font = luax_checktype<Font>(L, 1, "Font", LOVE_GRAPHICS_FONT_BITS);
|
||||
Font * font = luax_checktype<Font>(L, 1, "Font", GRAPHICS_FONT_T);
|
||||
instance->setFont(font);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getFont(lua_State * L)
|
||||
int w_getFont(lua_State * L)
|
||||
{
|
||||
Font * f = instance->getFont();
|
||||
|
||||
@@ -332,51 +332,51 @@ namespace opengl
|
||||
return 0;
|
||||
|
||||
f->retain();
|
||||
luax_newtype(L, "Font", LOVE_GRAPHICS_FONT_BITS, (void*)f);
|
||||
luax_newtype(L, "Font", GRAPHICS_FONT_T, (void*)f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_setBlendMode(lua_State * L)
|
||||
int w_setBlendMode(lua_State * L)
|
||||
{
|
||||
int mode = luaL_checkint(L, 1);
|
||||
instance->setBlendMode(mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_setColorMode(lua_State * L)
|
||||
int w_setColorMode(lua_State * L)
|
||||
{
|
||||
int mode = luaL_checkint(L, 1);
|
||||
instance->setColorMode(mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getBlendMode(lua_State * L)
|
||||
int w_getBlendMode(lua_State * L)
|
||||
{
|
||||
lua_pushinteger(L, instance->getBlendMode());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_getColorMode(lua_State * L)
|
||||
int w_getColorMode(lua_State * L)
|
||||
{
|
||||
lua_pushinteger(L, instance->getColorMode());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_setLineWidth(lua_State * L)
|
||||
int w_setLineWidth(lua_State * L)
|
||||
{
|
||||
float width = (float)luaL_checknumber(L, 1);
|
||||
instance->setLineWidth(width);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_setLineStyle(lua_State * L)
|
||||
int w_setLineStyle(lua_State * L)
|
||||
{
|
||||
int style = luaL_checkint(L, 1);
|
||||
instance->setLineStyle(style);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_setLine(lua_State * L)
|
||||
int w_setLine(lua_State * L)
|
||||
{
|
||||
float width = (float)luaL_checknumber(L, 1);
|
||||
int style = luaL_optint(L, 2, Graphics::LINE_SMOOTH);
|
||||
@@ -384,7 +384,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_setLineStipple(lua_State * L)
|
||||
int w_setLineStipple(lua_State * L)
|
||||
{
|
||||
if(lua_gettop(L) == 0)
|
||||
{
|
||||
@@ -398,38 +398,38 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getLineWidth(lua_State * L)
|
||||
int w_getLineWidth(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, instance->getLineWidth());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_getLineStyle(lua_State * L)
|
||||
int w_getLineStyle(lua_State * L)
|
||||
{
|
||||
lua_pushinteger(L, instance->getLineStyle());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_getLineStipple(lua_State * L)
|
||||
int w_getLineStipple(lua_State * L)
|
||||
{
|
||||
return instance->getLineStipple(L);
|
||||
}
|
||||
|
||||
int _wrap_setPointSize(lua_State * L)
|
||||
int w_setPointSize(lua_State * L)
|
||||
{
|
||||
float size = (float)luaL_checknumber(L, 1);
|
||||
instance->setPointSize(size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_setPointStyle(lua_State * L)
|
||||
int w_setPointStyle(lua_State * L)
|
||||
{
|
||||
int style = luaL_checkint(L, 1);
|
||||
instance->setPointStyle(style);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_setPoint(lua_State * L)
|
||||
int w_setPoint(lua_State * L)
|
||||
{
|
||||
float size = (float)luaL_checknumber(L, 1);
|
||||
int style = luaL_optint(L, 2, Graphics::POINT_SMOOTH);
|
||||
@@ -437,19 +437,19 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_getPointSize(lua_State * L)
|
||||
int w_getPointSize(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, instance->getPointSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_getPointStyle(lua_State * L)
|
||||
int w_getPointStyle(lua_State * L)
|
||||
{
|
||||
lua_pushinteger(L, instance->getPointStyle());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_getMaxPointSize(lua_State * L)
|
||||
int w_getMaxPointSize(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, instance->getMaxPointSize());
|
||||
return 1;
|
||||
@@ -466,9 +466,9 @@ namespace opengl
|
||||
* @param ox The offset along the x-axis.
|
||||
* @param oy The offset along the y-axis.
|
||||
**/
|
||||
int _wrap_draw(lua_State * L)
|
||||
int w_draw(lua_State * L)
|
||||
{
|
||||
Drawable * drawable = luax_checktype<Drawable>(L, 1, "Drawable", LOVE_GRAPHICS_DRAWABLE_BITS);
|
||||
Drawable * drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
|
||||
float x = (float)luaL_optnumber(L, 2, 0.0f);
|
||||
float y = (float)luaL_optnumber(L, 3, 0.0f);
|
||||
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
||||
@@ -495,9 +495,9 @@ namespace opengl
|
||||
* @param rw The width of the source rectangle.
|
||||
* @param rw The height of the source rectangle.
|
||||
**/
|
||||
int _wrap_draws(lua_State * L)
|
||||
int w_draws(lua_State * L)
|
||||
{
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
float x = (float)luaL_optnumber(L, 2, 0.0f);
|
||||
float y = (float)luaL_optnumber(L, 3, 0.0f);
|
||||
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
||||
@@ -526,9 +526,9 @@ namespace opengl
|
||||
* @param oy The offset along the y-axis.
|
||||
* @param f The Frame to dra.
|
||||
**/
|
||||
int _wrap_drawf(lua_State * L)
|
||||
int w_drawf(lua_State * L)
|
||||
{
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
float angle = (float)luaL_checknumber(L, 4);
|
||||
@@ -541,9 +541,9 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_drawTest(lua_State * L)
|
||||
int w_drawTest(lua_State * L)
|
||||
{
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
|
||||
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
float x = (float)luaL_optnumber(L, 2, 0.0f);
|
||||
float y = (float)luaL_optnumber(L, 3, 0.0f);
|
||||
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
||||
@@ -555,7 +555,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_print1(lua_State * L)
|
||||
int w_print1(lua_State * L)
|
||||
{
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
@@ -584,7 +584,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_printf1(lua_State * L)
|
||||
int w_printf1(lua_State * L)
|
||||
{
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
@@ -595,7 +595,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_point(lua_State * L)
|
||||
int w_point(lua_State * L)
|
||||
{
|
||||
float x = (float)luaL_checknumber(L, 1);
|
||||
float y = (float)luaL_checknumber(L, 2);
|
||||
@@ -603,7 +603,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_line(lua_State * L)
|
||||
int w_line(lua_State * L)
|
||||
{
|
||||
float x1 = (float)luaL_checknumber(L, 1);
|
||||
float y1 = (float)luaL_checknumber(L, 2);
|
||||
@@ -613,7 +613,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_triangle(lua_State * L)
|
||||
int w_triangle(lua_State * L)
|
||||
{
|
||||
int type = luaL_checkint(L, 1);
|
||||
float x1 = (float)luaL_checknumber(L, 2);
|
||||
@@ -626,7 +626,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_rectangle(lua_State * L)
|
||||
int w_rectangle(lua_State * L)
|
||||
{
|
||||
int type = luaL_checkint(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
@@ -637,7 +637,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_quad(lua_State * L)
|
||||
int w_quad(lua_State * L)
|
||||
{
|
||||
int type = luaL_checkint(L, 1);
|
||||
float x1 = (float)luaL_checknumber(L, 2);
|
||||
@@ -652,7 +652,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_circle(lua_State * L)
|
||||
int w_circle(lua_State * L)
|
||||
{
|
||||
int type = luaL_checkint(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
@@ -663,31 +663,31 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_polygon(lua_State * L)
|
||||
int w_polygon(lua_State * L)
|
||||
{
|
||||
return instance->polygon(L);
|
||||
}
|
||||
|
||||
int _wrap_push(lua_State * L)
|
||||
int w_push(lua_State * L)
|
||||
{
|
||||
instance->push();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_pop(lua_State * L)
|
||||
int w_pop(lua_State * L)
|
||||
{
|
||||
instance->pop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_rotate(lua_State * L)
|
||||
int w_rotate(lua_State * L)
|
||||
{
|
||||
float deg = (float)luaL_checknumber(L, 1);
|
||||
instance->rotate(deg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_scale(lua_State * L)
|
||||
int w_scale(lua_State * L)
|
||||
{
|
||||
float sx = (float)luaL_optnumber(L, 1, 1.0f);
|
||||
float sy = (float)luaL_optnumber(L, 2, sx);
|
||||
@@ -695,7 +695,7 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_translate(lua_State * L)
|
||||
int w_translate(lua_State * L)
|
||||
{
|
||||
float x = (float)luaL_checknumber(L, 1);
|
||||
float y = (float)luaL_checknumber(L, 2);
|
||||
@@ -703,152 +703,153 @@ namespace opengl
|
||||
return 0;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg wrap_Graphics_functions[] = {
|
||||
{ "checkMode", _wrap_checkMode },
|
||||
{ "setMode", _wrap_setMode },
|
||||
{ "toggleFullscreen", _wrap_toggleFullscreen },
|
||||
{ "reset", _wrap_reset },
|
||||
{ "clear", _wrap_clear },
|
||||
{ "present", _wrap_present },
|
||||
|
||||
{ "newImage", _wrap_newImage },
|
||||
{ "newGlyph", _wrap_newGlyph },
|
||||
{ "newFrame", _wrap_newFrame },
|
||||
{ "newFont", _wrap_newFont },
|
||||
{ "newImageFont", _wrap_newImageFont },
|
||||
{ "newSpriteBatch", _wrap_newSpriteBatch },
|
||||
|
||||
{ "setColor", _wrap_setColor },
|
||||
{ "getColor", _wrap_getColor },
|
||||
{ "setBackgroundColor", _wrap_setBackgroundColor },
|
||||
{ "getBackgroundColor", _wrap_getBackgroundColor },
|
||||
|
||||
{ "setFont", _wrap_setFont },
|
||||
{ "getFont", _wrap_getFont },
|
||||
|
||||
{ "setBlendMode", _wrap_setBlendMode },
|
||||
{ "setColorMode", _wrap_setColorMode },
|
||||
{ "getBlendMode", _wrap_getBlendMode },
|
||||
{ "getColorMode", _wrap_getColorMode },
|
||||
{ "setLineWidth", _wrap_setLineWidth },
|
||||
{ "setLineStyle", _wrap_setLineStyle },
|
||||
{ "setLine", _wrap_setLine },
|
||||
{ "setLineStipple", _wrap_setLineStipple },
|
||||
{ "getLineWidth", _wrap_getLineWidth },
|
||||
{ "getLineStyle", _wrap_getLineStyle },
|
||||
{ "getLineStipple", _wrap_getLineStipple },
|
||||
{ "setPointSize", _wrap_setPointSize },
|
||||
{ "setPointStyle", _wrap_setPointStyle },
|
||||
{ "setPoint", _wrap_setPoint },
|
||||
{ "getPointSize", _wrap_getPointSize },
|
||||
{ "getPointStyle", _wrap_getPointStyle },
|
||||
{ "getMaxPointSize", _wrap_getMaxPointSize },
|
||||
|
||||
{ "draw", _wrap_draw },
|
||||
{ "draws", _wrap_draws },
|
||||
{ "drawf", _wrap_drawf },
|
||||
{ "drawTest", _wrap_drawTest },
|
||||
|
||||
{ "print1", _wrap_print1 },
|
||||
{ "printf1", _wrap_printf1 },
|
||||
|
||||
{ "setCaption", _wrap_setCaption },
|
||||
{ "getCaption", _wrap_getCaption },
|
||||
|
||||
{ "getWidth", _wrap_getWidth },
|
||||
{ "getHeight", _wrap_getHeight },
|
||||
|
||||
{ "isCreated", _wrap_isCreated },
|
||||
|
||||
{ "getModes", _wrap_getModes },
|
||||
|
||||
{ "setScissor", _wrap_setScissor },
|
||||
{ "getScissor", _wrap_getScissor },
|
||||
|
||||
{ "point", _wrap_point },
|
||||
{ "line", _wrap_line },
|
||||
{ "triangle", _wrap_triangle },
|
||||
{ "rectangle", _wrap_rectangle },
|
||||
{ "quad", _wrap_quad },
|
||||
{ "circle", _wrap_circle },
|
||||
|
||||
{ "polygon", _wrap_polygon },
|
||||
|
||||
{ "push", _wrap_push },
|
||||
{ "pop", _wrap_pop },
|
||||
{ "rotate", _wrap_rotate },
|
||||
{ "scale", _wrap_scale },
|
||||
|
||||
{ "translate", _wrap_translate },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
// Types for this module.
|
||||
const lua_CFunction wrap_Graphics_types[] = {
|
||||
wrap_Font_open,
|
||||
wrap_Image_open,
|
||||
wrap_Glyph_open,
|
||||
wrap_Frame_open,
|
||||
wrap_SpriteBatch_open,
|
||||
0
|
||||
};
|
||||
|
||||
// List of constants.
|
||||
static const LuaConstant wrap_Graphics_constants[] = {
|
||||
|
||||
{ "align_left", Graphics::ALIGN_LEFT },
|
||||
{ "align_right", Graphics::ALIGN_RIGHT },
|
||||
{ "align_center", Graphics::ALIGN_CENTER },
|
||||
|
||||
{ "blend_alpha", Graphics::BLEND_ALPHA },
|
||||
{ "blend_additive", Graphics::BLEND_ADDITIVE },
|
||||
{ "color_replace", Graphics::COLOR_REPLACE },
|
||||
{ "color_modulate", Graphics::COLOR_MODULATE },
|
||||
|
||||
{ "draw_line", Graphics::DRAW_LINE },
|
||||
{ "draw_fill", Graphics::DRAW_FILL },
|
||||
|
||||
{ "line_smooth", Graphics::LINE_SMOOTH },
|
||||
{ "line_rough", Graphics::LINE_ROUGH },
|
||||
|
||||
{ "point_smooth", Graphics::POINT_SMOOTH },
|
||||
{ "point_rough", Graphics::POINT_ROUGH },
|
||||
|
||||
{ "filter_linear", Image::FILTER_LINEAR },
|
||||
{ "filter_nearest", Image::FILTER_NEAREST },
|
||||
|
||||
{ "wrap_clamp", Image::WRAP_CLAMP },
|
||||
{ "wrap_repeat", Image::WRAP_REPEAT },
|
||||
|
||||
/**
|
||||
|
||||
// Vertex buffer geometry types.
|
||||
|
||||
{ "type_points", TYPE_POINTS },
|
||||
{ "type_lines", TYPE_LINES },
|
||||
{ "type_line_strip", TYPE_LINE_STRIP },
|
||||
{ "type_triangles", TYPE_TRIANGLES },
|
||||
{ "type_triangle_strip", TYPE_TRIANGLE_STRIP },
|
||||
{ "type_triangle_fan", TYPE_TRIANGLE_FAN },
|
||||
{ "type_num", TYPE_NUM },
|
||||
|
||||
// Vertex buffer usage hints.
|
||||
|
||||
{ "usage_array", USAGE_ARRAY },
|
||||
{ "usage_dynamic", USAGE_DYNAMIC },
|
||||
{ "usage_static", USAGE_STATIC },
|
||||
{ "usage_stream", USAGE_STREAM },
|
||||
{ "usage_num", USAGE_NUM },
|
||||
**/
|
||||
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_Graphics_open(lua_State * L)
|
||||
int luaopen_love_graphics(lua_State * L)
|
||||
{
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "checkMode", w_checkMode },
|
||||
{ "setMode", w_setMode },
|
||||
{ "toggleFullscreen", w_toggleFullscreen },
|
||||
{ "reset", w_reset },
|
||||
{ "clear", w_clear },
|
||||
{ "present", w_present },
|
||||
|
||||
{ "newImage", w_newImage },
|
||||
{ "newGlyph", w_newGlyph },
|
||||
{ "newFrame", w_newFrame },
|
||||
{ "newFont", w_newFont },
|
||||
{ "newImageFont", w_newImageFont },
|
||||
{ "newSpriteBatch", w_newSpriteBatch },
|
||||
|
||||
{ "setColor", w_setColor },
|
||||
{ "getColor", w_getColor },
|
||||
{ "setBackgroundColor", w_setBackgroundColor },
|
||||
{ "getBackgroundColor", w_getBackgroundColor },
|
||||
|
||||
{ "setFont", w_setFont },
|
||||
{ "getFont", w_getFont },
|
||||
|
||||
{ "setBlendMode", w_setBlendMode },
|
||||
{ "setColorMode", w_setColorMode },
|
||||
{ "getBlendMode", w_getBlendMode },
|
||||
{ "getColorMode", w_getColorMode },
|
||||
{ "setLineWidth", w_setLineWidth },
|
||||
{ "setLineStyle", w_setLineStyle },
|
||||
{ "setLine", w_setLine },
|
||||
{ "setLineStipple", w_setLineStipple },
|
||||
{ "getLineWidth", w_getLineWidth },
|
||||
{ "getLineStyle", w_getLineStyle },
|
||||
{ "getLineStipple", w_getLineStipple },
|
||||
{ "setPointSize", w_setPointSize },
|
||||
{ "setPointStyle", w_setPointStyle },
|
||||
{ "setPoint", w_setPoint },
|
||||
{ "getPointSize", w_getPointSize },
|
||||
{ "getPointStyle", w_getPointStyle },
|
||||
{ "getMaxPointSize", w_getMaxPointSize },
|
||||
|
||||
{ "draw", w_draw },
|
||||
{ "draws", w_draws },
|
||||
{ "drawf", w_drawf },
|
||||
{ "drawTest", w_drawTest },
|
||||
|
||||
{ "print1", w_print1 },
|
||||
{ "printf1", w_printf1 },
|
||||
|
||||
{ "setCaption", w_setCaption },
|
||||
{ "getCaption", w_getCaption },
|
||||
|
||||
{ "getWidth", w_getWidth },
|
||||
{ "getHeight", w_getHeight },
|
||||
|
||||
{ "isCreated", w_isCreated },
|
||||
|
||||
{ "getModes", w_getModes },
|
||||
|
||||
{ "setScissor", w_setScissor },
|
||||
{ "getScissor", w_getScissor },
|
||||
|
||||
{ "point", w_point },
|
||||
{ "line", w_line },
|
||||
{ "triangle", w_triangle },
|
||||
{ "rectangle", w_rectangle },
|
||||
{ "quad", w_quad },
|
||||
{ "circle", w_circle },
|
||||
|
||||
{ "polygon", w_polygon },
|
||||
|
||||
{ "push", w_push },
|
||||
{ "pop", w_pop },
|
||||
{ "rotate", w_rotate },
|
||||
{ "scale", w_scale },
|
||||
|
||||
{ "translate", w_translate },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
// Types for this module.
|
||||
static const lua_CFunction types[] = {
|
||||
luaopen_font,
|
||||
luaopen_image,
|
||||
luaopen_glyph,
|
||||
luaopen_frame,
|
||||
luaopen_spritebatch,
|
||||
0
|
||||
};
|
||||
|
||||
// List of constants.
|
||||
static const LuaConstant constants[] = {
|
||||
|
||||
{ "align_left", Graphics::ALIGN_LEFT },
|
||||
{ "align_right", Graphics::ALIGN_RIGHT },
|
||||
{ "align_center", Graphics::ALIGN_CENTER },
|
||||
|
||||
{ "blend_alpha", Graphics::BLEND_ALPHA },
|
||||
{ "blend_additive", Graphics::BLEND_ADDITIVE },
|
||||
{ "color_replace", Graphics::COLOR_REPLACE },
|
||||
{ "color_modulate", Graphics::COLOR_MODULATE },
|
||||
|
||||
{ "draw_line", Graphics::DRAW_LINE },
|
||||
{ "draw_fill", Graphics::DRAW_FILL },
|
||||
|
||||
{ "line_smooth", Graphics::LINE_SMOOTH },
|
||||
{ "line_rough", Graphics::LINE_ROUGH },
|
||||
|
||||
{ "point_smooth", Graphics::POINT_SMOOTH },
|
||||
{ "point_rough", Graphics::POINT_ROUGH },
|
||||
|
||||
{ "filter_linear", Image::FILTER_LINEAR },
|
||||
{ "filter_nearest", Image::FILTER_NEAREST },
|
||||
|
||||
{ "wrap_clamp", Image::WRAP_CLAMP },
|
||||
{ "wrap_repeat", Image::WRAP_REPEAT },
|
||||
|
||||
/**
|
||||
|
||||
// Vertex buffer geometry types.
|
||||
|
||||
{ "type_points", TYPE_POINTS },
|
||||
{ "type_lines", TYPE_LINES },
|
||||
{ "type_line_strip", TYPE_LINE_STRIP },
|
||||
{ "type_triangles", TYPE_TRIANGLES },
|
||||
{ "type_triangle_strip", TYPE_TRIANGLE_STRIP },
|
||||
{ "type_triangle_fan", TYPE_TRIANGLE_FAN },
|
||||
{ "type_num", TYPE_NUM },
|
||||
|
||||
// Vertex buffer usage hints.
|
||||
|
||||
{ "usage_array", USAGE_ARRAY },
|
||||
{ "usage_dynamic", USAGE_DYNAMIC },
|
||||
{ "usage_static", USAGE_STATIC },
|
||||
{ "usage_stream", USAGE_STREAM },
|
||||
{ "usage_num", USAGE_NUM },
|
||||
**/
|
||||
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
if(instance == 0)
|
||||
{
|
||||
try
|
||||
@@ -861,11 +862,10 @@ namespace opengl
|
||||
}
|
||||
}
|
||||
|
||||
luax_register_gc(L, "love.graphics", instance);
|
||||
luax_register_module(L, wrap_Graphics_functions, wrap_Graphics_types, wrap_Graphics_constants, "graphics");
|
||||
luax_register_gc(L, instance);
|
||||
luax_register_module(L, functions, types, constants, "graphics");
|
||||
|
||||
# include <scripts/graphics.lua.h>
|
||||
//luaL_dofile(L, "../../src/scripts/graphics.lua");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -873,8 +873,3 @@ namespace opengl
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
int luaopen_love_graphics(lua_State * L)
|
||||
{
|
||||
return love::graphics::opengl::wrap_Graphics_open(L);
|
||||
}
|
||||
Reference in New Issue
Block a user