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
+21
View File
@@ -63,6 +63,27 @@ namespace love
struct vertex
{
vertex()
: r(255), g(255), b(255), a(255)
, x(0), y(0)
, s(0), t(0)
{}
vertex(float x, float y,
float s, float t)
: r(255), g(255), b(255), a(255)
, x(x), y(y)
, s(s), t(t)
{}
vertex(float x, float y,
float s, float t,
unsigned char r, unsigned char g, unsigned char b, unsigned char a)
: r(r), g(g), b(b), a(a)
, x(x), y(y)
, s(s), t(t)
{}
unsigned char r, g, b, a;
float x, y;
float s, t;
+1 -1
View File
@@ -461,7 +461,7 @@ StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
// Graphics
{"Drawable", GRAPHICS_DRAWABLE_ID},
{"Image", GRAPHICS_IMAGE_ID},
{"Quad", GRAPHICS_QUAD_ID},
{"Geometry", GRAPHICS_GEOMETRY_ID},
{"Font", GRAPHICS_FONT_ID},
{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
+1 -1
View File
@@ -49,7 +49,7 @@ extern unsigned int _gcthread;
enum Registry
{
REGISTRY_GC = 1,
REGISTRY_MODULES,
REGISTRY_MODULES
};
/**
+6 -6
View File
@@ -45,9 +45,9 @@ enum Type
// Graphics
GRAPHICS_DRAWABLE_ID,
GRAPHICS_DRAWQABLE_ID,
GRAPHICS_DRAWGABLE_ID,
GRAPHICS_IMAGE_ID,
GRAPHICS_QUAD_ID,
GRAPHICS_GEOMETRY_ID,
GRAPHICS_FONT_ID,
GRAPHICS_PARTICLE_SYSTEM_ID,
GRAPHICS_SPRITE_BATCH_ID,
@@ -120,13 +120,13 @@ const bits FONT_RASTERIZER_T = (bits(1) << FONT_RASTERIZER_ID) | OBJECT_T;
// Graphics.
const bits GRAPHICS_DRAWABLE_T = (bits(1) << GRAPHICS_DRAWABLE_ID) | OBJECT_T;
const bits GRAPHICS_DRAWQABLE_T = (bits(1) << GRAPHICS_DRAWQABLE_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_DRAWQABLE_T;
const bits GRAPHICS_QUAD_T = (bits(1) << GRAPHICS_QUAD_ID) | OBJECT_T;
const bits GRAPHICS_DRAWGABLE_T = (bits(1) << GRAPHICS_DRAWGABLE_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_DRAWGABLE_T;
const bits GRAPHICS_GEOMETRY_T = (bits(1) << GRAPHICS_GEOMETRY_ID) | OBJECT_T;
const bits GRAPHICS_FONT_T = (bits(1) << GRAPHICS_FONT_ID) | OBJECT_T;
const bits GRAPHICS_PARTICLE_SYSTEM_T = (bits(1) << GRAPHICS_PARTICLE_SYSTEM_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_SPRITE_BATCH_T = (bits(1) << GRAPHICS_SPRITE_BATCH_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_CANVAS_T = (bits(1) << GRAPHICS_CANVAS_ID) | GRAPHICS_DRAWQABLE_T;
const bits GRAPHICS_CANVAS_T = (bits(1) << GRAPHICS_CANVAS_ID) | GRAPHICS_DRAWGABLE_T;
const bits GRAPHICS_SHADER_T = (bits(1) << GRAPHICS_SHADER_ID) | OBJECT_T;
// Image.