Browse Source

Simplify Drawable code

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
b8b670e0ae

+ 3 - 12
src/modules/graphics/Drawable.h

@@ -23,6 +23,7 @@
 
 
 // LOVE
 // LOVE
 #include "common/Object.h"
 #include "common/Object.h"
+#include "common/Matrix.h"
 
 
 namespace love
 namespace love
 {
 {
@@ -43,19 +44,9 @@ public:
 	virtual ~Drawable() {}
 	virtual ~Drawable() {}
 
 
 	/**
 	/**
-	 * Draws the object with the specified transformation.
-	 *
-	 * @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.
+	 * Draws the object with the specified transformation matrix.
 	 **/
 	 **/
-	virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) = 0;
+	virtual void draw(const Matrix4 &m) = 0;
 };
 };
 
 
 } // graphics
 } // graphics

+ 1 - 12
src/modules/graphics/Texture.h

@@ -76,19 +76,8 @@ public:
 
 
 	/**
 	/**
 	 * Draws the texture using the specified transformation with a Quad applied.
 	 * Draws the texture using the specified transformation with a Quad applied.
-	 *
-	 * @param quad The Quad object 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) = 0;
+	virtual void drawq(Quad *quad, const Matrix4 &m) = 0;
 
 
 	virtual int getWidth() const;
 	virtual int getWidth() const;
 	virtual int getHeight() const;
 	virtual int getHeight() const;

+ 4 - 8
src/modules/graphics/opengl/Canvas.cpp

@@ -322,18 +322,14 @@ void Canvas::drawv(const Matrix4 &t, const Vertex *v)
 	gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
 	gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
 }
 }
 
 
-void Canvas::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Canvas::draw(const Matrix4 &m)
 {
 {
-	Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
-
-	drawv(t, vertices);
+	drawv(m, vertices);
 }
 }
 
 
-void Canvas::drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Canvas::drawq(Quad *quad, const Matrix4 &m)
 {
 {
-	Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
-
-	drawv(t, quad->getVertices());
+	drawv(m, quad->getVertices());
 }
 }
 
 
 void Canvas::setFilter(const Texture::Filter &f)
 void Canvas::setFilter(const Texture::Filter &f)

+ 7 - 7
src/modules/graphics/opengl/Canvas.h

@@ -70,17 +70,17 @@ public:
 	virtual ~Canvas();
 	virtual ~Canvas();
 
 
 	// Implements Volatile.
 	// Implements Volatile.
-	virtual bool loadVolatile();
-	virtual void unloadVolatile();
+	bool loadVolatile() override;
+	void unloadVolatile() override;
 
 
 	// Implements Drawable.
 	// Implements Drawable.
-	virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	void draw(const Matrix4 &m) override;
 
 
 	// Implements Texture.
 	// Implements Texture.
-	virtual void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
-	virtual void setFilter(const Texture::Filter &f);
-	virtual bool setWrap(const Texture::Wrap &w);
-	virtual const void *getHandle() const;
+	void drawq(Quad *quad, const Matrix4 &m) override;
+	void setFilter(const Texture::Filter &f) override;
+	bool setWrap(const Texture::Wrap &w) override;
+	const void *getHandle() const override;
 
 
 	/**
 	/**
 	 * @param canvases A list of other canvases to temporarily attach to this one,
 	 * @param canvases A list of other canvases to temporarily attach to this one,

+ 4 - 8
src/modules/graphics/opengl/Font.cpp

@@ -703,7 +703,7 @@ void Font::printv(const Matrix4 &t, const std::vector<DrawCommand> &drawcommands
 	drawVertices(drawcommands, false);
 	drawVertices(drawcommands, false);
 }
 }
 
 
-void Font::print(const std::vector<ColoredString> &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Font::print(const std::vector<ColoredString> &text, const Matrix4 &m)
 {
 {
 	ColoredCodepoints codepoints;
 	ColoredCodepoints codepoints;
 	getCodepointsFromString(text, codepoints);
 	getCodepointsFromString(text, codepoints);
@@ -711,12 +711,10 @@ void Font::print(const std::vector<ColoredString> &text, float x, float y, float
 	std::vector<GlyphVertex> vertices;
 	std::vector<GlyphVertex> vertices;
 	std::vector<DrawCommand> drawcommands = generateVertices(codepoints, vertices);
 	std::vector<DrawCommand> drawcommands = generateVertices(codepoints, vertices);
 
 
-	Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
-
-	printv(t, drawcommands, vertices);
+	printv(m, drawcommands, vertices);
 }
 }
 
 
-void Font::printf(const std::vector<ColoredString> &text, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Font::printf(const std::vector<ColoredString> &text, float wrap, AlignMode align, const Matrix4 &m)
 {
 {
 	ColoredCodepoints codepoints;
 	ColoredCodepoints codepoints;
 	getCodepointsFromString(text, codepoints);
 	getCodepointsFromString(text, codepoints);
@@ -724,9 +722,7 @@ void Font::printf(const std::vector<ColoredString> &text, float x, float y, floa
 	std::vector<GlyphVertex> vertices;
 	std::vector<GlyphVertex> vertices;
 	std::vector<DrawCommand> drawcommands = generateVerticesFormatted(codepoints, wrap, align, vertices);
 	std::vector<DrawCommand> drawcommands = generateVerticesFormatted(codepoints, wrap, align, vertices);
 
 
-	Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
-
-	printv(t, drawcommands, vertices);
+	printv(m, drawcommands, vertices);
 }
 }
 
 
 int Font::getWidth(const std::string &str)
 int Font::getWidth(const std::string &str)

+ 3 - 15
src/modules/graphics/opengl/Font.h

@@ -115,22 +115,10 @@ public:
 	static void getCodepointsFromString(const std::vector<ColoredString> &strs, ColoredCodepoints &codepoints);
 	static void getCodepointsFromString(const std::vector<ColoredString> &strs, ColoredCodepoints &codepoints);
 
 
 	/**
 	/**
-	 * Prints the text at the designated position with rotation and scaling.
-	 *
-	 * @param text A string.
-	 * @param x The x-coordinate.
-	 * @param y The y-coordinate.
-	 * @param angle The amount of rotation.
-	 * @param sx Scale along the x axis.
-	 * @param sy Scale 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.
+	 * Draws the text at the designated position with a transformation applied.
 	 **/
 	 **/
-	void print(const std::vector<ColoredString> &text, float x, float y, float angle = 0.0f, float sx = 1.0f, float sy = 1.0f, float ox = 0.0f, float oy = 0.0f, float kx = 0.0f, float ky = 0.0f);
-
-	void printf(const std::vector<ColoredString> &text, float x, float y, float wrap, AlignMode align, float angle = 0.0f, float sx = 1.0f, float sy = 1.0f, float ox = 0.0f, float oy = 0.0f, float kx = 0.0f, float ky = 0.0f);
+	void print(const std::vector<ColoredString> &text, const Matrix4 &m);
+	void printf(const std::vector<ColoredString> &text, float wrap, AlignMode align, const Matrix4 &m);
 
 
 	/**
 	/**
 	 * Returns the height of the font.
 	 * Returns the height of the font.

+ 4 - 4
src/modules/graphics/opengl/Graphics.cpp

@@ -1258,24 +1258,24 @@ bool Graphics::isWireframe() const
 	return states.back().wireframe;
 	return states.back().wireframe;
 }
 }
 
 
-void Graphics::print(const std::vector<Font::ColoredString> &str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Graphics::print(const std::vector<Font::ColoredString> &str, const Matrix4 &m)
 {
 {
 	checkSetDefaultFont();
 	checkSetDefaultFont();
 
 
 	DisplayState &state = states.back();
 	DisplayState &state = states.back();
 
 
 	if (state.font.get() != nullptr)
 	if (state.font.get() != nullptr)
-		state.font->print(str, x, y, angle, sx, sy, ox, oy, kx, ky);
+		state.font->print(str, m);
 }
 }
 
 
-void Graphics::printf(const std::vector<Font::ColoredString> &str, float x, float y, float wrap, Font::AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Graphics::printf(const std::vector<Font::ColoredString> &str, float wrap, Font::AlignMode align, const Matrix4 &m)
 {
 {
 	checkSetDefaultFont();
 	checkSetDefaultFont();
 
 
 	DisplayState &state = states.back();
 	DisplayState &state = states.back();
 
 
 	if (state.font.get() != nullptr)
 	if (state.font.get() != nullptr)
-		state.font->printf(str, x, y, wrap, align, angle, sx, sy, ox, oy, kx, ky);
+		state.font->printf(str, wrap, align, m);
 }
 }
 
 
 /**
 /**

+ 8 - 31
src/modules/graphics/opengl/Graphics.h

@@ -331,37 +331,14 @@ public:
 	bool isWireframe() const;
 	bool isWireframe() const;
 
 
 	/**
 	/**
-	 * Draws text at the specified coordinates, with rotation and
-	 * scaling along both axes.
-	 * @param x The x-coordinate.
-	 * @param y The y-coordinate.
-	 * @param angle The amount of rotation.
-	 * @param sx The scale factor along the x-axis. (1 = normal).
-	 * @param sy The scale factor along the y-axis. (1 = normal).
-	 * @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.
-	 **/
-	void print(const std::vector<Font::ColoredString> &str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
-
-	/**
-	 * Draw formatted text on screen at the specified coordinates.
-	 *
-	 * @param str A string of text.
-	 * @param x The x-coordinate.
-	 * @param y The y-coordinate.
-	 * @param wrap The maximum width of the text area.
-	 * @param align Where to align the text.
-	 * @param angle The amount of rotation.
-	 * @param sx The scale factor along the x-axis. (1 = normal).
-	 * @param sy The scale factor along the y-axis. (1 = normal).
-	 * @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.
-	 **/
-	void printf(const std::vector<Font::ColoredString> &str, float x, float y, float wrap, Font::AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	 * Draws text at the specified coordinates
+	 **/
+	void print(const std::vector<Font::ColoredString> &str, const Matrix4 &m);
+
+	/**
+	 * Draws formatted text on screen at the specified coordinates.
+	 **/
+	void printf(const std::vector<Font::ColoredString> &str, float wrap, Font::AlignMode align, const Matrix4 &m);
 
 
 	/**
 	/**
 	 * Draws a point at (x,y).
 	 * Draws a point at (x,y).

+ 4 - 8
src/modules/graphics/opengl/Image.cpp

@@ -460,18 +460,14 @@ void Image::drawv(const Matrix4 &t, const Vertex *v)
 	gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
 	gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
 }
 }
 
 
-void Image::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Image::draw(const Matrix4 &m)
 {
 {
-	Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
-
-	drawv(t, vertices);
+	drawv(m, vertices);
 }
 }
 
 
-void Image::drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Image::drawq(Quad *quad, const Matrix4 &m)
 {
 {
-	Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
-
-	drawv(t, quad->getVertices());
+	drawv(m, quad->getVertices());
 }
 }
 
 
 const void *Image::getHandle() const
 const void *Image::getHandle() const

+ 7 - 7
src/modules/graphics/opengl/Image.h

@@ -85,26 +85,26 @@ public:
 	virtual ~Image();
 	virtual ~Image();
 
 
 	// Implements Volatile.
 	// Implements Volatile.
-	bool loadVolatile();
-	void unloadVolatile();
+	bool loadVolatile() override;
+	void unloadVolatile() override;
 
 
 	/**
 	/**
 	 * @copydoc Drawable::draw()
 	 * @copydoc Drawable::draw()
 	 **/
 	 **/
-	void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	void draw(const Matrix4 &m) override;
 
 
 	/**
 	/**
 	 * @copydoc Texture::drawq()
 	 * @copydoc Texture::drawq()
 	 **/
 	 **/
-	void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	void drawq(Quad *quad, const Matrix4 &m) override;
 
 
-	virtual const void *getHandle() const;
+	const void *getHandle() const override;
 
 
 	const std::vector<StrongRef<love::image::ImageData>> &getImageData() const;
 	const std::vector<StrongRef<love::image::ImageData>> &getImageData() const;
 	const std::vector<StrongRef<love::image::CompressedImageData>> &getCompressedData() const;
 	const std::vector<StrongRef<love::image::CompressedImageData>> &getCompressedData() const;
 
 
-	virtual void setFilter(const Texture::Filter &f);
-	virtual bool setWrap(const Texture::Wrap &w);
+	void setFilter(const Texture::Filter &f) override;
+	bool setWrap(const Texture::Wrap &w) override;
 
 
 	void setMipmapSharpness(float sharpness);
 	void setMipmapSharpness(float sharpness);
 	float getMipmapSharpness() const;
 	float getMipmapSharpness() const;

+ 1 - 3
src/modules/graphics/opengl/Mesh.cpp

@@ -574,7 +574,7 @@ int Mesh::bindAttributeToShaderInput(int attributeindex, const std::string &inpu
 	return attriblocation;
 	return attriblocation;
 }
 }
 
 
-void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Mesh::draw(const Matrix4 &m)
 {
 {
 	if (vertexCount <= 0)
 	if (vertexCount <= 0)
 		return;
 		return;
@@ -606,8 +606,6 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo
 	else
 	else
 		gl.bindTexture(gl.getDefaultTexture());
 		gl.bindTexture(gl.getDefaultTexture());
 
 
-	Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
-
 	OpenGL::TempTransform transform(gl);
 	OpenGL::TempTransform transform(gl);
 	transform.get() *= m;
 	transform.get() *= m;
 
 

+ 1 - 1
src/modules/graphics/opengl/Mesh.h

@@ -197,7 +197,7 @@ public:
 	int bindAttributeToShaderInput(int attributeindex, const std::string &inputname);
 	int bindAttributeToShaderInput(int attributeindex, const std::string &inputname);
 
 
 	// Implements Drawable.
 	// Implements Drawable.
-	void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) override;
+	void draw(const Matrix4 &m) override;
 
 
 	static GLenum getGLBufferUsage(Usage usage);
 	static GLenum getGLBufferUsage(Usage usage);
 
 

+ 2 - 2
src/modules/graphics/opengl/ParticleSystem.cpp

@@ -84,7 +84,7 @@ void ParticleSystem::setBufferSize(uint32 size)
 	createVertices(size);
 	createVertices(size);
 }
 }
 
 
-void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void ParticleSystem::draw(const Matrix4 &m)
 {
 {
 	uint32 pCount = getCount();
 	uint32 pCount = getCount();
 
 
@@ -94,7 +94,7 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
 	OpenGL::TempDebugGroup debuggroup("ParticleSystem draw");
 	OpenGL::TempDebugGroup debuggroup("ParticleSystem draw");
 
 
 	OpenGL::TempTransform transform(gl);
 	OpenGL::TempTransform transform(gl);
-	transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
+	transform.get() *= m;
 
 
 	const Vertex *textureVerts = texture->getVertices();
 	const Vertex *textureVerts = texture->getVertices();
 	Vertex *pVerts = particleVerts;
 	Vertex *pVerts = particleVerts;

+ 1 - 1
src/modules/graphics/opengl/ParticleSystem.h

@@ -43,7 +43,7 @@ public:
 
 
 	ParticleSystem *clone() override;
 	ParticleSystem *clone() override;
 	void setBufferSize(uint32 size) override;
 	void setBufferSize(uint32 size) override;
-	void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) override;
+	void draw(const Matrix4 &m) override;
 
 
 private:
 private:
 
 

+ 7 - 11
src/modules/graphics/opengl/SpriteBatch.cpp

@@ -66,7 +66,7 @@ SpriteBatch::~SpriteBatch()
 	delete array_buf;
 	delete array_buf;
 }
 }
 
 
-int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
+int SpriteBatch::add(const Matrix4 &m, int index /*= -1*/)
 {
 {
 	if (index < -1 || index >= size)
 	if (index < -1 || index >= size)
 		throw love::Exception("Invalid sprite index: %d", index + 1);
 		throw love::Exception("Invalid sprite index: %d", index + 1);
@@ -74,9 +74,7 @@ int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, fl
 	if (index == -1 && next >= size)
 	if (index == -1 && next >= size)
 		setBufferSize(size * 2);
 		setBufferSize(size * 2);
 
 
-	Matrix3 t(x, y, a, sx, sy, ox, oy, kx, ky);
-
-	addv(texture->getVertices(), t, (index == -1) ? next : index);
+	addv(texture->getVertices(), m, (index == -1) ? next : index);
 
 
 	// Increment counter.
 	// Increment counter.
 	if (index == -1)
 	if (index == -1)
@@ -85,7 +83,7 @@ int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, fl
 	return index;
 	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::addq(Quad *quad, const Matrix4 &m, int index /*= -1*/)
 {
 {
 	if (index < -1 || index >= size)
 	if (index < -1 || index >= size)
 		throw love::Exception("Invalid sprite index: %d", index + 1);
 		throw love::Exception("Invalid sprite index: %d", index + 1);
@@ -93,9 +91,7 @@ int SpriteBatch::addq(Quad *quad, float x, float y, float a, float sx, float sy,
 	if (index == -1 && next >= size)
 	if (index == -1 && next >= size)
 		setBufferSize(size * 2);
 		setBufferSize(size * 2);
 
 
-	Matrix3 t(x, y, a, sx, sy, ox, oy, kx, ky);
-
-	addv(quad->getVertices(), t, (index == -1) ? next : index);
+	addv(quad->getVertices(), m, (index == -1) ? next : index);
 
 
 	// Increment counter.
 	// Increment counter.
 	if (index == -1)
 	if (index == -1)
@@ -249,7 +245,7 @@ bool SpriteBatch::getDrawRange(int &start, int &count) const
 	return true;
 	return true;
 }
 }
 
 
-void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void SpriteBatch::draw(const Matrix4 &m)
 {
 {
 	const size_t pos_offset   = offsetof(Vertex, x);
 	const size_t pos_offset   = offsetof(Vertex, x);
 	const size_t texel_offset = offsetof(Vertex, s);
 	const size_t texel_offset = offsetof(Vertex, s);
@@ -261,7 +257,7 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float
 	OpenGL::TempDebugGroup debuggroup("SpriteBatch draw");
 	OpenGL::TempDebugGroup debuggroup("SpriteBatch draw");
 
 
 	OpenGL::TempTransform transform(gl);
 	OpenGL::TempTransform transform(gl);
-	transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
+	transform.get() *= m;
 
 
 	gl.bindTexture(*(GLuint *) texture->getHandle());
 	gl.bindTexture(*(GLuint *) texture->getHandle());
 
 
@@ -320,7 +316,7 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float
 		gl.drawElements(GL_TRIANGLES, (GLsizei) quad_indices.getIndexCount(count), quad_indices.getType(), indices);
 		gl.drawElements(GL_TRIANGLES, (GLsizei) quad_indices.getIndexCount(count), quad_indices.getType(), indices);
 }
 }
 
 
-void SpriteBatch::addv(const Vertex *v, const Matrix3 &m, int index)
+void SpriteBatch::addv(const Vertex *v, const Matrix4 &m, int index)
 {
 {
 	// Needed for colors.
 	// Needed for colors.
 	Vertex sprite[4] = {v[0], v[1], v[2], v[3]};
 	Vertex sprite[4] = {v[0], v[1], v[2], v[3]};

+ 4 - 4
src/modules/graphics/opengl/SpriteBatch.h

@@ -55,8 +55,8 @@ public:
 	SpriteBatch(Texture *texture, int size, Mesh::Usage usage);
 	SpriteBatch(Texture *texture, int size, Mesh::Usage usage);
 	virtual ~SpriteBatch();
 	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 add(const Matrix4 &m, int index = -1);
+	int addq(Quad *quad, const Matrix4 &m, int index = -1);
 	void clear();
 	void clear();
 
 
 	void flush();
 	void flush();
@@ -106,7 +106,7 @@ public:
 	bool getDrawRange(int &start, int &count) const;
 	bool getDrawRange(int &start, int &count) const;
 
 
 	// Implements Drawable.
 	// Implements Drawable.
-	void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	void draw(const Matrix4 &m) override;
 
 
 private:
 private:
 
 
@@ -122,7 +122,7 @@ private:
 	 **/
 	 **/
 	void setBufferSize(int newsize);
 	void setBufferSize(int newsize);
 
 
-	void addv(const Vertex *v, const Matrix3 &m, int index);
+	void addv(const Vertex *v, const Matrix4 &m, int index);
 
 
 	/**
 	/**
 	 * Set the color for vertices.
 	 * Set the color for vertices.

+ 6 - 8
src/modules/graphics/opengl/Text.cpp

@@ -182,21 +182,19 @@ void Text::set(const std::vector<Font::ColoredString> &text, float wrap, Font::A
 	Font::ColoredCodepoints codepoints;
 	Font::ColoredCodepoints codepoints;
 	Font::getCodepointsFromString(text, codepoints);
 	Font::getCodepointsFromString(text, codepoints);
 
 
-	addTextData({codepoints, wrap, align, {}, false, false, Matrix3()});
+	addTextData({codepoints, wrap, align, {}, false, false, Matrix4()});
 }
 }
 
 
-int Text::add(const std::vector<Font::ColoredString> &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+int Text::add(const std::vector<Font::ColoredString> &text, const Matrix4 &m)
 {
 {
-	return addf(text, -1.0f, Font::ALIGN_MAX_ENUM, x, y, angle, sx, sy, ox, oy, kx, ky);
+	return addf(text, -1.0f, Font::ALIGN_MAX_ENUM, m);
 }
 }
 
 
-int Text::addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+int Text::addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, const Matrix4 &m)
 {
 {
 	Font::ColoredCodepoints codepoints;
 	Font::ColoredCodepoints codepoints;
 	Font::getCodepointsFromString(text, codepoints);
 	Font::getCodepointsFromString(text, codepoints);
 
 
-	Matrix3 m(x, y, angle, sx, sy, ox, oy, kx, ky);
-
 	addTextData({codepoints, wrap, align, {}, true, true, m});
 	addTextData({codepoints, wrap, align, {}, true, true, m});
 
 
 	return (int) text_data.size() - 1;
 	return (int) text_data.size() - 1;
@@ -210,7 +208,7 @@ void Text::clear()
 	vert_offset = 0;
 	vert_offset = 0;
 }
 }
 
 
-void Text::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Text::draw(const Matrix4 &m)
 {
 {
 	if (vbo == nullptr || draw_commands.empty())
 	if (vbo == nullptr || draw_commands.empty())
 		return;
 		return;
@@ -227,7 +225,7 @@ void Text::draw(float x, float y, float angle, float sx, float sy, float ox, flo
 	const size_t stride = sizeof(Font::GlyphVertex);
 	const size_t stride = sizeof(Font::GlyphVertex);
 
 
 	OpenGL::TempTransform transform(gl);
 	OpenGL::TempTransform transform(gl);
-	transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
+	transform.get() *= m;
 
 
 	{
 	{
 		GLBuffer::Bind bind(*vbo);
 		GLBuffer::Bind bind(*vbo);

+ 5 - 4
src/modules/graphics/opengl/Text.h

@@ -44,12 +44,13 @@ public:
 	void set(const std::vector<Font::ColoredString> &text);
 	void set(const std::vector<Font::ColoredString> &text);
 	void set(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align);
 	void set(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align);
 
 
-	int add(const std::vector<Font::ColoredString> &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
-	int addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	int add(const std::vector<Font::ColoredString> &text, const Matrix4 &m);
+	int addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, const Matrix4 &m);
+
 	void clear();
 	void clear();
 
 
 	// Implements Drawable.
 	// Implements Drawable.
-	virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	void draw(const Matrix4 &m) override;
 
 
 	void setFont(Font *f);
 	void setFont(Font *f);
 	Font *getFont() const;
 	Font *getFont() const;
@@ -74,7 +75,7 @@ private:
 		Font::TextInfo text_info;
 		Font::TextInfo text_info;
 		bool use_matrix;
 		bool use_matrix;
 		bool append_vertices;
 		bool append_vertices;
-		Matrix3 matrix;
+		Matrix4 matrix;
 	};
 	};
 
 
 	void uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t vertoffset);
 	void uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t vertoffset);

+ 2 - 2
src/modules/graphics/opengl/Video.cpp

@@ -114,7 +114,7 @@ love::video::VideoStream *Video::getStream()
 	return stream;
 	return stream;
 }
 }
 
 
-void Video::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+void Video::draw(const Matrix4 &m)
 {
 {
 	update();
 	update();
 
 
@@ -130,7 +130,7 @@ void Video::draw(float x, float y, float angle, float sx, float sy, float ox, fl
 	shader->setVideoTextures(textures[0], textures[1], textures[2]);
 	shader->setVideoTextures(textures[0], textures[1], textures[2]);
 
 
 	OpenGL::TempTransform transform(gl);
 	OpenGL::TempTransform transform(gl);
-	transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
+	transform.get() *= m;
 
 
 	gl.useVertexAttribArrays(ATTRIBFLAG_POS | ATTRIBFLAG_TEXCOORD);
 	gl.useVertexAttribArrays(ATTRIBFLAG_POS | ATTRIBFLAG_TEXCOORD);
 
 

+ 5 - 3
src/modules/graphics/opengl/Video.h

@@ -44,11 +44,13 @@ public:
 	~Video();
 	~Video();
 
 
 	// Volatile
 	// Volatile
-	bool loadVolatile();
-	void unloadVolatile();
+	bool loadVolatile() override;
+	void unloadVolatile() override;
+
+	// Drawable
+	void draw(const Matrix4 &m) override;
 
 
 	love::video::VideoStream *getStream();
 	love::video::VideoStream *getStream();
-	void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
 
 
 	love::audio::Source *getSource();
 	love::audio::Source *getSource();
 	void setSource(love::audio::Source *source);
 	void setSource(love::audio::Source *source);

+ 10 - 8
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -1551,11 +1551,13 @@ int w_draw(lua_State *L)
 	float kx = (float) luaL_optnumber(L, startidx + 7, 0.0);
 	float kx = (float) luaL_optnumber(L, startidx + 7, 0.0);
 	float ky = (float) luaL_optnumber(L, startidx + 8, 0.0);
 	float ky = (float) luaL_optnumber(L, startidx + 8, 0.0);
 
 
+	Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
+
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		if (texture && quad)
 		if (texture && quad)
-			texture->drawq(quad, x, y, a, sx, sy, ox, oy, kx, ky);
+			texture->drawq(quad, m);
 		else if (drawable)
 		else if (drawable)
-			drawable->draw(x, y, a, sx, sy, ox, oy, kx, ky);
+			drawable->draw(m);
 	});
 	});
 
 
 	return 0;
 	return 0;
@@ -1576,9 +1578,9 @@ int w_print(lua_State *L)
 	float kx = (float)luaL_optnumber(L, 9, 0.0f);
 	float kx = (float)luaL_optnumber(L, 9, 0.0f);
 	float ky = (float)luaL_optnumber(L, 10, 0.0f);
 	float ky = (float)luaL_optnumber(L, 10, 0.0f);
 
 
-	luax_catchexcept(L,
-		[&](){ instance()->print(str, x, y, angle, sx, sy, ox, oy, kx,ky); }
-	);
+	Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
+
+	luax_catchexcept(L, [&](){ instance()->print(str, m); });
 	return 0;
 	return 0;
 }
 }
 
 
@@ -1616,9 +1618,9 @@ int w_printf(lua_State *L)
 		ky = (float) luaL_optnumber(L, 12, 0.0f);
 		ky = (float) luaL_optnumber(L, 12, 0.0f);
 	}
 	}
 
 
-	luax_catchexcept(L,
-		[&](){ instance()->printf(str, x, y, wrap, align, angle, sx, sy, ox, oy, kx, ky); }
-	);
+	Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
+
+	luax_catchexcept(L, [&](){ instance()->printf(str, wrap, align, m); });
 	return 0;
 	return 0;
 }
 }
 
 

+ 4 - 2
src/modules/graphics/opengl/wrap_SpriteBatch.cpp

@@ -61,11 +61,13 @@ static inline int w_SpriteBatch_add_or_set(lua_State *L, SpriteBatch *t, int sta
 	float kx = (float) luaL_optnumber(L, startidx + 7, 0.0);
 	float kx = (float) luaL_optnumber(L, startidx + 7, 0.0);
 	float ky = (float) luaL_optnumber(L, startidx + 8, 0.0);
 	float ky = (float) luaL_optnumber(L, startidx + 8, 0.0);
 
 
+	Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
+
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		if (quad)
 		if (quad)
-			index = t->addq(quad, x, y, a, sx, sy, ox, oy, kx, ky, index);
+			index = t->addq(quad, m, index);
 		else
 		else
-			index = t->add(x, y, a, sx, sy, ox, oy, kx, ky, index);
+			index = t->add(m, index);
 	});
 	});
 
 
 	return index;
 	return index;

+ 4 - 2
src/modules/graphics/opengl/wrap_Text.cpp

@@ -139,8 +139,9 @@ int w_Text_add(lua_State *L)
 	float kx = (float) luaL_optnumber(L, 10, 0.0);
 	float kx = (float) luaL_optnumber(L, 10, 0.0);
 	float ky = (float) luaL_optnumber(L, 11, 0.0);
 	float ky = (float) luaL_optnumber(L, 11, 0.0);
 
 
+	Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
 	int index = 0;
 	int index = 0;
-	luax_catchexcept(L, [&](){ index = t->add(text, x, y, a, sx, sy, ox, oy, kx, ky); });
+	luax_catchexcept(L, [&](){ index = t->add(text, m); });
 	lua_pushnumber(L, index + 1);
 	lua_pushnumber(L, index + 1);
 
 
 	return 1;
 	return 1;
@@ -171,8 +172,9 @@ int w_Text_addf(lua_State *L)
 	float kx = (float) luaL_optnumber(L, 12, 0.0);
 	float kx = (float) luaL_optnumber(L, 12, 0.0);
 	float ky = (float) luaL_optnumber(L, 13, 0.0);
 	float ky = (float) luaL_optnumber(L, 13, 0.0);
 
 
+	Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
 	int index = 0;
 	int index = 0;
-	luax_catchexcept(L, [&](){ index = t->addf(text, wrap, align, x, y, a, sx, sy, ox, oy, kx, ky); });
+	luax_catchexcept(L, [&](){ index = t->addf(text, wrap, align, m); });
 	lua_pushnumber(L, index + 1);
 	lua_pushnumber(L, index + 1);
 
 
 	return 1;
 	return 1;