vrld avatar vrld committed 29275e6

Generalize Quad into Geometry.

A Geometry is a (convex) shape with associated texture coordinates. It can be used as a quad, as non-rectangular image display or anything in between.

Added:
------

-- new empty geometry object with count vertices
geom = love.graphics.newGeometry(count)

-- 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]}
-- {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:get(i)

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

Renamed:
--------

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

Removed:
--------

quad:setViewport()
quad:getViewport()

Comments (0)

Files changed (29)

src/common/math.h

 	unsigned char r, g, b, a;
 	float x, y;
 	float s, t;
+
+	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, unsigned char _r = 255, unsigned char _g = 255, unsigned char _b = 255, unsigned char _a = 255)
+		: r(_r) , g(_g) , b(_b) , a(_a)
+		, x(_x) , y(_y)
+		, s(_s) , t(_t)
+	{}
 };
 
 inline int next_p2(int x)

src/common/runtime.cpp

 
 	// Graphics
 	{"Drawable", GRAPHICS_DRAWABLE_ID},
+	{"DrawGable", GRAPHICS_DRAWGABLE_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},

src/common/types.h

 
 	// 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,
 
 // 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_PIXELEFFECT_T = (bits(1) << GRAPHICS_PIXELEFFECT_ID) | OBJECT_T;
 
 // Image.

src/modules/graphics/DrawGable.h

+/**
+ * Copyright (c) 2006-2012 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_GRAPHICS_DRAWGABLE_H
+#define LOVE_GRAPHICS_DRAWGABLE_H
+
+// LOVE
+#include "Drawable.h"
+#include "Geometry.h"
+
+namespace love
+{
+namespace graphics
+{
+
+/**
+ * A DrawGable is anything that be drawn in part with a Geometry.
+ **/
+class DrawGable : public Drawable
+{
+public:
+
+	/**
+	 * Destructor.
+	 **/
+	virtual ~DrawGable() {}
+
+	/**
+	 * Draws the object with the specified transformation.
+	 *
+	 * @param geom The geometry to use to draw the object.
+	 * @param x The position of the object along the x-axis.
+	 * @param y The position of the object along the y-axis.
+	 * @param angle The angle of the object (in radians).
+	 * @param sx The scale factor along the x-axis.
+	 * @param sy The scale factor along the y-axis.
+	 * @param ox The origin offset along the x-axis.
+	 * @param oy The origin offset along the y-axis.
+	 * @param kx Shear along the x-axis.
+	 * @param ky Shear along the y-axis.
+	 **/
+	virtual void drawg(Geometry *geom, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const = 0;
+};
+
+} // graphics
+} // love
+
+#endif // LOVE_GRAPHICS_DRAWGABLE_H

src/modules/graphics/DrawQable.cpp

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#include "DrawQable.h"
-
-namespace love
-{
-namespace graphics
-{
-
-DrawQable::~DrawQable()
-{
-}
-
-} // graphics
-} // love

src/modules/graphics/DrawQable.h

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#ifndef LOVE_GRAPHICS_DRAWQABLE_H
-#define LOVE_GRAPHICS_DRAWQABLE_H
-
-// LOVE
-#include "Drawable.h"
-#include "Quad.h"
-
-namespace love
-{
-namespace graphics
-{
-
-/**
- * A DrawQable is anything that be drawn in part with a Quad.
- **/
-class DrawQable : public Drawable
-{
-public:
-
-	/**
-	 * Destructor.
-	 **/
-	virtual ~DrawQable();
-
-	/**
-	 * Draws the object with the specified transformation.
-	 *
-	 * @param quad The Quad to use to draw the object.
-	 * @param x The position of the object along the x-axis.
-	 * @param y The position of the object along the y-axis.
-	 * @param angle The angle of the object (in radians).
-	 * @param sx The scale factor along the x-axis.
-	 * @param sy The scale factor along the y-axis.
-	 * @param ox The origin offset along the x-axis.
-	 * @param oy The origin offset along the y-axis.
-	 * @param kx Shear along the x-axis.
-	 * @param ky Shear along the y-axis.
-	 **/
-	virtual void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const = 0;
-};
-
-} // graphics
-} // love
-
-#endif // LOVE_GRAPHICS_DRAWQABLE_H

src/modules/graphics/Geometry.cpp

+/**
+ * Copyright (c) 2006-2012 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#include "Geometry.h"
+#include "common/Exception.h"
+
+// STD
+#include <limits>
+#include <algorithm> // for std::swap()
+#include <cstring> // For memcpy
+
+namespace love
+{
+namespace graphics
+{
+
+Geometry::Geometry(size_t count)
+	: vertices(NULL)
+	, vertexCount(count)
+	, x_min(0)
+	, x_max(0)
+	, y_min(0)
+	, y_max(0)
+{
+	vertices = new vertex[vertexCount];
+
+	for (size_t i = 0; i < vertexCount; ++i)
+	{
+		vertex v;
+		v.x = v.y = v.s = v.t = 0;
+		v.y = v.g = v.b = v.a = 1;
+		vertices[i] = v;
+	}
+}
+
+Geometry::Geometry(const std::vector<vertex> &vert)
+	: vertices(NULL)
+	, vertexCount(vert.size())
+	, x_min(std::numeric_limits<float>::max())
+	, x_max(std::numeric_limits<float>::min())
+	, y_min(std::numeric_limits<float>::max())
+	, y_max(std::numeric_limits<float>::min())
+{
+	vertices = new vertex[vertexCount];
+
+	for (size_t i = 0; i < vertexCount; ++i)
+	{
+		const vertex &v = vert[i];
+		vertices[i] = v;
+
+		x_min = v.x < x_min ? v.x : x_min;
+		x_max = v.x > x_max ? v.x : x_max;
+		y_min = v.y < y_min ? v.y : y_min;
+		y_max = v.y > y_max ? v.y : y_max;
+	}
+}
+
+Geometry::Geometry(float x, float y, float w, float h, float sw, float sh)
+	: vertexCount(4)
+	, x_min(x)
+	, x_max(x+w)
+	, y_min(y)
+	, y_max(y+h)
+{
+	vertices = new vertex[4];
+
+	vertices[0] = vertex(0, 0,     x/sw,     y/sh);
+	vertices[1] = vertex(w, 0, (x+w)/sw,     y/sh);
+	vertices[2] = vertex(w, h, (x+w)/sw, (y+h)/sh);
+	vertices[3] = vertex(0, h,     x/sw, (y+h)/sh);
+}
+
+Geometry::Geometry(const Geometry &other)
+	: vertexCount(other.vertexCount)
+	, x_min(other.x_min)
+	, x_max(other.x_max)
+	, y_min(other.y_min)
+	, y_max(other.y_max)
+{
+	vertices = new vertex[vertexCount];
+	memcpy(vertices, other.vertices, vertexCount * sizeof(vertex));
+}
+
+Geometry &Geometry::operator=(const Geometry &other)
+{
+	if (this != &other)
+	{
+		Geometry temp(other);
+		std::swap(vertices, temp.vertices);
+
+		vertexCount = temp.vertexCount;
+		x_min       = temp.x_min;
+		x_max       = temp.x_max;
+		y_min       = temp.y_min;
+		y_max       = temp.y_max;
+	}
+	return *this;
+}
+
+Geometry::~Geometry()
+{
+	if (vertices)
+	{
+		delete[] vertices;
+		vertices = NULL;
+	}
+}
+
+const vertex &Geometry::get(size_t i) const
+{
+	if (i >= vertexCount)
+		throw Exception("Invalid index");
+	return vertices[i];
+}
+
+void Geometry::set(size_t i, const vertex &v)
+{
+	if (i >= vertexCount)
+		throw Exception("Invalid index");
+
+	vertices[i] = v;
+	x_min = v.x < x_min ? v.x : x_min;
+	x_max = v.x > x_max ? v.x : x_max;
+	y_min = v.y < y_min ? v.y : y_min;
+	y_max = v.y > y_max ? v.y : y_max;
+}
+
+void Geometry::flip(bool x, bool y)
+{
+	for (size_t i = 0; i < vertexCount; ++i)
+	{
+		vertex &v = vertices[i];
+		if (x) v.x = x_max + x_min - v.x;
+		if (y) v.y = y_max + y_min - v.y;
+	}
+}
+
+} // graphics
+} // love

src/modules/graphics/Geometry.h

+/**
+ * Copyright (c) 2006-2012 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_GRAPHICS_GEOMETRY_H
+#define LOVE_GRAPHICS_GEOMETRY_H
+
+// LOVE
+#include "common/Object.h"
+#include "common/math.h"
+
+// std
+#include <vector>
+
+namespace love
+{
+namespace graphics
+{
+
+class Geometry : public Object
+{
+public:
+	/**
+	 * Creates a new, empty geometry object.
+	 * @param count Number of vertices in this geometry.
+	 **/
+	explicit Geometry(size_t count);
+
+	/**
+	 * Creates a new geometry object from a std::vector<vertex>.
+	 * @param v
+	 **/
+	explicit Geometry(const std::vector<vertex> &v);
+
+	/**
+	 * Creates a new geometry from (texture) quad information.
+	 * @param x Top left position in the image.
+	 * @param y Top left position in the image.
+	 * @param w Width of the quad.
+	 * @param h Height of the quad.
+	 * @param sw The reference width, the width of the Image.
+	 * @param sh The reference height, the height of the Image.
+	 */
+	Geometry(float x, float y, float w, float h, float sw, float sh);
+
+	Geometry(const Geometry &other);
+	Geometry &operator=(const Geometry &other);
+	virtual ~Geometry();
+
+	const vertex &get(size_t i) const;
+	void set(size_t i, const vertex &v);
+
+	void flip(bool x, bool y);
+
+	/**
+	 * Gets a pointer to the vertices.
+	 **/
+	const vertex *getVertices() const
+	{
+		return vertices;
+	}
+
+	size_t getVertexCount() const
+	{
+		return vertexCount;
+	}
+
+protected:
+	vertex *vertices;
+	size_t vertexCount;
+
+	float x_min;
+	float x_max;
+
+	float y_min;
+	float y_max;
+};
+
+} // graphics
+} // love
+
+#endif // LOVE_GRAPHICS_GEOMETRY_H

src/modules/graphics/Image.h

 
 // LOVE
 #include "graphics/Volatile.h"
-#include "graphics/DrawQable.h"
+#include "graphics/DrawGable.h"
 #include "common/StringMap.h"
 
 namespace love
 namespace graphics
 {
 
-class Image : public DrawQable, public Volatile
+class Image : public DrawGable, public Volatile
 {
 public:
 

src/modules/graphics/Quad.cpp

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#include "Quad.h"
-
-namespace love
-{
-namespace graphics
-{
-
-Quad::Quad()
-{
-}
-
-Quad::~Quad()
-{
-}
-
-} // graphics
-} // love

src/modules/graphics/Quad.h

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#ifndef LOVE_GRAPHICS_QUAD_H
-#define LOVE_GRAPHICS_QUAD_H
-
-// LOVE
-#include "common/Object.h"
-#include "common/math.h"
-
-namespace love
-{
-namespace graphics
-{
-
-class Quad : public Object
-{
-public:
-
-	struct Viewport
-	{
-		float x, y, w, h;
-	};
-
-	Quad();
-
-	virtual ~Quad();
-
-	virtual void refresh(const Viewport &v, float sw, float sh) = 0;
-
-	virtual void setViewport(const Viewport &v) = 0;
-	virtual Viewport getViewport() const = 0;
-
-	virtual void flip(bool x, bool y) = 0;
-
-	/**
-	 * Gets a pointer to the vertices.
-	 **/
-	virtual const vertex *getVertices() const = 0;
-};
-} // graphics
-} // love
-
-#endif // LOVE_GRAPHICS_QUAD_H

src/modules/graphics/opengl/Canvas.cpp

 	// world coordinates
 	vertices[0].x = 0;
 	vertices[0].y = h;
-	vertices[1].x = 0;
-	vertices[1].y = 0;
+	vertices[1].x = w;
+	vertices[1].y = h;
 	vertices[2].x = w;
 	vertices[2].y = 0;
-	vertices[3].x = w;
-	vertices[3].y = h;
+	vertices[3].x = 0;
+	vertices[3].y = 0;
 
 	// texture coordinates
 	vertices[0].s = 0;
 	vertices[0].t = 0;
-	vertices[1].s = 0;
-	vertices[1].t = 1;
+	vertices[1].s = 1;
+	vertices[1].t = 0;
 	vertices[2].s = 1;
 	vertices[2].t = 1;
-	vertices[3].s = 1;
-	vertices[3].t = 0;
+	vertices[3].s = 0;
+	vertices[3].t = 1;
 
 	getStrategy();
+	settings.wrap.s = settings.wrap.t = Image::WRAP_REPEAT;
 
 	loadVolatile();
 }
 	drawv(t, vertices);
 }
 
-void Canvas::drawq(love::graphics::Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
+void Canvas::drawg(Geometry *geom, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 {
-	const vertex *v = quad->getVertices();
+	size_t count = geom->getVertexCount();
+	if (count == 0)
+		return;
 
-	// mirror quad on x axis
-	vertex w[4];
-	memcpy(w, v, sizeof(vertex)*4);
-	for (size_t i = 0; i < 4; ++i)
-		w[i].t = 1. - w[i].t;
+	// mirror geometry around x axis
+	// XXX: only works wrap mode repeat!
+	Geometry temp(*geom);
+	vertex *v = const_cast<vertex *>(temp.getVertices());
+	for (size_t i = 0; i < count; ++i)
+		v[i].t = -v[i].t;
 
 	static Matrix t;
 	t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
 
-	drawv(t, w);
+	drawv(t, v, count);
 }
 
 love::image::ImageData *Canvas::getImageData(love::image::Image *image)
 	return height;
 }
 
-void Canvas::drawv(const Matrix &t, const vertex *v) const
+void Canvas::drawv(const Matrix &t, const vertex *v, size_t count) const
 {
 	glPushMatrix();
 
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].x);
 	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].s);
-	glDrawArrays(GL_QUADS, 0, 4);
+	glDrawArrays(GL_TRIANGLE_FAN, 0, count);
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 	glDisableClientState(GL_VERTEX_ARRAY);
 

src/modules/graphics/opengl/Canvas.h

 #ifndef LOVE_GRAPHICS_OPENGL_CANVAS_H
 #define LOVE_GRAPHICS_OPENGL_CANVAS_H
 
-#include "graphics/DrawQable.h"
+#include "graphics/DrawGable.h"
 #include "graphics/Volatile.h"
 #include "graphics/Image.h"
 #include "graphics/Color.h"
 namespace opengl
 {
 
-class Canvas : public DrawQable, public Volatile
+class Canvas : public DrawGable, public Volatile
 {
 public:
 	enum TextureType {
 	virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
 
 	/**
-	 * @copydoc DrawQable::drawq()
+	 * @copydoc DrawGable::drawg()
 	 **/
-	void drawq(love::graphics::Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
+	void drawg(Geometry *geom, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
 
 	love::image::ImageData *getImageData(love::image::Image *image);
 
 		Image::Wrap   wrap;
 	} settings;
 
-	void drawv(const Matrix &t, const vertex *v) const;
+	void drawv(const Matrix &t, const vertex *v, size_t count = 4) const;
 
 	static StringMap<TextureType, TYPE_MAX_ENUM>::Entry textureTypeEntries[];
 	static StringMap<TextureType, TYPE_MAX_ENUM> textureTypes;

src/modules/graphics/opengl/Font.cpp

 #include "common/config.h"
 #include "Font.h"
 #include "font/GlyphData.h"
-#include "Quad.h"
+#include "graphics/Geometry.h"
 
 #include "libraries/utf8/utf8.h"
 
 #include <sstream>
 
 #include <algorithm> // for max
+#include <vector>
 
 namespace love
 {
 
 		g->texture = t;
 
-		Quad::Viewport v;
-		v.x = (float) texture_x;
-		v.y = (float) texture_y;
-		v.w = (float) w;
-		v.h = (float) h;
-		
-		Quad q = Quad(v, (const float) texture_width, (const float) texture_height);
-		const vertex *verts = q.getVertices();
+		Geometry geom(texture_x, texture_y, w, h, float(texture_width), float(texture_height));
+		const vertex *verts = geom.getVertices();
 		
 		// copy vertex data to the glyph and set proper bearing
 		for (int i = 0; i < 4; i++)

src/modules/graphics/opengl/Graphics.cpp

 	return image;
 }
 
-Quad *Graphics::newQuad(float x, float y, float w, float h, float sw, float sh)
+Geometry *Graphics::newGeometry(const std::vector<vertex> &vertices)
 {
-	Quad::Viewport v;
-	v.x = x;
-	v.y = y;
-	v.w = w;
-	v.h = h;
-	return new Quad(v, sw, sh);
+	return new Geometry(vertices);
+}
+
+Geometry *Graphics::newQuad(float x, float y, float w, float h, float sw, float sh)
+{
+	return new Geometry(x, y, w, h, sw, sh);
 }
 
 Font *Graphics::newFont(love::font::Rasterizer *r, const Image::Filter &filter)

src/modules/graphics/opengl/Graphics.h

 #include "GLee.h"
 
 // LOVE
+#include "common/math.h"
+
 #include "graphics/Graphics.h"
 #include "graphics/Color.h"
+#include "graphics/Geometry.h"
 
 #include "image/Image.h"
 #include "image/ImageData.h"
 #include "OpenGL.h"
 #include "Font.h"
 #include "Image.h"
-#include "Quad.h"
 #include "SpriteBatch.h"
 #include "ParticleSystem.h"
 #include "Canvas.h"
 	Image *newImage(love::image::ImageData *data);
 
 	/**
-	 * Creates a Quad object.
+	 * Creates a Geometry object.
 	 **/
-	Quad *newQuad(float x, float y, float w, float h, float sw, float sh);
+	Geometry *newGeometry(const std::vector<vertex> &vertices);
+
+	/**
+	 * Creates a quadliteral Geometry object.
+	 **/
+	Geometry *newQuad(float x, float y, float w, float h, float sw, float sh);
 
 	/**
 	 * Creates a Font object.

src/modules/graphics/opengl/Image.cpp

 	drawv(t, vertices);
 }
 
-void Image::drawq(love::graphics::Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
+void Image::drawg(Geometry *geom, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 {
 	static Matrix t;
-	const vertex *v = quad->getVertices();
+	size_t count = geom->getVertexCount();
+	if (count == 0)
+		return;
 
+	const vertex *v = geom->getVertices();
 	t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
-	drawv(t, v);
+	drawv(t, v, count);
 }
 
 void Image::setFilter(const Image::Filter &f)
 	}
 }
 
-void Image::drawv(const Matrix &t, const vertex *v) const
+void Image::drawv(const Matrix &t, const vertex *v, size_t count) const
 {
 	bind();
 
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].x);
 	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].s);
-	glDrawArrays(GL_QUADS, 0, 4);
+	glDrawArrays(GL_TRIANGLE_FAN, 0, count); // XXX: works for all *convex* geometries
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 	glDisableClientState(GL_VERTEX_ARRAY);
 

src/modules/graphics/opengl/Image.h

 	void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
 
 	/**
-	 * @copydoc DrawQable::drawq()
+	 * @copydoc DrawGable::drawg()
 	 **/
-	void drawq(love::graphics::Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
+	void drawg(Geometry *geom, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
 
 	/**
 	 * Sets the filter mode.
 
 private:
 
-	void drawv(const Matrix &t, const vertex *v) const;
+	void drawv(const Matrix &t, const vertex *v, size_t count = 4) const;
 
 	friend class PixelEffect;
 	GLuint getTextureName() const

src/modules/graphics/opengl/Quad.cpp

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#include "Quad.h"
-#include "common/Matrix.h"
-
-// GLee
-#include "GLee.h"
-
-// STD
-#include <cstring> // For memcpy
-
-namespace love
-{
-namespace graphics
-{
-namespace opengl
-{
-
-Quad::Quad(const Viewport &v, float sw, float sh)
-	: sw(sw)
-	, sh(sh)
-{
-	memset(vertices, 255, sizeof(vertex)*NUM_VERTICES);
-	refresh(v, sw, sh);
-}
-
-Quad::~Quad()
-{
-}
-
-void Quad::refresh(const Viewport &v, float sw, float sh)
-{
-	if (!GLEE_ARB_texture_non_power_of_two)
-	{
-		sw = next_p2(sw);
-		sh = next_p2(sh);
-	}
-	viewport = v;
-
-	vertices[0].x = 0;
-	vertices[0].y = 0;
-	vertices[1].x = 0;
-	vertices[1].y = v.h;
-	vertices[2].x = v.w;
-	vertices[2].y = v.h;
-	vertices[3].x = v.w;
-	vertices[3].y = 0;
-
-	vertices[0].s = v.x/sw;
-	vertices[0].t = v.y/sh;
-	vertices[1].s = v.x/sw;
-	vertices[1].t = (v.y+v.h)/sh;
-	vertices[2].s = (v.x+v.w)/sw;
-	vertices[2].t = (v.y+v.h)/sh;
-	vertices[3].s = (v.x+v.w)/sw;
-	vertices[3].t = v.y/sh;
-}
-
-void Quad::setViewport(const Quad::Viewport &v)
-{
-	refresh(v, sw, sh);
-}
-
-Quad::Viewport Quad::getViewport() const
-{
-	return viewport;
-}
-
-void Quad::flip(bool x, bool y)
-{
-	vertex temp[4];
-	if (x)
-	{
-		memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
-		vertices[0].s = temp[3].s;
-		vertices[0].t = temp[3].t;
-		vertices[1].s = temp[2].s;
-		vertices[1].t = temp[2].t;
-		vertices[2].s = temp[1].s;
-		vertices[2].t = temp[1].t;
-		vertices[3].s = temp[0].s;
-		vertices[3].t = temp[0].t;
-	}
-	if (y)
-	{
-		memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
-		vertices[0].s = temp[1].s;
-		vertices[0].t = temp[1].t;
-		vertices[1].s = temp[0].s;
-		vertices[1].t = temp[0].t;
-		vertices[2].s = temp[3].s;
-		vertices[2].t = temp[3].t;
-		vertices[3].s = temp[2].s;
-		vertices[3].t = temp[2].t;
-	}
-}
-
-const vertex *Quad::getVertices() const
-{
-	return vertices;
-}
-
-} // opengl
-} // graphics
-} // love

src/modules/graphics/opengl/Quad.h

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#ifndef LOVE_GRAPHICS_OPENGL_QUAD_H
-#define LOVE_GRAPHICS_OPENGL_QUAD_H
-
-// LOVE
-#include "common/math.h"
-#include <graphics/Quad.h>
-
-namespace love
-{
-namespace graphics
-{
-namespace opengl
-{
-
-class Quad : public love::graphics::Quad
-{
-public:
-
-	/**
-	 * Creates a new Quad of size (w,h), using (x,y) as the top-left
-	 * anchor point in the source image. The size of the source image is
-	 * is specified by (sw,sh).
-	 *
-	 * @param sw Width of the source image.
-	 * @param sh Height of the source image.
-	 **/
-	Quad(const Viewport &v, float sw, float sh);
-
-	virtual ~Quad();
-
-	void refresh(const Viewport &v, float sw, float sh);
-
-	void setViewport(const Viewport &v);
-	Viewport getViewport() const;
-
-	void flip(bool x, bool y);
-
-	/**
-	 * Gets a pointer to the vertices.
-	 **/
-	const vertex *getVertices() const;
-
-protected:
-
-	static const unsigned int NUM_VERTICES = 4;
-	vertex vertices[NUM_VERTICES];
-
-	Viewport viewport;
-	float sw, sh;
-};
-
-} // opengl
-} // graphics
-} // love
-
-#endif // LOVE_GRAPHICS_OPENGL_QUAD_H

src/modules/graphics/opengl/SpriteBatch.cpp

 
 // LOVE
 #include "Image.h"
-#include "Quad.h"
+#include "graphics/Geometry.h"
 #include "VertexBuffer.h"
 
 namespace love
 	return index;
 }
 
-int SpriteBatch::addq(Quad *quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
+int SpriteBatch::addg(Geometry *geom, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
 {
 	// Only do this if there's a free slot.
 	if ((index == -1 && next >= size) || index < -1 || index >= next)
 		return -1;
 
+	// only add if geometry is a quad
+	if (geom->getVertexCount() != 4)
+		return -1;
+
 	// Needed for colors.
-	memcpy(sprite, quad->getVertices(), sizeof(vertex)*4);
+	Geometry temp(*geom);
 
 	// Transform.
+	vertex *vertices = const_cast<vertex *>(temp.getVertices());
 	Matrix t;
 	t.setTransformation(x, y, a, sx, sy, ox, oy, kx, ky);
-	t.transform(sprite, sprite, 4);
+	t.transform(vertices, vertices, 4);
 
 	if (color)
-		setColorv(sprite, *color);
+		setColorv(vertices, *color);
 
-	addv(sprite, (index == -1 ? next : index));
+	addv(vertices, (index == -1 ? next : index));
 
 	// Increment counter.
 	if (index == -1)

src/modules/graphics/opengl/SpriteBatch.h

 {
 namespace graphics
 {
+class Geometry;
+
 namespace opengl
 {
 
 // Forward declarations.
 class Image;
-class Quad;
 class VertexBuffer;
 class VertexIndex;
 
 	virtual ~SpriteBatch();
 
 	int add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
-	int addq(Quad *quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
+	int addg(Geometry *geom, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
 	void clear();
 
 	void *lock();

src/modules/graphics/opengl/wrap_Geometry.cpp

+/**
+ * Copyright (c) 2006-2012 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+// LOVE
+#include "wrap_Geometry.h"
+#include "common/Exception.h"
+
+namespace love
+{
+namespace graphics
+{
+namespace opengl
+{
+
+Geometry *luax_checkgeometry(lua_State *L, int idx)
+{
+	return luax_checktype<Geometry>(L, idx, "Geometry", GRAPHICS_GEOMETRY_T);
+}
+
+int w_Geometry_get(lua_State *L)
+{
+	Geometry *geom = luax_checktype<Geometry>(L, 1, "Geometry", GRAPHICS_GEOMETRY_T);
+	size_t i = size_t(luaL_checkint(L, 2));
+	try {
+		const vertex &v = geom->get(i-1);
+		lua_pushnumber(L, v.x);
+		lua_pushnumber(L, v.y);
+		lua_pushnumber(L, v.s);
+		lua_pushnumber(L, v.t);
+		lua_pushnumber(L, v.r);
+		lua_pushnumber(L, v.g);
+		lua_pushnumber(L, v.b);
+		lua_pushnumber(L, v.a);
+	}
+	catch (Exception &e)
+	{
+		return luaL_error(L, e.what());
+	}
+
+	return 8;
+}
+
+int w_Geometry_set(lua_State *L)
+{
+	Geometry *geom = luax_checktype<Geometry>(L, 1, "Geometry", GRAPHICS_GEOMETRY_T);
+	size_t i = size_t(luaL_checkint(L, 2));
+
+	vertex v;
+	v.x = luaL_checknumber(L, 3);
+	v.y = luaL_checknumber(L, 4);
+	v.s = luaL_checknumber(L, 5);
+	v.t = luaL_checknumber(L, 6);
+	v.r = luaL_optint(L,  7, 255);
+	v.g = luaL_optint(L,  8, 255);
+	v.b = luaL_optint(L,  9, 255);
+	v.a = luaL_optint(L, 10, 255);
+
+	try {
+		geom->set(i-1, v);
+	}
+	catch (Exception &e)
+	{
+		return luaL_error(L, e.what());
+	}
+
+	return 0;
+}
+
+int w_Geometry_flip(lua_State *L)
+{
+	Geometry *geom = luax_checktype<Geometry>(L, 1, "Geometry", GRAPHICS_GEOMETRY_T);
+	geom->flip(luax_toboolean(L, 2), luax_toboolean(L, 3));
+	return 0;
+}
+
+static const luaL_Reg w_Geometry_functions[] =
+{
+	{ "set", w_Geometry_set },
+	{ "get", w_Geometry_get },
+	{ "flip", w_Geometry_flip },
+	{ 0, 0 }
+};
+
+extern "C" int luaopen_geometry(lua_State *L)
+{
+	return luax_register_type(L, "Geometry", w_Geometry_functions);
+}
+
+} // opengl
+} // graphics
+} // love

src/modules/graphics/opengl/wrap_Geometry.h

+/**
+ * Copyright (c) 2006-2012 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_GRAPHICS_OPENGL_WRAP_GEOMETRY_H
+#define LOVE_GRAPHICS_OPENGL_WRAP_GEOMETRY_H
+
+// LOVE
+#include "common/runtime.h"
+#include "graphics/Geometry.h"
+
+namespace love
+{
+namespace graphics
+{
+namespace opengl
+{
+
+Geometry *luax_checkgeometry(lua_State *L, int idx);
+int w_Geometry_flip(lua_State *L);
+int w_Geometry_get(lua_State *L);
+int w_Geometry_set(lua_State *L);
+extern "C" int luaopen_geometry(lua_State *L);
+
+} // opengl
+} // graphics
+} // love
+
+#endif // LOVE_GRAPHICS_OPENGL_WRAP_GEOMETRY_H

src/modules/graphics/opengl/wrap_Graphics.cpp

 
 #include "wrap_Graphics.h"
 #include "GLee.h"
-#include "graphics/DrawQable.h"
+#include "graphics/DrawGable.h"
 #include "image/ImageData.h"
 #include "font/Rasterizer.h"
 
 	return 1;
 }
 
+int w_newGeometry(lua_State *L)
+{
+	std::vector<vertex> vertices;
+	if (lua_istable(L, 1))
+	{
+		size_t n = lua_objlen(L, 1);
+		vertices.reserve(n);
+		for (size_t i = 0; i < n; ++i)
+		{
+			vertex v;
+			lua_rawgeti(L, 1, i+1);
+
+			lua_rawgeti(L, -1, 1);
+			v.x = luaL_checknumber(L, -1);
+
+			lua_rawgeti(L, -2, 2);
+			v.y = luaL_checknumber(L, -1);
+
+			lua_rawgeti(L, -3, 3);
+			v.s = luaL_checknumber(L, -1);
+
+			lua_rawgeti(L, -4, 4);
+			v.t = luaL_checknumber(L, -1);
+
+			lua_rawgeti(L, -5, 5);
+			v.r = luaL_optint(L, -1, 255);
+
+			lua_rawgeti(L, -6, 6);
+			v.g = luaL_optint(L, -1, 255);
+
+			lua_rawgeti(L, -7, 7);
+			v.b = luaL_optint(L, -1, 255);
+
+			lua_rawgeti(L, -8, 8);
+			v.a = luaL_optint(L, -1, 255);
+
+			lua_pop(L, 9);
+			vertices.push_back(v);
+		}
+	}
+	else if (lua_isnumber(L, 1))
+	{
+		int n = lua_tonumber(L, 1);
+		if (n <= 0)
+			return luaL_error(L, "Invalid geometry size: %d (must be > 0)", n);
+
+		vertices.resize(n);
+	}
+	else
+		return luaL_typerror(L, 1, "table or number");
+
+	if (vertices.size() < 3)
+		return luaL_error(L, "Need at least three points to construct a geometry.");
+
+	Geometry *geom = instance->newGeometry(vertices);
+
+	if (geom == 0)
+		return luaL_error(L, "Could not create geometry.");
+
+	luax_newtype(L, "Geometry", GRAPHICS_GEOMETRY_T, (void *)geom);
+	return 1;
+}
+
 int w_newQuad(lua_State *L)
 {
 	float x = (float) luaL_checknumber(L, 1);
 	float sw = (float) luaL_checknumber(L, 5);
 	float sh = (float) luaL_checknumber(L, 6);
 
-	Quad *frame = instance->newQuad(x, y, w, h, sw, sh);
+	Geometry *quad = instance->newQuad(x, y, w, h, sw, sh);
 
-	if (frame == 0)
-		return luaL_error(L, "Could not create frame.");
+	if (quad == 0)
+		return luaL_error(L, "Could not create quad.");
 
-	luax_newtype(L, "Quad", GRAPHICS_QUAD_T, (void *)frame);
+	luax_newtype(L, "Geometry", GRAPHICS_GEOMETRY_T, (void *)quad);
 	return 1;
 }
 
 }
 
 /**
- * Draws an Quad of a DrawQable at the specified coordinates,
+ * Draws a Geometry of a DrawGable at the specified coordinates,
  * with rotation and scaling along both axes.
  *
- * @param q The Quad to draw.
+ * @param g The Geometry to draw.
  * @param x The x-coordinate.
  * @param y The y-coordinate.
  * @param angle The amount of rotation.
  * @param kx Shear along the x-axis.
  * @param ky Shear along the y-axis.
  **/
-int w_drawq(lua_State *L)
+int w_drawg(lua_State *L)
 {
-	DrawQable *dq = luax_checktype<DrawQable>(L, 1, "DrawQable", GRAPHICS_DRAWQABLE_T);
-	Quad *q = luax_checkframe(L, 2);
+	DrawGable *dg = luax_checktype<DrawGable>(L, 1, "DrawGable", GRAPHICS_DRAWGABLE_T);
+	Geometry *g = luax_checkgeometry(L, 2);
 	float x = (float)luaL_checknumber(L, 3);
 	float y = (float)luaL_checknumber(L, 4);
 	float angle = (float)luaL_optnumber(L, 5, 0);
 	float oy = (float)luaL_optnumber(L, 9, 0);
 	float kx = (float)luaL_optnumber(L, 10, 0);
 	float ky = (float)luaL_optnumber(L, 11, 0);
-	dq->drawq(q, x, y, angle, sx, sy, ox, oy, kx, ky);
+	dg->drawg(g, x, y, angle, sx, sy, ox, oy, kx, ky);
 	return 0;
 }
 
 	{ "present", w_present },
 
 	{ "newImage", w_newImage },
+	{ "newGeometry", w_newGeometry },
 	{ "newQuad", w_newQuad },
 	{ "newFont", w_newFont },
 	{ "newImageFont", w_newImageFont },
 	{ "isSupported", w_isSupported },
 
 	{ "draw", w_draw },
-	{ "drawq", w_drawq },
+	{ "drawg", w_drawg },
 	{ "drawTest", w_drawTest },
 
 	{ "print", w_print },
 {
 	luaopen_font,
 	luaopen_image,
-	luaopen_frame,
+	luaopen_geometry,
 	luaopen_spritebatch,
 	luaopen_particlesystem,
 	luaopen_canvas,

src/modules/graphics/opengl/wrap_Graphics.h

 // LOVE
 #include "wrap_Font.h"
 #include "wrap_Image.h"
-#include "wrap_Quad.h"
+#include "wrap_Geometry.h"
 #include "wrap_SpriteBatch.h"
 #include "wrap_ParticleSystem.h"
 #include "wrap_Canvas.h"
 int w_defineMask(lua_State *L);
 int w_setMask(lua_State *L);
 int w_newImage(lua_State *L);
+int w_newGeometry(lua_State *L);
 int w_newQuad(lua_State *L);
 int w_newFrame(lua_State *L);
 int w_newFont(lua_State *L);

src/modules/graphics/opengl/wrap_Quad.cpp

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-// LOVE
-#include "wrap_Quad.h"
-
-namespace love
-{
-namespace graphics
-{
-namespace opengl
-{
-
-Quad *luax_checkframe(lua_State *L, int idx)
-{
-	return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
-}
-
-int w_Quad_flip(lua_State *L)
-{
-	Quad *quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
-	quad->flip(luax_toboolean(L, 2), luax_toboolean(L, 3));
-	return 0;
-}
-
-int w_Quad_setViewport(lua_State *L)
-{
-	Quad *quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
-	Quad::Viewport v;
-	v.x = (float) luaL_checknumber(L, 2);
-	v.y = (float) luaL_checknumber(L, 3);
-	v.w = (float) luaL_checknumber(L, 4);
-	v.h = (float) luaL_checknumber(L, 5);
-	quad->setViewport(v);
-	return 0;
-}
-
-int w_Quad_getViewport(lua_State *L)
-{
-	Quad *quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
-	Quad::Viewport v = quad->getViewport();
-	lua_pushnumber(L, v.x);
-	lua_pushnumber(L, v.y);
-	lua_pushnumber(L, v.w);
-	lua_pushnumber(L, v.h);
-	return 4;
-}
-
-static const luaL_Reg w_Quad_functions[] =
-{
-	{ "flip", w_Quad_flip },
-	{ "setViewport", w_Quad_setViewport },
-	{ "getViewport", w_Quad_getViewport },
-	{ 0, 0 }
-};
-
-extern "C" int luaopen_frame(lua_State *L)
-{
-	return luax_register_type(L, "Quad", w_Quad_functions);
-}
-
-} // opengl
-} // graphics
-} // love

src/modules/graphics/opengl/wrap_Quad.h

-/**
- * Copyright (c) 2006-2012 LOVE Development Team
- *
- * This software is provided 'as-is', without any express or implied
- * warranty.  In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- **/
-
-#ifndef LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
-#define LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
-
-// LOVE
-#include "common/runtime.h"
-#include "Quad.h"
-
-namespace love
-{
-namespace graphics
-{
-namespace opengl
-{
-
-Quad *luax_checkframe(lua_State *L, int idx);
-int w_Quad_flip(lua_State *L);
-int w_Quad_setViewport(lua_State *L);
-int w_Quad_getViewport(lua_State *L);
-extern "C" int luaopen_frame(lua_State *L);
-
-} // opengl
-} // graphics
-} // love
-
-#endif // LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H

src/modules/graphics/opengl/wrap_SpriteBatch.cpp

 int w_SpriteBatch_addq(lua_State *L)
 {
 	SpriteBatch *t = luax_checkspritebatch(L, 1);
-	Quad *q = luax_checktype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
+	Geometry *geom = luax_checktype<Geometry>(L, 2, "Geometry", GRAPHICS_GEOMETRY_T);
 	float x = (float)luaL_optnumber(L, 3, 0.0f);
 	float y = (float)luaL_optnumber(L, 4, 0.0f);
 	float angle = (float)luaL_optnumber(L, 5, 0.0f);
 	float oy = (float)luaL_optnumber(L, 9, 0);
 	float kx = (float)luaL_optnumber(L, 10, 0);
 	float ky = (float)luaL_optnumber(L, 11, 0);
-	lua_pushnumber(L, t->addq(q, x, y, angle, sx, sy, ox, oy, kx, ky));
+	lua_pushnumber(L, t->addg(geom, x, y, angle, sx, sy, ox, oy, kx, ky));
 	return 1;
 }
 
 {
 	SpriteBatch *t = luax_checkspritebatch(L, 1);
 	int index = luaL_checkinteger(L, 2);
-	Quad *q = luax_checktype<Quad>(L, 3, "Quad", GRAPHICS_QUAD_T);
+	Geometry *geom = luax_checktype<Geometry>(L, 3, "Geometry", GRAPHICS_GEOMETRY_T);
 	float x = (float)luaL_optnumber(L, 4, 0.0f);
 	float y = (float)luaL_optnumber(L, 5, 0.0f);
 	float angle = (float)luaL_optnumber(L, 6, 0.0f);
 	float oy = (float)luaL_optnumber(L, 10, 0);
 	float kx = (float)luaL_optnumber(L, 11, 0);
 	float ky = (float)luaL_optnumber(L, 12, 0);
-	t->addq(q, x, y, angle, sx, sy, ox, oy, kx, ky, index);
+	t->addg(geom, x, y, angle, sx, sy, ox, oy, kx, ky, index);
 	return 0;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.