Commits

Bart van Strien committed 86a44f2 Draft

CRLF to LF

Comments (0)

Files changed (414)

src/common/Data.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_DATA_H
-#define LOVE_DATA_H
-
-// LOVE
-#include "config.h"
-#include "Object.h"
-
-namespace love
-{
-
-/**
- * This class is a simple abstraction over all objects which contain data.
- **/
-class Data : public Object
-{
-public:
-
-	/**
-	 * Destructor.
-	 **/
-	virtual ~Data() {};
-
-	/**
-	 * Gets a pointer to the data. This pointer will obviously not
-	 * be valid if the Data object is destroyed.
-	 **/
-	virtual void *getData() const = 0 ;
-
-	/**
-	 * Gets the size of the Data in bytes.
-	 **/
-	virtual int getSize() const = 0;
-
-}; // Data
-
-} // love
-
-#endif // LOVE_DATA_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_DATA_H
+#define LOVE_DATA_H
+
+// LOVE
+#include "config.h"
+#include "Object.h"
+
+namespace love
+{
+
+/**
+ * This class is a simple abstraction over all objects which contain data.
+ **/
+class Data : public Object
+{
+public:
+
+	/**
+	 * Destructor.
+	 **/
+	virtual ~Data() {};
+
+	/**
+	 * Gets a pointer to the data. This pointer will obviously not
+	 * be valid if the Data object is destroyed.
+	 **/
+	virtual void *getData() const = 0 ;
+
+	/**
+	 * Gets the size of the Data in bytes.
+	 **/
+	virtual int getSize() const = 0;
+
+}; // Data
+
+} // love
+
+#endif // LOVE_DATA_H

src/common/EnumMap.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_ENUM_MAP_H
-#define LOVE_ENUM_MAP_H
-
-#include "Exception.h"
-
-namespace love
-{
-
-template<typename T, typename U, unsigned PEAK>
-class EnumMap
-{
-public:
-
-	struct Entry
-	{
-		T t;
-		U u;
-	};
-
-	EnumMap(Entry *entries, unsigned size)
-	{
-		unsigned n = size/sizeof(Entry);
-
-		for (unsigned i = 0; i<n; ++i)
-		{
-			unsigned e_t = (unsigned)entries[i].t;
-			unsigned e_u = (unsigned)entries[i].u;
-
-			if (e_t < PEAK)
-			{
-				values_u[e_t].v = e_u;
-				values_u[e_t].set = true;
-			}
-			if (e_u < PEAK)
-			{
-				values_t[e_u].v = e_t;
-				values_t[e_u].set = true;
-			}
-		}
-	}
-
-	bool find(T t, U &u)
-	{
-		if ((unsigned)t < PEAK && values_u[(unsigned)t].set)
-		{
-			u = (U)values_u[(unsigned)t].v;
-			return true;
-		}
-
-		return false;
-	}
-
-	bool find(U u, T &t)
-	{
-		if ((unsigned)u < PEAK && values_t[(unsigned)u].set)
-		{
-			t = (T)values_t[(unsigned)u].v;
-			return true;
-		}
-
-		return false;
-	}
-
-private:
-
-	struct Value
-	{
-		unsigned v;
-		bool set;
-		Value() : set(false) {}
-	};
-
-	Value values_t[PEAK];
-	Value values_u[PEAK];
-
-}; // EnumMap
-
-} // love
-
-#endif // LOVE_ENUM_MAP_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_ENUM_MAP_H
+#define LOVE_ENUM_MAP_H
+
+#include "Exception.h"
+
+namespace love
+{
+
+template<typename T, typename U, unsigned PEAK>
+class EnumMap
+{
+public:
+
+	struct Entry
+	{
+		T t;
+		U u;
+	};
+
+	EnumMap(Entry *entries, unsigned size)
+	{
+		unsigned n = size/sizeof(Entry);
+
+		for (unsigned i = 0; i<n; ++i)
+		{
+			unsigned e_t = (unsigned)entries[i].t;
+			unsigned e_u = (unsigned)entries[i].u;
+
+			if (e_t < PEAK)
+			{
+				values_u[e_t].v = e_u;
+				values_u[e_t].set = true;
+			}
+			if (e_u < PEAK)
+			{
+				values_t[e_u].v = e_t;
+				values_t[e_u].set = true;
+			}
+		}
+	}
+
+	bool find(T t, U &u)
+	{
+		if ((unsigned)t < PEAK && values_u[(unsigned)t].set)
+		{
+			u = (U)values_u[(unsigned)t].v;
+			return true;
+		}
+
+		return false;
+	}
+
+	bool find(U u, T &t)
+	{
+		if ((unsigned)u < PEAK && values_t[(unsigned)u].set)
+		{
+			t = (T)values_t[(unsigned)u].v;
+			return true;
+		}
+
+		return false;
+	}
+
+private:
+
+	struct Value
+	{
+		unsigned v;
+		bool set;
+		Value() : set(false) {}
+	};
+
+	Value values_t[PEAK];
+	Value values_u[PEAK];
+
+}; // EnumMap
+
+} // love
+
+#endif // LOVE_ENUM_MAP_H

src/common/Exception.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 "Exception.h"
-#include "common/config.h"
-
-#include <iostream>
-
-using namespace std;
-
-namespace love
-{
-
-Exception::Exception(const char *fmt, ...)
-{
-	va_list args;
-	int size_buffer = 256, size_out;
-	char *buffer;
-	while (true)
-	{
-		buffer = new char[size_buffer];
-		memset(buffer, 0, size_buffer);
-
-		va_start(args, fmt);
-		size_out = vsnprintf(buffer, size_buffer, fmt, args);
-		va_end(args);
-
-		// see http://perfec.to/vsnprintf/pasprintf.c
-		// if size_out ...
-		//      == -1             --> output was truncated
-		//      == size_buffer    --> output was truncated
-		//      == size_buffer-1  --> ambiguous, /may/ have been truncated
-		//       > size_buffer    --> output was truncated, and size_out
-		//                            bytes would have been written
-		if (size_out == size_buffer || size_out == -1 || size_out == size_buffer-1)
-			size_buffer *= 2;
-		else if (size_out > size_buffer)
-			size_buffer = size_out + 2; // to avoid the ambiguous case
-		else
-			break;
-
-		delete[] buffer;
-	}
-	message = std::string(buffer);
-	delete[] buffer;
-}
-
-}
+/**
+ * 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 "Exception.h"
+#include "common/config.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace love
+{
+
+Exception::Exception(const char *fmt, ...)
+{
+	va_list args;
+	int size_buffer = 256, size_out;
+	char *buffer;
+	while (true)
+	{
+		buffer = new char[size_buffer];
+		memset(buffer, 0, size_buffer);
+
+		va_start(args, fmt);
+		size_out = vsnprintf(buffer, size_buffer, fmt, args);
+		va_end(args);
+
+		// see http://perfec.to/vsnprintf/pasprintf.c
+		// if size_out ...
+		//      == -1             --> output was truncated
+		//      == size_buffer    --> output was truncated
+		//      == size_buffer-1  --> ambiguous, /may/ have been truncated
+		//       > size_buffer    --> output was truncated, and size_out
+		//                            bytes would have been written
+		if (size_out == size_buffer || size_out == -1 || size_out == size_buffer-1)
+			size_buffer *= 2;
+		else if (size_out > size_buffer)
+			size_buffer = size_out + 2; // to avoid the ambiguous case
+		else
+			break;
+
+		delete[] buffer;
+	}
+	message = std::string(buffer);
+	delete[] buffer;
+}
+
+}

src/common/Exception.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_EXCEPTION_H
-#define LOVE_EXCEPTION_H
-
-#include <exception>
-#include <cstdarg> // vararg
-#include <cstdio> // vsnprintf
-#include <cstring> // strncpy
-#include <string>
-
-namespace love
-{
-
-/**
- * A convenient vararg-enabled exception class.
- **/
-class Exception : public std::exception
-{
-public:
-
-	/**
-	 * Creates a new Exception according to printf-rules.
-	 *
-	 * See: http://www.cplusplus.com/reference/clibrary/cstdio/printf/
-	 *
-	 * @param fmt The format string (see printf).
-	 **/
-	Exception(const char *fmt, ...);
-	virtual ~Exception() throw() {}
-
-	/**
-	 * Returns a string containing reason for the exception.
-	 * @return A description of the exception.
-	 **/
-	inline virtual const char *what() const throw()
-	{
-		return message.c_str();
-	}
-
-private:
-
-	std::string message;
-
-}; // Exception
-
-} // love
-
-#endif // LOVE_EXCEPTION_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_EXCEPTION_H
+#define LOVE_EXCEPTION_H
+
+#include <exception>
+#include <cstdarg> // vararg
+#include <cstdio> // vsnprintf
+#include <cstring> // strncpy
+#include <string>
+
+namespace love
+{
+
+/**
+ * A convenient vararg-enabled exception class.
+ **/
+class Exception : public std::exception
+{
+public:
+
+	/**
+	 * Creates a new Exception according to printf-rules.
+	 *
+	 * See: http://www.cplusplus.com/reference/clibrary/cstdio/printf/
+	 *
+	 * @param fmt The format string (see printf).
+	 **/
+	Exception(const char *fmt, ...);
+	virtual ~Exception() throw() {}
+
+	/**
+	 * Returns a string containing reason for the exception.
+	 * @return A description of the exception.
+	 **/
+	inline virtual const char *what() const throw()
+	{
+		return message.c_str();
+	}
+
+private:
+
+	std::string message;
+
+}; // Exception
+
+} // love
+
+#endif // LOVE_EXCEPTION_H

src/common/Matrix.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 "Matrix.h"
-
-// STD
-#include <cstring> // memcpy
-#include <cmath>
-
-namespace love
-{
-
-// | e0 e4 e8  e12 |
-// | e1 e5 e9  e13 |
-// | e2 e6 e10 e14 |
-// | e3 e7 e11 e15 |
-
-Matrix::Matrix()
-{
-	setIdentity();
-}
-
-Matrix::~Matrix()
-{
-}
-
-//                 | e0 e4 e8  e12 |
-//                 | e1 e5 e9  e13 |
-//                 | e2 e6 e10 e14 |
-//                 | e3 e7 e11 e15 |
-// | e0 e4 e8  e12 |
-// | e1 e5 e9  e13 |
-// | e2 e6 e10 e14 |
-// | e3 e7 e11 e15 |
-
-Matrix Matrix::operator * (const Matrix &m) const
-{
-	Matrix t;
-
-	t.e[0] = (e[0]*m.e[0]) + (e[4]*m.e[1]) + (e[8]*m.e[2]) + (e[12]*m.e[3]);
-	t.e[4] = (e[0]*m.e[4]) + (e[4]*m.e[5]) + (e[8]*m.e[6]) + (e[12]*m.e[7]);
-	t.e[8] = (e[0]*m.e[8]) + (e[4]*m.e[9]) + (e[8]*m.e[10]) + (e[12]*m.e[11]);
-	t.e[12] = (e[0]*m.e[12]) + (e[4]*m.e[13]) + (e[8]*m.e[14]) + (e[12]*m.e[15]);
-
-	t.e[1] = (e[1]*m.e[0]) + (e[5]*m.e[1]) + (e[9]*m.e[2]) + (e[13]*m.e[3]);
-	t.e[5] = (e[1]*m.e[4]) + (e[5]*m.e[5]) + (e[9]*m.e[6]) + (e[13]*m.e[7]);
-	t.e[9] = (e[1]*m.e[8]) + (e[5]*m.e[9]) + (e[9]*m.e[10]) + (e[13]*m.e[11]);
-	t.e[13] = (e[1]*m.e[12]) + (e[5]*m.e[13]) + (e[9]*m.e[14]) + (e[13]*m.e[15]);
-
-	t.e[2] = (e[2]*m.e[0]) + (e[6]*m.e[1]) + (e[10]*m.e[2]) + (e[14]*m.e[3]);
-	t.e[6] = (e[2]*m.e[4]) + (e[6]*m.e[5]) + (e[10]*m.e[6]) + (e[14]*m.e[7]);
-	t.e[10] = (e[2]*m.e[8]) + (e[6]*m.e[9]) + (e[10]*m.e[10]) + (e[14]*m.e[11]);
-	t.e[14] = (e[2]*m.e[12]) + (e[6]*m.e[13]) + (e[10]*m.e[14]) + (e[14]*m.e[15]);
-
-	t.e[3] = (e[3]*m.e[0]) + (e[7]*m.e[1]) + (e[11]*m.e[2]) + (e[15]*m.e[3]);
-	t.e[7] = (e[3]*m.e[4]) + (e[7]*m.e[5]) + (e[11]*m.e[6]) + (e[15]*m.e[7]);
-	t.e[11] = (e[3]*m.e[8]) + (e[7]*m.e[9]) + (e[11]*m.e[10]) + (e[15]*m.e[11]);
-	t.e[15] = (e[3]*m.e[12]) + (e[7]*m.e[13]) + (e[11]*m.e[14]) + (e[15]*m.e[15]);
-
-	return t;
-}
-
-void Matrix::operator *= (const Matrix &m)
-{
-	Matrix t = (*this) * m;
-	memcpy((void *)this->e, (void *)t.e, sizeof(float)*16);
-}
-
-const float *Matrix::getElements() const
-{
-	return e;
-}
-
-void Matrix::setIdentity()
-{
-	memset(e, 0, sizeof(float)*16);
-	e[0] = e[5] = e[10] = e[15] = 1;
-}
-
-void Matrix::setTranslation(float x, float y)
-{
-	setIdentity();
-	e[12] = x;
-	e[13] = y;
-}
-
-void Matrix::setRotation(float rad)
-{
-	setIdentity();
-	float c = cos(rad), s = sin(rad);
-	e[0] = c;
-	e[4] = -s;
-	e[1] = s;
-	e[5] = c;
-}
-
-void Matrix::setScale(float sx, float sy)
-{
-	setIdentity();
-	e[0] = sx;
-	e[5] = sy;
-}
-
-void Matrix::setShear(float kx, float ky)
-{
-	setIdentity();
-	e[1] = ky;
-	e[4] = kx;
-}
-
-void Matrix::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
-{
-	memset(e, 0, sizeof(float)*16); // zero out matrix
-	float c = cos(angle), s = sin(angle);
-	// matrix multiplication carried out on paper:
-	// |1     x| |c -s    | |sx       | | 1 ky    | |1     -ox|
-	// |  1   y| |s  c    | |   sy    | |kx  1    | |  1   -oy|
-	// |    1  | |     1  | |      1  | |      1  | |    1    |
-	// |      1| |       1| |        1| |        1| |       1 |
-	//   move      rotate      scale       skew       origin
-	e[10] = e[15] = 1.0f;
-	e[0]  = c * sx - ky * s * sy; // = a
-	e[1]  = s * sx + ky * c * sy; // = b
-	e[4]  = kx * c * sx - s * sy; // = c
-	e[5]  = kx * s * sx + c * sy; // = d
-	e[12] = x - ox * e[0] - oy * e[4];
-	e[13] = y - ox * e[1] - oy * e[5];
-}
-
-void Matrix::translate(float x, float y)
-{
-	Matrix t;
-	t.setTranslation(x, y);
-	this->operator *=(t);
-}
-
-void Matrix::rotate(float rad)
-{
-	Matrix t;
-	t.setRotation(rad);
-	this->operator *=(t);
-}
-
-void Matrix::scale(float sx, float sy)
-{
-	Matrix t;
-	t.setScale(sx, sy);
-	this->operator *=(t);
-}
-
-void Matrix::shear(float kx, float ky)
-{
-	Matrix t;
-	t.setShear(kx,ky);
-	this->operator *=(t);
-}
-
-//                 | x |
-//                 | y |
-//                 | 0 |
-//                 | 1 |
-// | e0 e4 e8  e12 |
-// | e1 e5 e9  e13 |
-// | e2 e6 e10 e14 |
-// | e3 e7 e11 e15 |
-
-void Matrix::transform(vertex *dst, const vertex *src, int size) const
-{
-	for (int i = 0; i<size; i++)
-	{
-		// Store in temp variables in case src = dst
-		float x = (e[0]*src[i].x) + (e[4]*src[i].y) + (0) + (e[12]);
-		float y = (e[1]*src[i].x) + (e[5]*src[i].y) + (0) + (e[13]);
-
-		dst[i].x = x;
-		dst[i].y = y;
-	}
-}
-
-
-} // love
+/**
+ * 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 "Matrix.h"
+
+// STD
+#include <cstring> // memcpy
+#include <cmath>
+
+namespace love
+{
+
+// | e0 e4 e8  e12 |
+// | e1 e5 e9  e13 |
+// | e2 e6 e10 e14 |
+// | e3 e7 e11 e15 |
+
+Matrix::Matrix()
+{
+	setIdentity();
+}
+
+Matrix::~Matrix()
+{
+}
+
+//                 | e0 e4 e8  e12 |
+//                 | e1 e5 e9  e13 |
+//                 | e2 e6 e10 e14 |
+//                 | e3 e7 e11 e15 |
+// | e0 e4 e8  e12 |
+// | e1 e5 e9  e13 |
+// | e2 e6 e10 e14 |
+// | e3 e7 e11 e15 |
+
+Matrix Matrix::operator * (const Matrix &m) const
+{
+	Matrix t;
+
+	t.e[0] = (e[0]*m.e[0]) + (e[4]*m.e[1]) + (e[8]*m.e[2]) + (e[12]*m.e[3]);
+	t.e[4] = (e[0]*m.e[4]) + (e[4]*m.e[5]) + (e[8]*m.e[6]) + (e[12]*m.e[7]);
+	t.e[8] = (e[0]*m.e[8]) + (e[4]*m.e[9]) + (e[8]*m.e[10]) + (e[12]*m.e[11]);
+	t.e[12] = (e[0]*m.e[12]) + (e[4]*m.e[13]) + (e[8]*m.e[14]) + (e[12]*m.e[15]);
+
+	t.e[1] = (e[1]*m.e[0]) + (e[5]*m.e[1]) + (e[9]*m.e[2]) + (e[13]*m.e[3]);
+	t.e[5] = (e[1]*m.e[4]) + (e[5]*m.e[5]) + (e[9]*m.e[6]) + (e[13]*m.e[7]);
+	t.e[9] = (e[1]*m.e[8]) + (e[5]*m.e[9]) + (e[9]*m.e[10]) + (e[13]*m.e[11]);
+	t.e[13] = (e[1]*m.e[12]) + (e[5]*m.e[13]) + (e[9]*m.e[14]) + (e[13]*m.e[15]);
+
+	t.e[2] = (e[2]*m.e[0]) + (e[6]*m.e[1]) + (e[10]*m.e[2]) + (e[14]*m.e[3]);
+	t.e[6] = (e[2]*m.e[4]) + (e[6]*m.e[5]) + (e[10]*m.e[6]) + (e[14]*m.e[7]);
+	t.e[10] = (e[2]*m.e[8]) + (e[6]*m.e[9]) + (e[10]*m.e[10]) + (e[14]*m.e[11]);
+	t.e[14] = (e[2]*m.e[12]) + (e[6]*m.e[13]) + (e[10]*m.e[14]) + (e[14]*m.e[15]);
+
+	t.e[3] = (e[3]*m.e[0]) + (e[7]*m.e[1]) + (e[11]*m.e[2]) + (e[15]*m.e[3]);
+	t.e[7] = (e[3]*m.e[4]) + (e[7]*m.e[5]) + (e[11]*m.e[6]) + (e[15]*m.e[7]);
+	t.e[11] = (e[3]*m.e[8]) + (e[7]*m.e[9]) + (e[11]*m.e[10]) + (e[15]*m.e[11]);
+	t.e[15] = (e[3]*m.e[12]) + (e[7]*m.e[13]) + (e[11]*m.e[14]) + (e[15]*m.e[15]);
+
+	return t;
+}
+
+void Matrix::operator *= (const Matrix &m)
+{
+	Matrix t = (*this) * m;
+	memcpy((void *)this->e, (void *)t.e, sizeof(float)*16);
+}
+
+const float *Matrix::getElements() const
+{
+	return e;
+}
+
+void Matrix::setIdentity()
+{
+	memset(e, 0, sizeof(float)*16);
+	e[0] = e[5] = e[10] = e[15] = 1;
+}
+
+void Matrix::setTranslation(float x, float y)
+{
+	setIdentity();
+	e[12] = x;
+	e[13] = y;
+}
+
+void Matrix::setRotation(float rad)
+{
+	setIdentity();
+	float c = cos(rad), s = sin(rad);
+	e[0] = c;
+	e[4] = -s;
+	e[1] = s;
+	e[5] = c;
+}
+
+void Matrix::setScale(float sx, float sy)
+{
+	setIdentity();
+	e[0] = sx;
+	e[5] = sy;
+}
+
+void Matrix::setShear(float kx, float ky)
+{
+	setIdentity();
+	e[1] = ky;
+	e[4] = kx;
+}
+
+void Matrix::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+{
+	memset(e, 0, sizeof(float)*16); // zero out matrix
+	float c = cos(angle), s = sin(angle);
+	// matrix multiplication carried out on paper:
+	// |1     x| |c -s    | |sx       | | 1 ky    | |1     -ox|
+	// |  1   y| |s  c    | |   sy    | |kx  1    | |  1   -oy|
+	// |    1  | |     1  | |      1  | |      1  | |    1    |
+	// |      1| |       1| |        1| |        1| |       1 |
+	//   move      rotate      scale       skew       origin
+	e[10] = e[15] = 1.0f;
+	e[0]  = c * sx - ky * s * sy; // = a
+	e[1]  = s * sx + ky * c * sy; // = b
+	e[4]  = kx * c * sx - s * sy; // = c
+	e[5]  = kx * s * sx + c * sy; // = d
+	e[12] = x - ox * e[0] - oy * e[4];
+	e[13] = y - ox * e[1] - oy * e[5];
+}
+
+void Matrix::translate(float x, float y)
+{
+	Matrix t;
+	t.setTranslation(x, y);
+	this->operator *=(t);
+}
+
+void Matrix::rotate(float rad)
+{
+	Matrix t;
+	t.setRotation(rad);
+	this->operator *=(t);
+}
+
+void Matrix::scale(float sx, float sy)
+{
+	Matrix t;
+	t.setScale(sx, sy);
+	this->operator *=(t);
+}
+
+void Matrix::shear(float kx, float ky)
+{
+	Matrix t;
+	t.setShear(kx,ky);
+	this->operator *=(t);
+}
+
+//                 | x |
+//                 | y |
+//                 | 0 |
+//                 | 1 |
+// | e0 e4 e8  e12 |
+// | e1 e5 e9  e13 |
+// | e2 e6 e10 e14 |
+// | e3 e7 e11 e15 |
+
+void Matrix::transform(vertex *dst, const vertex *src, int size) const
+{
+	for (int i = 0; i<size; i++)
+	{
+		// Store in temp variables in case src = dst
+		float x = (e[0]*src[i].x) + (e[4]*src[i].y) + (0) + (e[12]);
+		float y = (e[1]*src[i].x) + (e[5]*src[i].y) + (0) + (e[13]);
+
+		dst[i].x = x;
+		dst[i].y = y;
+	}
+}
+
+
+} // love

src/common/Matrix.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_MATRIX_H
-#define LOVE_MATRIX_H
-
-// LOVE
-#include "math.h"
-
-namespace love
-{
-
-/**
- * This class is the basis for all transformations in LOVE. Althought not
- * really needed for 2D, it contains 4x4 elements to be compatible with
- * OpenGL without conversions.
- **/
-class Matrix
-{
-public:
-
-	/**
-	 * Creates a new identity matrix.
-	 **/
-	Matrix();
-
-	/**
-	 * Destructor.
-	 **/
-	~Matrix();
-
-	/**
-	 * Multiplies this Matrix with another Matrix, changing neither.
-	 * @param m The Matrix to multiply with this Matrix.
-	 * @return The combined matrix.
-	 **/
-	Matrix operator * (const Matrix &m) const;
-
-	/**
-	 * Multiplies a Matrix into this Matrix.
-	 * @param m The Matrix to combine into this Matrix.
-	 **/
-	void operator *= (const Matrix &m);
-
-	/**
-	 * Gets a pointer to the 16 array elements.
-	 * @return The array elements.
-	 **/
-	const float *getElements() const;
-
-	/**
-	 * Resets this Matrix to the identity matrix.
-	 **/
-	void setIdentity();
-
-	/**
-	 * Resets this Matrix to a translation.
-	 * @param x Translation along x-axis.
-	 * @param y Translation along y-axis.
-	 **/
-	void setTranslation(float x, float y);
-
-	/**
-	 * Resets this Matrix to a rotation.
-	 * @param r The angle in radians.
-	 **/
-	void setRotation(float r);
-
-	/**
-	 * Resets this Matrix to a scale transformation.
-	 * @param sx Scale factor along the x-axis.
-	 * @param sy Scale factor along the y-axis.
-	 **/
-	void setScale(float sx, float sy);
-
-	/**
-	 * Resets this Matrix to a shear transformation.
-	 * @param kx Shear along x-axis.
-	 * @param ky Shear along y-axis.
-	 **/
-	void setShear(float kx, float ky);
-
-	/**
-	 * Creates a transformation with a certain position, orientation, scale
-	 * and offset. Perfect for Drawables -- what a coincidence!
-	 *
-	 * @param x The translation along the x-axis.
-	 * @param y The translation along the y-axis.
-	 * @param angle The rotation (rad) around the center with offset (ox,oy).
-	 * @param sx Scale along x-axis.
-	 * @param sy Scale along y-axis.
-	 * @param ox The offset for rotation along the x-axis.
-	 * @param oy The offset for rotation along the y-axis.
-	 * @param kx Shear along x-axis
-	 * @param ky Shear along y-axis
-	 **/
-	void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
-
-	/**
-	 * Multiplies this Matrix with a translation.
-	 * @param x Translation along x-axis.
-	 * @param y Translation along y-axis.
-	 **/
-	void translate(float x, float y);
-
-	/**
-	 * Multiplies this Matrix with a rotation.
-	 * @param r Angle in radians.
-	 **/
-	void rotate(float r);
-
-	/**
-	 * Multiplies this Matrix with a scale transformation.
-	 * @param sx Scale factor along the x-axis.
-	 * @param sy Scale factor along the y-axis.
-	 **/
-	void scale(float sx, float sy);
-
-	/**
-	 * Multiplies this Matrix with a shear transformation.
-	 * @param kx Shear along the x-axis.
-	 * @param ky Shear along the y-axis.
-	 **/
-	void shear(float kx, float ky);
-
-	/**
-	 * Transforms an array of vertices by this Matrix. The sources and
-	 * destination arrays may be the same.
-	 *
-	 * @param dst Storage for the transformed vertices.
-	 * @param src The source vertices.
-	 * @param size The number of vertices.
-	 **/
-	void transform(vertex *dst, const vertex *src, int size) const;
-
-private:
-
-	/**
-	 * | e0 e4 e8  e12 |
-	 * | e1 e5 e9  e13 |
-	 * | e2 e6 e10 e14 |
-	 * | e3 e7 e11 e15 |
-	 **/
-	float e[16];
-
-}; // Matrix
-
-} //love
-
-#endif// LOVE_MATRIX_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_MATRIX_H
+#define LOVE_MATRIX_H
+
+// LOVE
+#include "math.h"
+
+namespace love
+{
+
+/**
+ * This class is the basis for all transformations in LOVE. Althought not
+ * really needed for 2D, it contains 4x4 elements to be compatible with
+ * OpenGL without conversions.
+ **/
+class Matrix
+{
+public:
+
+	/**
+	 * Creates a new identity matrix.
+	 **/
+	Matrix();
+
+	/**
+	 * Destructor.
+	 **/
+	~Matrix();
+
+	/**
+	 * Multiplies this Matrix with another Matrix, changing neither.
+	 * @param m The Matrix to multiply with this Matrix.
+	 * @return The combined matrix.
+	 **/
+	Matrix operator * (const Matrix &m) const;
+
+	/**
+	 * Multiplies a Matrix into this Matrix.
+	 * @param m The Matrix to combine into this Matrix.
+	 **/
+	void operator *= (const Matrix &m);
+
+	/**
+	 * Gets a pointer to the 16 array elements.
+	 * @return The array elements.
+	 **/
+	const float *getElements() const;
+
+	/**
+	 * Resets this Matrix to the identity matrix.
+	 **/
+	void setIdentity();
+
+	/**
+	 * Resets this Matrix to a translation.
+	 * @param x Translation along x-axis.
+	 * @param y Translation along y-axis.
+	 **/
+	void setTranslation(float x, float y);
+
+	/**
+	 * Resets this Matrix to a rotation.
+	 * @param r The angle in radians.
+	 **/
+	void setRotation(float r);
+
+	/**
+	 * Resets this Matrix to a scale transformation.
+	 * @param sx Scale factor along the x-axis.
+	 * @param sy Scale factor along the y-axis.
+	 **/
+	void setScale(float sx, float sy);
+
+	/**
+	 * Resets this Matrix to a shear transformation.
+	 * @param kx Shear along x-axis.
+	 * @param ky Shear along y-axis.
+	 **/
+	void setShear(float kx, float ky);
+
+	/**
+	 * Creates a transformation with a certain position, orientation, scale
+	 * and offset. Perfect for Drawables -- what a coincidence!
+	 *
+	 * @param x The translation along the x-axis.
+	 * @param y The translation along the y-axis.
+	 * @param angle The rotation (rad) around the center with offset (ox,oy).
+	 * @param sx Scale along x-axis.
+	 * @param sy Scale along y-axis.
+	 * @param ox The offset for rotation along the x-axis.
+	 * @param oy The offset for rotation along the y-axis.
+	 * @param kx Shear along x-axis
+	 * @param ky Shear along y-axis
+	 **/
+	void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+
+	/**
+	 * Multiplies this Matrix with a translation.
+	 * @param x Translation along x-axis.
+	 * @param y Translation along y-axis.
+	 **/
+	void translate(float x, float y);
+
+	/**
+	 * Multiplies this Matrix with a rotation.
+	 * @param r Angle in radians.
+	 **/
+	void rotate(float r);
+
+	/**
+	 * Multiplies this Matrix with a scale transformation.
+	 * @param sx Scale factor along the x-axis.
+	 * @param sy Scale factor along the y-axis.
+	 **/
+	void scale(float sx, float sy);
+
+	/**
+	 * Multiplies this Matrix with a shear transformation.
+	 * @param kx Shear along the x-axis.
+	 * @param ky Shear along the y-axis.
+	 **/
+	void shear(float kx, float ky);
+
+	/**
+	 * Transforms an array of vertices by this Matrix. The sources and
+	 * destination arrays may be the same.
+	 *
+	 * @param dst Storage for the transformed vertices.
+	 * @param src The source vertices.
+	 * @param size The number of vertices.
+	 **/
+	void transform(vertex *dst, const vertex *src, int size) const;
+
+private:
+
+	/**
+	 * | e0 e4 e8  e12 |
+	 * | e1 e5 e9  e13 |
+	 * | e2 e6 e10 e14 |
+	 * | e3 e7 e11 e15 |
+	 **/
+	float e[16];
+
+}; // Matrix
+
+} //love
+
+#endif// LOVE_MATRIX_H

src/common/Memoizer.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 "Memoizer.h"
-#include <cstddef>
-
-namespace love
-{
-
-std::map<void *, void *> Memoizer::objectMap;
-
-void Memoizer::add(void *key, void *val)
-{
-	objectMap[key] = val;
-}
-
-void Memoizer::remove(void *key)
-{
-	objectMap.erase(key);
-}
-
-void *Memoizer::find(void *key)
-{
-	if (objectMap.count(key)) return objectMap[key];
-	return NULL;
-}
-
-} // love
+/**
+ * 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 "Memoizer.h"
+#include <cstddef>
+
+namespace love
+{
+
+std::map<void *, void *> Memoizer::objectMap;
+
+void Memoizer::add(void *key, void *val)
+{
+	objectMap[key] = val;
+}
+
+void Memoizer::remove(void *key)
+{
+	objectMap.erase(key);
+}
+
+void *Memoizer::find(void *key)
+{
+	if (objectMap.count(key)) return objectMap[key];
+	return NULL;
+}
+
+} // love

src/common/Memoizer.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_MEMOIZER_H
-#define LOVE_MEMOIZER_H
-
-#include <map>
-
-namespace love
-{
-
-class Memoizer
-{
-public:
-
-	static void add(void *key, void *val);
-
-	static void remove(void *key);
-
-	static void *find(void *key);
-
-private:
-
-	static std::map<void *, void *> objectMap;
-}; // Memoizer
-
-} // love
-
-#endif // LOVE_MEMOIZER_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_MEMOIZER_H
+#define LOVE_MEMOIZER_H
+
+#include <map>
+
+namespace love
+{
+
+class Memoizer
+{
+public:
+
+	static void add(void *key, void *val);
+
+	static void remove(void *key);
+
+	static void *find(void *key);
+
+private:
+
+	static std::map<void *, void *> objectMap;
+}; // Memoizer
+
+} // love
+
+#endif // LOVE_MEMOIZER_H

src/common/Module.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_MODULE_H
-#define LOVE_MODULE_H
-
-// LOVE
-#include "runtime.h"
-#include "Exception.h"
-#include "Object.h"
-
-namespace love
-{
-/**
- * Abstract superclass for all modules.
- **/
-class Module : public Object
-{
-public:
-
-	/**
-	 * Destructor.
-	 **/
-	virtual ~Module() {};
-
-	/**
-	 * Gets the name of the module. This is used in case of errors
-	 * and other messages.
-	 *
-	 * @return The full name of the module, eg. love.graphics.opengl.
-	 **/
-	virtual const char *getName() const = 0;
-
-}; // Module
-
-} // love
-
-#endif // LOVE_MODULE_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_MODULE_H
+#define LOVE_MODULE_H
+
+// LOVE
+#include "runtime.h"
+#include "Exception.h"
+#include "Object.h"
+
+namespace love
+{
+/**
+ * Abstract superclass for all modules.
+ **/
+class Module : public Object
+{
+public:
+
+	/**
+	 * Destructor.
+	 **/
+	virtual ~Module() {};
+
+	/**
+	 * Gets the name of the module. This is used in case of errors
+	 * and other messages.
+	 *
+	 * @return The full name of the module, eg. love.graphics.opengl.
+	 **/
+	virtual const char *getName() const = 0;
+
+}; // Module
+
+} // love
+
+#endif // LOVE_MODULE_H

src/common/Object.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:
- *