Add Geometries (replaces Quads).

A Geometry is a collection of vertices describing a non self-intersecting
(simple) polygon. In addition to screen coordinates, the vertices have
attributes for texture coordinates (s,t) and color (r,g,b,a).

It can be used as a quad, to display distorted images, or anything in between.

Added:
^^^^^^

-- geometry from table, where table has the format:
-- info = {
-- {x,y, s,t, [r = 255, g = 255, b = 255, a = 255]}
-- {x,y, s,t, [r = 255, g = 255, b = 255, a = 255]}
-- ...
-- }
geom = love.graphics.newGeometry(info)

-- convenience wrapper for quads (same as before)
geom = love.graphics.newQuad(x,y, w,h, sw,sh)

-- retrieve vertex i (1-indexed)
x,y,s,t,r,g,b,a = geom:getVertex(i)

-- set vertex i (1-indexed)
geom:setVertex(i, x,y, s,t, [r,g,b,a])

-- flip geometry
geom:flip(x, y)


Renamed:
^^^^^^^^

love.graphics.drawq() -> love.graphics.drawg()


Removed:
^^^^^^^^

quad:setViewport()
quad:getViewport()
This commit is contained in:
vrld
2013-04-21 18:53:13 +02:00
parent 9d62d0044c
commit 71317c4359
28 changed files with 750 additions and 229 deletions
@@ -19,7 +19,6 @@
**/
#include "wrap_ParticleSystem.h"
#include "wrap_Quad.h"
#include "common/Vector.h"
@@ -530,58 +529,6 @@ int w_ParticleSystem_getColors(lua_State *L)
return colors.size();
}
int w_ParticleSystem_setQuads(lua_State *L)
{
ParticleSystem *t = luax_checkparticlesystem(L, 1);
int nQuads = lua_gettop(L) - 1;
if (lua_istable(L, 2))
nQuads = lua_objlen(L, 2);
// Remove all quads if no argument is given.
if (nQuads == 0)
{
t->setQuads();
return 0;
}
std::vector<Quad *> quads(nQuads);
if (lua_istable(L, 2))
{
for (int i = 0; i < nQuads; i++)
{
lua_rawgeti(L, 2, i + 1); // array index
quads[i] = luax_checkquad(L, -1);
lua_pop(L, 1);
}
}
else
{
for (int i = 0; i < nQuads; i++)
quads[i] = luax_checkquad(L, i + 2);
}
t->setQuads(quads);
return 0;
}
int w_ParticleSystem_getQuads(lua_State *L)
{
ParticleSystem *t = luax_checkparticlesystem(L, 1);
const std::vector<Quad *> &quads = t->getQuads();
for (size_t i = 0; i < quads.size(); i++)
{
quads[i]->retain();
luax_newtype(L, "Quad", GRAPHICS_QUAD_T, (void *) quads[i]);
}
return quads.size();
}
int w_ParticleSystem_count(lua_State *L)
{
ParticleSystem *t = luax_checkparticlesystem(L, 1);
@@ -698,8 +645,6 @@ static const luaL_Reg functions[] =
{ "getSpinVariation", w_ParticleSystem_getSpinVariation },
{ "setColors", w_ParticleSystem_setColors },
{ "getColors", w_ParticleSystem_getColors },
{ "setQuads", w_ParticleSystem_setQuads },
{ "getQuads", w_ParticleSystem_getQuads },
{ "setOffset", w_ParticleSystem_setOffset },
{ "getOffset", w_ParticleSystem_getOffset },
{ "count", w_ParticleSystem_count },