mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Merged default into minor
--HG-- branch : minor
This commit is contained in:
@@ -167,7 +167,7 @@ void Graphics::setViewportSize(int width, int height)
|
||||
|
||||
// We want to affect the main screen, not any Canvas that's currently active
|
||||
// (not that any *should* be active when this is called.)
|
||||
std::vector<Canvas *> canvases = getCanvas();
|
||||
std::vector<Object::StrongRef<Canvas>> canvases = states.back().canvases;
|
||||
setCanvas();
|
||||
|
||||
// Set the viewport to top-left corner.
|
||||
@@ -1061,7 +1061,7 @@ love::image::ImageData *Graphics::newScreenshot(love::image::Image *image, bool
|
||||
{
|
||||
// Temporarily unbind the currently active canvas (glReadPixels reads the
|
||||
// active framebuffer, not the main one.)
|
||||
std::vector<Canvas *> canvases = getCanvas();
|
||||
std::vector<Object::StrongRef<Canvas>> canvases = states.back().canvases;
|
||||
setCanvas();
|
||||
|
||||
int w = getWidth();
|
||||
|
||||
@@ -68,6 +68,7 @@ int w_Canvas_getImageData(lua_State *L)
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
||||
love::image::ImageData *img = canvas->getImageData(image);
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
|
||||
img->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ int w_newImage(lua_State *L)
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, image);
|
||||
image->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -241,6 +242,7 @@ int w_newQuad(lua_State *L)
|
||||
|
||||
Quad *quad = instance()->newQuad(v, sw, sh);
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quad);
|
||||
quad->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -265,6 +267,7 @@ int w_newFont(lua_State *L)
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
font->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -282,8 +285,8 @@ int w_newImageFont(lua_State *L)
|
||||
filter = i->getFilter();
|
||||
love::image::ImageData *id = i->getImageData();
|
||||
if (!id)
|
||||
return luaL_argerror(L, 1, "Image cannot be compressed.");
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id, false);
|
||||
return luaL_argerror(L, 1, "Image must not be compressed.");
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id);
|
||||
lua_replace(L, 1);
|
||||
}
|
||||
|
||||
@@ -305,6 +308,7 @@ int w_newImageFont(lua_State *L)
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
font->release();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -327,6 +331,7 @@ int w_newSpriteBatch(lua_State *L)
|
||||
);
|
||||
|
||||
luax_pushtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -343,6 +348,7 @@ int w_newParticleSystem(lua_State *L)
|
||||
);
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -367,6 +373,7 @@ int w_newCanvas(lua_State *L)
|
||||
return luaL_error(L, "Canvas not created, but no error thrown. I don't even...");
|
||||
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, canvas);
|
||||
canvas->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -450,6 +457,7 @@ int w_newShader(lua_State *L)
|
||||
{
|
||||
Shader *shader = instance()->newShader(sources);
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
shader->release();
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
@@ -542,6 +550,7 @@ int w_newMesh(lua_State *L)
|
||||
t->setTexture(tex);
|
||||
|
||||
luax_pushtype(L, "Mesh", GRAPHICS_MESH_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -631,7 +640,6 @@ int w_getFont(lua_State *L)
|
||||
if (f == 0)
|
||||
return 0;
|
||||
|
||||
f->retain();
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
|
||||
return 1;
|
||||
}
|
||||
@@ -855,6 +863,7 @@ int w_newScreenshot(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
|
||||
i->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -903,16 +912,13 @@ int w_getCanvas(lua_State *L)
|
||||
const std::vector<Canvas *> canvases = instance()->getCanvas();
|
||||
int n = 0;
|
||||
|
||||
if (!canvases.empty())
|
||||
for (Canvas *c : canvases)
|
||||
{
|
||||
for (Canvas *c : canvases)
|
||||
{
|
||||
c->retain();
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
|
||||
n++;
|
||||
}
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
|
||||
n++;
|
||||
}
|
||||
else
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
n = 1;
|
||||
@@ -938,10 +944,7 @@ int w_getShader(lua_State *L)
|
||||
{
|
||||
Shader *shader = instance()->getShader();
|
||||
if (shader)
|
||||
{
|
||||
shader->retain();
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
|
||||
@@ -91,10 +91,7 @@ int w_Image_getData(lua_State *L)
|
||||
{
|
||||
love::image::CompressedData *t = i->getCompressedData();
|
||||
if (t)
|
||||
{
|
||||
t->retain();
|
||||
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
}
|
||||
@@ -102,10 +99,7 @@ int w_Image_getData(lua_State *L)
|
||||
{
|
||||
love::image::ImageData *t = i->getImageData();
|
||||
if (t)
|
||||
{
|
||||
t->retain();
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
||||
@@ -263,18 +263,13 @@ int w_Mesh_getTexture(lua_State *L)
|
||||
if (tex == nullptr)
|
||||
return 0;
|
||||
|
||||
tex->retain();
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
else
|
||||
{
|
||||
tex->release();
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ int w_ParticleSystem_clone(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ clone = t->clone(); });
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, clone);
|
||||
clone->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -67,7 +68,6 @@ int w_ParticleSystem_getTexture(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
Texture *tex = t->getTexture();
|
||||
tex->retain();
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
@@ -75,10 +75,7 @@ int w_ParticleSystem_getTexture(lua_State *L)
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
else
|
||||
{
|
||||
tex->release();
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -608,7 +605,6 @@ int w_ParticleSystem_getQuads(lua_State *L)
|
||||
|
||||
for (size_t i = 0; i < quads.size(); i++)
|
||||
{
|
||||
quads[i]->retain();
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quads[i]);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,6 @@ int w_SpriteBatch_getTexture(lua_State *L)
|
||||
{
|
||||
SpriteBatch *t = luax_checkspritebatch(L, 1);
|
||||
Texture *tex = t->getTexture();
|
||||
tex->retain();
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
@@ -145,10 +144,7 @@ int w_SpriteBatch_getTexture(lua_State *L)
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
else
|
||||
{
|
||||
tex->release();
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user