Browse Source

Merged default into Mesh

--HG--
branch : Mesh
Alex Szpakowski 12 years ago
parent
commit
c63e2ec624

+ 2 - 0
platform/macosx/love-framework.xcodeproj/project.pbxproj

@@ -2268,6 +2268,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
 				CLANG_ENABLE_MODULES = YES;
 				DEAD_CODE_STRIPPING = YES;
 				FRAMEWORK_SEARCH_PATHS = /Library/Frameworks;
@@ -2303,6 +2304,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
 				CLANG_ENABLE_MODULES = YES;
 				COPY_PHASE_STRIP = NO;
 				FRAMEWORK_SEARCH_PATHS = /Library/Frameworks;

+ 2 - 0
platform/macosx/love.xcodeproj/project.pbxproj

@@ -302,6 +302,7 @@
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
 				CLANG_ENABLE_MODULES = YES;
 				FRAMEWORK_SEARCH_PATHS = /Library/Frameworks;
 				GCC_INCREASE_PRECOMPILED_HEADER_SHARING = YES;
@@ -353,6 +354,7 @@
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
 				CLANG_ENABLE_MODULES = YES;
 				DEPLOYMENT_POSTPROCESSING = NO;
 				FRAMEWORK_SEARCH_PATHS = /Library/Frameworks;

+ 0 - 8
platform/macosx/loveProj.xcconfig

@@ -1,8 +0,0 @@
-	GCC_ENABLE_CPP_EXCEPTIONS = YES;
-	GCC_ENABLE_CPP_RTTI = YES;
-	GCC_WARN_ABOUT_RETURN_TYPE = YES;
-	GCC_WARN_UNUSED_VARIABLE = YES;
-	GCC_INCREASE_PRECOMPILED_HEADER_SHARING = YES;
-	GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
-	PREBINDING = NO;
-	INFOPLIST_EXPAND_BUILD_SETTINGS = YES;

+ 0 - 7
platform/macosx/loveTarget.xcconfig

@@ -1,7 +0,0 @@
-	GCC_PRECOMPILE_PREFIX_HEADER = YES;
-	GCC_PREFIX_HEADER = love_Prefix.pch;
-	INFOPLIST_FILE = Info.plist;
-	INSTALL_PATH = $(HOME)/Applications;
-	PRODUCT_NAME = 	love;
-	STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = Dynamic;
-	GCC_SYMBOLS_PRIVATE_EXTERN = NO;

+ 0 - 28
platform/macosx/script.sh

@@ -1,28 +0,0 @@
-#! /bin/sh
-#Use install_name_tool, make love to search libs in its own framework folder instead
-#*very* hackish.
-#IL
-install_name_tool -change /usr/local/lib/libIL.dylib @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love
-
-install_name_tool -change /usr/local/lib/libILU.dylib @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love
-
-install_name_tool -change /usr/local/lib/libILUT.dylib @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love
-
-install_name_tool -change /usr/local/lib/libIL.1.dylib @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love
-
-install_name_tool -change /usr/local/lib/libILU.1.dylib @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love
-
-install_name_tool -change /usr/local/lib/libILUT.1.dylib @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love
-
-# FreeType
-install_name_tool -change /Library/Frameworks/FreeType.framework/Versions/2.3/FreeType @executable_path/../Frameworks/FreeType.framework/Versions/2.3/FreeType build/Release/love.app/Contents/MacOS/love
-
-# SDL
-install_name_tool -change /Library/Frameworks/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL build/Release/love.app/Contents/MacOS/love
-
-install_name_tool -change /Library/Frameworks/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL build/Release/love.app/Contents/Frameworks/SDL_mixer.framework/SDL_mixer
-
-# SDL_mixer
-#install_name_tool -change /Library/Frameworks/SDL_mixer.framework/Versions/A/SDL_mixer @executable_path/../#Frameworks/SDL_mixer.framework/Versions/A/SDL_mixer build/Release/love.app/Contents/MacOS/love
-
-exit 0

+ 39 - 10
src/common/Module.cpp

@@ -29,7 +29,30 @@
 
 namespace
 {
-	std::map<std::string, love::Module*> registry;
+	typedef std::map<std::string, love::Module*> ModuleRegistry;
+
+	// The registry must be dynamically managed, because some modules
+	// (the math module) are static globals that are not guaranteed to
+	// be destroyed before other static globals.
+	ModuleRegistry *registry = nullptr;
+
+	ModuleRegistry &registryInstance()
+	{
+		if (!registry)
+			registry = new ModuleRegistry;
+
+		return *registry;
+	}
+
+	void freeEmptyRegistry()
+	{
+		if (registry && registry->empty())
+		{
+			delete registry;
+			registry = nullptr;
+		}
+	}
+
 } // anonymous namespace
 
 namespace love
@@ -37,10 +60,10 @@ namespace love
 
 Module::~Module()
 {
-	std::map<std::string, Module*>::iterator it;
+	ModuleRegistry &registry = registryInstance();
 
 	// We can't use the overridden Module::getName() in this destructor.
-	for (it = registry.begin(); it != registry.end(); ++it)
+	for (auto it = registry.begin(); it != registry.end(); ++it)
 	{
 		if (it->second == this)
 		{
@@ -48,16 +71,20 @@ Module::~Module()
 			break;
 		}
 	}
+
+	freeEmptyRegistry();
 }
 
 void Module::registerInstance(Module *instance)
 {
-	if (instance == NULL)
+	if (instance == nullptr)
 		throw Exception("Module instance is NULL");
 
 	std::string name(instance->getName());
 
-	std::map<std::string, Module*>::iterator it = registry.find(name);
+	ModuleRegistry &registry = registryInstance();
+
+	auto it = registry.find(name);
 
 	if (it != registry.end())
 	{
@@ -71,25 +98,27 @@ void Module::registerInstance(Module *instance)
 
 Module *Module::getInstance(const std::string &name)
 {
-	std::map<std::string, Module*>::const_iterator it = registry.find(name);
+	ModuleRegistry &registry = registryInstance();
+
+	auto it = registry.find(name);
 
 	if (registry.end() == it)
-		return NULL;
+		return nullptr;
 
 	return it->second;
 }
 
 Module *Module::findInstance(const std::string &name)
 {
-	std::map<std::string, Module*>::const_iterator it;
+	ModuleRegistry &registry = registryInstance();
 
-	for (it = registry.begin(); it != registry.end(); ++it)
+	for (auto it = registry.begin(); it != registry.end(); ++it)
 	{
 		if (it->first.find(name) == 0)
 			return it->second;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 } // love

+ 1 - 1
src/common/Variant.cpp

@@ -26,7 +26,7 @@ namespace love
 
 extern StringMap<Type, TYPE_MAX_ENUM> types;
 
-love::Type extractudatatype(lua_State *L, int idx)
+static love::Type extractudatatype(lua_State *L, int idx)
 {
 	Type t = INVALID_ID;
 	if (!lua_isuserdata(L, idx))

+ 1 - 11
src/common/runtime.cpp

@@ -168,7 +168,7 @@ int luax_intflag(lua_State *L, int table_index, const char *key, int defaultValu
 	if (!lua_isnumber(L, -1))
 		retval = defaultValue;
 	else
-		retval = lua_tonumber(L, -1);
+		retval = (int) lua_tointeger(L, -1);
 
 	lua_pop(L, 1);
 	return retval;
@@ -533,16 +533,6 @@ int luax_pconvobj(lua_State *L, int idxs[], int n, const char *mod, const char *
 	return ret;
 }
 
-int luax_strtofile(lua_State *L, int idx)
-{
-	return luax_convobj(L, idx, "filesystem", "newFile");
-}
-
-int luax_filetodata(lua_State *L, int idx)
-{
-	return luax_convobj(L, idx, "filesystem", "read");
-}
-
 int luax_insist(lua_State *L, int idx, const char *k)
 {
 	// Convert to absolute index if necessary.

+ 5 - 5
src/modules/graphics/opengl/Font.cpp

@@ -215,10 +215,10 @@ Font::Glyph *Font::addGlyph(uint32 glyph)
 		g->texture = t;
 
 		const GlyphVertex verts[4] = {
-			{0, 0, float(textureX)/float(textureWidth),   float(textureY)/float(textureHeight)},
-			{w, 0, float(textureX+w)/float(textureWidth), float(textureY)/float(textureHeight)},
-			{w, h, float(textureX+w)/float(textureWidth), float(textureY+h)/float(textureHeight)},
-			{0, h, float(textureX)/float(textureWidth),   float(textureY+h)/float(textureHeight)},
+			{    0.0f,     0.0f, float(textureX)/float(textureWidth),   float(textureY)/float(textureHeight)},
+			{float(w),     0.0f, float(textureX+w)/float(textureWidth), float(textureY)/float(textureHeight)},
+			{float(w), float(h), float(textureX+w)/float(textureWidth), float(textureY+h)/float(textureHeight)},
+			{    0.0f, float(h), float(textureX)/float(textureWidth),   float(textureY+h)/float(textureHeight)},
 		};
 
 		// copy vertex data to the glyph and set proper bearing
@@ -550,7 +550,7 @@ int Font::getDescent() const
 float Font::getBaseline() const
 {
 	// 1.25 is magic line height for true type fonts
-	return (type == FONT_TRUETYPE) ? floor(getHeight() / 1.25f + 0.5f) : 0.0f;
+	return (type == FONT_TRUETYPE) ? floorf(getHeight() / 1.25f + 0.5f) : 0.0f;
 }
 
 bool Font::hasGlyph(uint32 glyph) const

+ 8 - 24
src/modules/graphics/opengl/Graphics.cpp

@@ -242,22 +242,6 @@ int Graphics::getHeight() const
 	return height;
 }
 
-int Graphics::getRenderWidth() const
-{
-	if (Canvas::current)
-		return Canvas::current->getWidth();
-
-	return getWidth();
-}
-
-int Graphics::getRenderHeight() const
-{
-	if (Canvas::current)
-		return Canvas::current->getHeight();
-
-	return getHeight();
-}
-
 bool Graphics::isCreated() const
 {
 	return created;
@@ -741,7 +725,7 @@ void Graphics::printf(const std::string &str, float x, float y, float wrap, Alig
 	glPushMatrix();
 
 	static Matrix t;
-	t.setTransformation(ceil(x), ceil(y), angle, sx, sy, ox, oy, kx, ky);
+	t.setTransformation(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
 	glMultMatrixf((const GLfloat *)t.getElements());
 
 	x = y = 0.0f;
@@ -760,10 +744,10 @@ void Graphics::printf(const std::string &str, float x, float y, float wrap, Alig
 			switch (align)
 			{
 			case ALIGN_RIGHT:
-				currentFont->print(*line_iter, ceil(x + (wrap - width)), ceil(y), 0.0f);
+				currentFont->print(*line_iter, ceilf(x + (wrap - width)), ceilf(y), 0.0f);
 				break;
 			case ALIGN_CENTER:
-				currentFont->print(*line_iter, ceil(x + (wrap - width) / 2), ceil(y), 0.0f);
+				currentFont->print(*line_iter, ceilf(x + (wrap - width) / 2), ceilf(y), 0.0f);
 				break;
 			case ALIGN_JUSTIFY:
 				num_spaces = std::count(line_iter->begin(), line_iter->end(), ' ');
@@ -771,11 +755,11 @@ void Graphics::printf(const std::string &str, float x, float y, float wrap, Alig
 					extra_spacing = (wrap - width) / float(num_spaces);
 				else
 					extra_spacing = 0.0f;
-				currentFont->print(*line_iter, ceil(x), ceil(y), extra_spacing);
+				currentFont->print(*line_iter, ceilf(x), ceilf(y), extra_spacing);
 				break;
 			case ALIGN_LEFT:
 			default:
-				currentFont->print(*line_iter, ceil(x), ceil(y), 0.0f);
+				currentFont->print(*line_iter, ceilf(x), ceilf(y), 0.0f);
 				break;
 			}
 			y += currentFont->getHeight() * currentFont->getLineHeight();
@@ -808,19 +792,19 @@ void Graphics::polyline(const float *coords, size_t count)
 	if (lineJoin == LINE_JOIN_NONE)
 	{
 			NoneJoinPolyline line;
-			line.render(coords, count, lineWidth * .5f, pixel_size_stack.back(), lineStyle == LINE_SMOOTH);
+			line.render(coords, count, lineWidth * .5f, float(pixel_size_stack.back()), lineStyle == LINE_SMOOTH);
 			line.draw();
 	}
 	else if (lineJoin == LINE_JOIN_BEVEL)
 	{
 		BevelJoinPolyline line;
-		line.render(coords, count, lineWidth * .5f, pixel_size_stack.back(), lineStyle == LINE_SMOOTH);
+		line.render(coords, count, lineWidth * .5f, float(pixel_size_stack.back()), lineStyle == LINE_SMOOTH);
 		line.draw();
 	}
 	else // LINE_JOIN_MITER
 	{
 		MiterJoinPolyline line;
-		line.render(coords, count, lineWidth * .5f, pixel_size_stack.back(), lineStyle == LINE_SMOOTH);
+		line.render(coords, count, lineWidth * .5f, float(pixel_size_stack.back()), lineStyle == LINE_SMOOTH);
 		line.draw();
 	}
 }

+ 0 - 3
src/modules/graphics/opengl/Graphics.h

@@ -456,9 +456,6 @@ public:
 
 private:
 
-	int getRenderWidth() const;
-	int getRenderHeight() const;
-
 	Font *currentFont;
 	love::window::Window *currentWindow;
 

+ 12 - 7
src/modules/graphics/opengl/ParticleSystem.cpp

@@ -233,7 +233,7 @@ void ParticleSystem::initParticle(particle *p)
 	min = speedMin;
 	max = speedMax;
 	float speed = (float) rng.random(min, max);
-	p->speed = love::Vector(cos(p->direction), sin(p->direction));
+	p->speed = love::Vector(cosf(p->direction), sinf(p->direction));
 	p->speed *= speed;
 
 	p->linearAcceleration.x = (float) rng.random(linearAccelerationMin.x, linearAccelerationMax.x);
@@ -652,11 +652,16 @@ void ParticleSystem::setColor(const std::vector<Color> &newColors)
 
 std::vector<Color> ParticleSystem::getColor() const
 {
-	// We store colors as floats...
+	// The particle system stores colors as floats...
 	std::vector<Color> ncolors(colors.size());
 
 	for (size_t i = 0; i < colors.size(); ++i)
-		ncolors[i] = Color(colors[i].r, colors[i].g, colors[i].b, colors[i].a);
+	{
+		ncolors[i].r = (unsigned char) (colors[i].r * 255);
+		ncolors[i].g = (unsigned char) (colors[i].g * 255);
+		ncolors[i].b = (unsigned char) (colors[i].b * 255);
+		ncolors[i].a = (unsigned char) (colors[i].a * 255);
+	}
 
 	return ncolors;
 }
@@ -764,10 +769,10 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
 			pVerts[v].t = imageVerts[v].t;
 
 			// particle colors are stored as floats (0-1) but vertex colors are stored as unsigned bytes (0-255)
-			pVerts[v].r = p->color.r*255;
-			pVerts[v].g = p->color.g*255;
-			pVerts[v].b = p->color.b*255;
-			pVerts[v].a = p->color.a*255;
+			pVerts[v].r = (unsigned char) (p->color.r*255);
+			pVerts[v].g = (unsigned char) (p->color.g*255);
+			pVerts[v].b = (unsigned char) (p->color.b*255);
+			pVerts[v].a = (unsigned char) (p->color.a*255);
 		}
 
 		pVerts += 4;

+ 1 - 1
src/modules/graphics/opengl/Polyline.cpp

@@ -27,7 +27,7 @@
 #include "OpenGL.h"
 
 // treat adjacent segments with angles between their directions <5 degree as straight
-static const float LINES_PARALLEL_EPS = 0.05;
+static const float LINES_PARALLEL_EPS = 0.05f;
 
 namespace love
 {

+ 214 - 0
src/modules/graphics/opengl/wrap_Geometry.cpp

@@ -0,0 +1,214 @@
+/**
+ * Copyright (c) 2006-2013 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_getVertexCount(lua_State *L)
+{
+	Geometry *geom = luax_checkgeometry(L, 1);
+	lua_pushinteger(L, geom->getVertexCount());
+	return 1;
+}
+
+int w_Geometry_getVertex(lua_State *L)
+{
+	Geometry *geom = luax_checkgeometry(L, 1);
+	size_t i = size_t(luaL_checkinteger(L, 2));
+
+	EXCEPT_GUARD(
+		const Vertex &v = geom->getVertex(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);
+	)
+
+	return 8;
+}
+
+int w_Geometry_setVertex(lua_State *L)
+{
+	Geometry *geom = luax_checkgeometry(L, 1);
+	size_t i = size_t(luaL_checkinteger(L, 2));
+
+	Vertex v;
+
+	if (lua_istable(L, 3))
+	{
+		for (int i = 1; i <= 8; i++)
+			lua_rawgeti(L, 3, i);
+
+		v.x = (float) luaL_checknumber(L, -8);
+		v.y = (float) luaL_checknumber(L, -7);
+		v.s = (float) luaL_checknumber(L, -6);
+		v.t = (float) luaL_checknumber(L, -5);
+		v.r = (unsigned char) luaL_optinteger(L, -4, 255);
+		v.g = (unsigned char) luaL_optinteger(L, -3, 255);
+		v.b = (unsigned char) luaL_optinteger(L, -2, 255);
+		v.a = (unsigned char) luaL_optinteger(L, -1, 255);
+
+		lua_pop(L, 8);
+	}
+	else
+	{
+		v.x = (float) luaL_checknumber(L, 3);
+		v.y = (float) luaL_checknumber(L, 4);
+		v.s = (float) luaL_checknumber(L, 5);
+		v.t = (float) luaL_checknumber(L, 6);
+		v.r = (unsigned char) luaL_optinteger(L,  7, 255);
+		v.g = (unsigned char) luaL_optinteger(L,  8, 255);
+		v.b = (unsigned char) luaL_optinteger(L,  9, 255);
+		v.a = (unsigned char) luaL_optinteger(L, 10, 255);
+	}
+
+	EXCEPT_GUARD(geom->setVertex(i-1, v);)
+
+	if (v.r != 255 || v.g != 255 || v.b != 255 || v.a != 255)
+		geom->setVertexColors(true);
+
+	return 0;
+}
+
+int w_Geometry_setVertexColors(lua_State *L)
+{
+	Geometry *geom = luax_checkgeometry(L, 1);
+	geom->setVertexColors(luax_toboolean(L, 2));
+	return 0;
+}
+
+int w_Geometry_hasVertexColors(lua_State *L)
+{
+	Geometry *geom = luax_checkgeometry(L, 1);
+	luax_pushboolean(L, geom->hasVertexColors());
+	return 1;
+}
+
+int w_Geometry_getDrawMode(lua_State *L)
+{
+	Geometry *geom = luax_checkgeometry(L, 1);
+
+	Geometry::DrawMode mode = geom->getDrawMode();
+	const char *str;
+
+	if (!Geometry::getConstant(mode, str))
+		return luaL_error(L, "Unknown Geometry draw mode");
+
+	lua_pushstring(L, str);
+
+	return 1;
+}
+
+int w_Geometry_getVertexMap(lua_State *L)
+{
+	Geometry *g = luax_checkgeometry(L, 1);
+
+	size_t elemcount = g->getElementCount();
+	const uint16 *elements = g->getElementArray();
+
+	if (elemcount == 0)
+		elemcount = g->getVertexCount();
+
+	lua_createtable(L, elemcount, 0);
+	for (size_t i = 0; i < elemcount; i++)
+	{
+		if (elements)
+			lua_pushinteger(L, elements[i] + 1);
+		else
+			lua_pushinteger(L, i + 1);
+
+		lua_rawseti(L, -2, i + 1);
+	}
+
+	return 1;
+}
+
+int w_Geometry_setVertexMap(lua_State *L)
+{
+	Geometry *g = luax_checkgeometry(L, 1);
+
+	for (int i = lua_gettop(L); i >= 2; i--)
+	{
+		if (lua_isnil(L, i))
+			lua_pop(L, 1);
+		else
+			break;
+	}
+
+	bool is_table = lua_istable(L, 2);
+	int nargs = is_table ? lua_objlen(L, 2) : lua_gettop(L) - 1;
+
+	std::vector<uint16> vertexmap;
+	vertexmap.reserve(nargs);
+
+	for (int i = 0; i < nargs; i++)
+	{
+		if (is_table)
+		{
+			lua_rawgeti(L, 2, i + 1);
+			vertexmap.push_back(uint16(luaL_checkinteger(L, -1) - 1));
+			lua_pop(L, 1);
+		}
+		else
+			vertexmap.push_back(uint16(luaL_checkinteger(L, i + 2) - 1));
+	}
+
+	EXCEPT_GUARD(g->setElementArray(&vertexmap[0], vertexmap.size());)
+	return 0;
+}
+
+static const luaL_Reg w_Geometry_functions[] =
+{
+	{ "getVertexCount", w_Geometry_getVertexCount },
+	{ "getVertex", w_Geometry_getVertex },
+	{ "setVertex", w_Geometry_setVertex },
+	{ "setVertexColors", w_Geometry_setVertexColors },
+	{ "hasVertexColors", w_Geometry_hasVertexColors },
+	{ "getDrawMode", w_Geometry_getDrawMode },
+	{ "getVertexMap", w_Geometry_getVertexMap },
+	{ "setVertexMap", w_Geometry_setVertexMap },
+	{ 0, 0 }
+};
+
+extern "C" int luaopen_geometry(lua_State *L)
+{
+	return luax_register_type(L, "Geometry", w_Geometry_functions);
+}
+
+} // opengl
+} // graphics
+} // love

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

@@ -304,7 +304,7 @@ int w_newParticleSystem(lua_State *L)
 	if (size < 1.0 || size > ParticleSystem::MAX_PARTICLES)
 		return luaL_error(L, "Invalid ParticleSystem size");	
 
-	EXCEPT_GUARD(t = instance->newParticleSystem(image, size);)
+	EXCEPT_GUARD(t = instance->newParticleSystem(image, int(size));)
 
 	luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
 	return 1;
@@ -688,7 +688,7 @@ int w_setDefaultMipmapFilter(lua_State *L)
 			return luaL_error(L, "Invalid filter mode: %s", str);
 	}
 
-	float sharpness = luaL_optnumber(L, 2, 0);
+	float sharpness = (float) luaL_optnumber(L, 2, 0);
 
 	instance->setDefaultMipmapFilter(filter, sharpness);
 

+ 2 - 0
src/modules/graphics/opengl/wrap_Graphics.h

@@ -49,6 +49,7 @@ int w_getDimensions(lua_State *L);
 int w_setScissor(lua_State *L);
 int w_getScissor(lua_State *L);
 int w_setStencil(lua_State *L);
+int w_setInvertedStencil(lua_State *L);
 int w_getMaxImageSize(lua_State *L);
 int w_newImage(lua_State *L);
 int w_newQuad(lua_State *L);
@@ -99,6 +100,7 @@ int w_line(lua_State *L);
 int w_rectangle(lua_State *L);
 int w_circle(lua_State *L);
 int w_arc(lua_State *L);
+int w_polygon(lua_State *L);
 int w_push(lua_State *L);
 int w_pop(lua_State *L);
 int w_rotate(lua_State *L);

+ 1 - 1
src/modules/graphics/opengl/wrap_Image.cpp

@@ -104,7 +104,7 @@ int w_Image_setMipmapFilter(lua_State *L)
 
 	EXCEPT_GUARD(t->setFilter(f);)
 
-	float sharpness = luaL_optnumber(L, 3, 0);
+	float sharpness = (float) luaL_optnumber(L, 3, 0);
 	t->setMipmapSharpness(sharpness);
 
 	return 0;

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

@@ -37,7 +37,7 @@ int w_Image_getWidth(lua_State *L);
 int w_Image_getHeight(lua_State *L);
 int w_Image_getDimensions(lua_State *L);
 int w_Image_setFilter(lua_State *L);
-int w_image_getFilter(lua_State *L);
+int w_Image_getFilter(lua_State *L);
 int w_Image_setMipmapFilter(lua_State *L);
 int w_Image_getMipmapFilter(lua_State *L);
 int w_Image_setWrap(lua_State *L);

+ 12 - 12
src/modules/graphics/opengl/wrap_ParticleSystem.cpp

@@ -457,10 +457,10 @@ int w_ParticleSystem_setColors(lua_State *L)
 				// push args[i+2][j+1] onto the stack
 				lua_rawgeti(L, i + 2, j + 1);
 
-			int r = luaL_checkint(L, -4);
-			int g = luaL_checkint(L, -3);
-			int b = luaL_checkint(L, -2);
-			int a = luaL_optint(L, -1, 255);
+			unsigned char r = (unsigned char) luaL_checkinteger(L, -4);
+			unsigned char g = (unsigned char) luaL_checkinteger(L, -3);
+			unsigned char b = (unsigned char) luaL_checkinteger(L, -2);
+			unsigned char a = (unsigned char) luaL_optinteger(L, -1, 255);
 
 			// pop the color components from the stack
 			lua_pop(L, 4);
@@ -483,10 +483,10 @@ int w_ParticleSystem_setColors(lua_State *L)
 
 		if (nColors == 1)
 		{
-			int r = luaL_checkint(L, 2);
-			int g = luaL_checkint(L, 3);
-			int b = luaL_checkint(L, 4);
-			int a = luaL_optint(L, 5, 255);
+			unsigned char r = (unsigned char) luaL_checkinteger(L, 2);
+			unsigned char g = (unsigned char) luaL_checkinteger(L, 3);
+			unsigned char b = (unsigned char) luaL_checkinteger(L, 4);
+			unsigned char a = (unsigned char) luaL_optinteger(L, 5, 255);
 			t->setColor(Color(r,g,b,a));
 		}
 		else
@@ -494,10 +494,10 @@ int w_ParticleSystem_setColors(lua_State *L)
 			std::vector<Color> colors(nColors);
 			for (size_t i = 0; i < nColors; ++i)
 			{
-				int r = luaL_checkint(L, 1 + i*4 + 1);
-				int g = luaL_checkint(L, 1 + i*4 + 2);
-				int b = luaL_checkint(L, 1 + i*4 + 3);
-				int a = luaL_checkint(L, 1 + i*4 + 4);
+				unsigned char r = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 1);
+				unsigned char g = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 2);
+				unsigned char b = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 3);
+				unsigned char a = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 4);
 				colors[i] = Color(r,g,b,a);
 			}
 			t->setColor(colors);

+ 1 - 0
src/modules/graphics/opengl/wrap_Shader.h

@@ -37,6 +37,7 @@ int w_Shader_sendInt(lua_State *L);
 int w_Shader_sendFloat(lua_State *L);
 int w_Shader_sendMatrix(lua_State *L);
 int w_Shader_sendImage(lua_State *L);
+int w_Shader_sendCanvas(lua_State *L);
 int w_Shader_send(lua_State *L);
 extern "C" int luaopen_shader(lua_State *L);
 

+ 8 - 8
src/modules/graphics/opengl/wrap_SpriteBatch.cpp

@@ -154,19 +154,19 @@ int w_SpriteBatch_setColor(lua_State *L)
 		for (int i = 1; i <= 4; i++)
 			lua_rawgeti(L, 2, i);
 
-		c.r = (unsigned char) luaL_checkint(L, -4);
-		c.g = (unsigned char) luaL_checkint(L, -3);
-		c.b = (unsigned char) luaL_checkint(L, -2);
-		c.a = (unsigned char) luaL_optint(L, -1, 255);
+		c.r = (unsigned char) luaL_checkinteger(L, -4);
+		c.g = (unsigned char) luaL_checkinteger(L, -3);
+		c.b = (unsigned char) luaL_checkinteger(L, -2);
+		c.a = (unsigned char) luaL_optinteger(L, -1, 255);
 
 		lua_pop(L, 4);
 	}
 	else
 	{
-		c.r = (unsigned char)luaL_checkint(L, 2);
-		c.g = (unsigned char)luaL_checkint(L, 3);
-		c.b = (unsigned char)luaL_checkint(L, 4);
-		c.a = (unsigned char)luaL_optint(L, 5, 255);
+		c.r = (unsigned char)luaL_checkinteger(L, 2);
+		c.g = (unsigned char)luaL_checkinteger(L, 3);
+		c.b = (unsigned char)luaL_checkinteger(L, 4);
+		c.a = (unsigned char)luaL_optinteger(L, 5, 255);
 	}
 
 	t->setColor(c);

+ 10 - 10
src/modules/math/wrap_BezierCurve.cpp

@@ -69,8 +69,8 @@ int w_BezierCurve_setControlPoint(lua_State *L)
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	int idx = luaL_checkinteger(L, 2);
-	double vx = luaL_checknumber(L, 3);
-	double vy = luaL_checknumber(L, 4);
+	float vx = (float) luaL_checknumber(L, 3);
+	float vy = (float) luaL_checknumber(L, 4);
 
 	if (idx > 0) // 1-indexing
 		idx--;
@@ -82,8 +82,8 @@ int w_BezierCurve_setControlPoint(lua_State *L)
 int w_BezierCurve_insertControlPoint(lua_State *L)
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
-	double vx = luaL_checknumber(L, 2);
-	double vy = luaL_checknumber(L, 3);
+	float vx = (float) luaL_checknumber(L, 2);
+	float vy = (float) luaL_checknumber(L, 3);
 	int idx = luaL_optinteger(L, 4, -1);
 
 	if (idx > 0) // 1-indexing
@@ -96,8 +96,8 @@ int w_BezierCurve_insertControlPoint(lua_State *L)
 int w_BezierCurve_translate(lua_State *L)
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
-	double dx = luaL_checknumber(L, 2);
-	double dy = luaL_checknumber(L, 3);
+	float dx = (float) luaL_checknumber(L, 2);
+	float dy = (float) luaL_checknumber(L, 3);
 	curve->translate(Vector(dx,dy));
 	return 0;
 }
@@ -106,8 +106,8 @@ int w_BezierCurve_rotate(lua_State *L)
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	double phi = luaL_checknumber(L, 2);
-	double ox = luaL_optnumber(L, 3, 0);
-	double oy = luaL_optnumber(L, 4, 0);
+	float ox = (float) luaL_optnumber(L, 3, 0);
+	float oy = (float) luaL_optnumber(L, 4, 0);
 	curve->rotate(phi, Vector(ox,oy));
 	return 0;
 }
@@ -116,8 +116,8 @@ int w_BezierCurve_scale(lua_State *L)
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	double s = luaL_checknumber(L, 2);
-	double ox = luaL_optnumber(L, 3, 0);
-	double oy = luaL_optnumber(L, 4, 0);
+	float ox = (float) luaL_optnumber(L, 3, 0);
+	float oy = (float) luaL_optnumber(L, 4, 0);
 	curve->scale(s, Vector(ox,oy));
 	return 0;
 }

+ 22 - 22
src/modules/math/wrap_Math.cpp

@@ -106,8 +106,8 @@ int w_newBezierCurve(lua_State *L)
 			lua_rawgeti(L, 1, i+1);
 
 			Vector v;
-			v.x = luaL_checknumber(L, -2);
-			v.y = luaL_checknumber(L, -1);
+			v.x = (float) luaL_checknumber(L, -2);
+			v.y = (float) luaL_checknumber(L, -1);
 			points.push_back(v);
 
 			lua_pop(L, 2);
@@ -120,8 +120,8 @@ int w_newBezierCurve(lua_State *L)
 		for (size_t i = 1; i <= top; i += 2)
 		{
 			Vector v;
-			v.x = luaL_checknumber(L, i);
-			v.y = luaL_checknumber(L, i+1);
+			v.x = (float) luaL_checknumber(L, i);
+			v.y = (float) luaL_checknumber(L, i+1);
 			points.push_back(v);
 		}
 	}
@@ -144,8 +144,8 @@ int w_triangulate(lua_State *L)
 			lua_rawgeti(L, 1, i+1);
 
 			Vertex v;
-			v.x = luaL_checknumber(L, -2);
-			v.y = luaL_checknumber(L, -1);
+			v.x = (float) luaL_checknumber(L, -2);
+			v.y = (float) luaL_checknumber(L, -1);
 			vertices.push_back(v);
 
 			lua_pop(L, 2);
@@ -158,8 +158,8 @@ int w_triangulate(lua_State *L)
 		for (size_t i = 1; i <= top; i += 2)
 		{
 			Vertex v;
-			v.x = luaL_checknumber(L, i);
-			v.y = luaL_checknumber(L, i+1);
+			v.x = (float) luaL_checknumber(L, i);
+			v.y = (float) luaL_checknumber(L, i+1);
 			vertices.push_back(v);
 		}
 	}
@@ -214,8 +214,8 @@ int w_isConvex(lua_State *L)
 			lua_rawgeti(L, 1, i+1);
 
 			Vertex v;
-			v.x = luaL_checknumber(L, -2);
-			v.y = luaL_checknumber(L, -1);
+			v.x = (float) luaL_checknumber(L, -2);
+			v.y = (float) luaL_checknumber(L, -1);
 			vertices.push_back(v);
 
 			lua_pop(L, 2);
@@ -228,8 +228,8 @@ int w_isConvex(lua_State *L)
 		for (size_t i = 1; i <= top; i += 2)
 		{
 			Vertex v;
-			v.x = luaL_checknumber(L, i);
-			v.y = luaL_checknumber(L, i+1);
+			v.x = (float) luaL_checknumber(L, i);
+			v.y = (float) luaL_checknumber(L, i+1);
 			vertices.push_back(v);
 		}
 	}
@@ -246,26 +246,26 @@ int w_noise(lua_State *L)
 	switch (lua_gettop(L))
 	{
 	case 1:
-		x = luaL_checknumber(L, 1);
+		x = (float) luaL_checknumber(L, 1);
 		val = Math::instance.noise(x);
 		break;
 	case 2:
-		x = luaL_checknumber(L, 1);
-		y = luaL_checknumber(L, 2);
+		x = (float) luaL_checknumber(L, 1);
+		y = (float) luaL_checknumber(L, 2);
 		val = Math::instance.noise(x, y);
 		break;
 	case 3:
-		x = luaL_checknumber(L, 1);
-		y = luaL_checknumber(L, 2);
-		z = luaL_checknumber(L, 3);
+		x = (float) luaL_checknumber(L, 1);
+		y = (float) luaL_checknumber(L, 2);
+		z = (float) luaL_checknumber(L, 3);
 		val = Math::instance.noise(x, y, z);
 		break;
 	case 4:
 	default:
-		x = luaL_checknumber(L, 1);
-		y = luaL_checknumber(L, 2);
-		z = luaL_checknumber(L, 3);
-		w = luaL_checknumber(L, 4);
+		x = (float) luaL_checknumber(L, 1);
+		y = (float) luaL_checknumber(L, 2);
+		z = (float) luaL_checknumber(L, 3);
+		w = (float) luaL_checknumber(L, 4);
 		val = Math::instance.noise(x, y, z, w);
 		break;
 	}

+ 2 - 2
src/modules/mouse/Mouse.h

@@ -42,10 +42,10 @@ public:
 		BUTTON_LEFT,
 		BUTTON_MIDDLE,
 		BUTTON_RIGHT,
-		BUTTON_WHEELUP,
-		BUTTON_WHEELDOWN,
 		BUTTON_X1,
 		BUTTON_X2,
+		BUTTON_WHEELUP,
+		BUTTON_WHEELDOWN,
 		BUTTON_MAX_ENUM
 	};
 

+ 1 - 1
src/modules/mouse/sdl/Mouse.cpp

@@ -130,7 +130,7 @@ void Mouse::setVisible(bool visible)
 
 bool Mouse::isDown(Button *buttonlist) const
 {
-	Uint8 buttonstate = SDL_GetMouseState(0, 0);
+	Uint32 buttonstate = SDL_GetMouseState(0, 0);
 
 	for (Button button = *buttonlist; button != BUTTON_MAX_ENUM; button = *(++buttonlist))
 	{

+ 6 - 6
src/modules/physics/box2d/Fixture.cpp

@@ -140,18 +140,18 @@ bool Fixture::isValid() const
 void Fixture::setFilterData(int *v)
 {
 	b2Filter f;
-	f.categoryBits = (unsigned short)v[0];
-	f.maskBits = (unsigned short)v[1];
-	f.groupIndex = v[2];
+	f.categoryBits = (uint16) v[0];
+	f.maskBits = (uint16) v[1];
+	f.groupIndex = (int16) v[2];
 	fixture->SetFilterData(f);
 }
 
 void Fixture::getFilterData(int *v)
 {
 	b2Filter f = fixture->GetFilterData();
-	v[0] = (int)f.categoryBits;
-	v[1] = (int)f.maskBits;
-	v[2] = f.groupIndex;
+	v[0] = (int) f.categoryBits;
+	v[1] = (int) f.maskBits;
+	v[2] = (int) f.groupIndex;
 }
 
 int Fixture::setCategory(lua_State *L)

+ 4 - 4
src/modules/sound/lullaby/VorbisDecoder.cpp

@@ -34,13 +34,13 @@ namespace lullaby
 /**
  * CALLBACK FUNCTIONS
  **/
-int vorbisClose(void *	/* ptr to the data that the vorbis files need*/)
+static int vorbisClose(void *	/* ptr to the data that the vorbis files need*/)
 {
 	// Does nothing (handled elsewhere)
 	return 1;
 }
 
-size_t vorbisRead(void *ptr		/* ptr to the data that the vorbis files need*/,
+static size_t vorbisRead(void *ptr	/* ptr to the data that the vorbis files need*/,
 				  size_t byteSize	/* how big a byte is*/,
 				  size_t sizeToRead	/* How much we can read*/,
 				  void *datasource	/* this is a pointer to the data we passed into ov_open_callbacks (our SOggFile struct*/)
@@ -72,7 +72,7 @@ size_t vorbisRead(void *ptr		/* ptr to the data that the vorbis files need*/,
 	return actualSizeToRead;
 }
 
-int vorbisSeek(void *datasource	/* ptr to the data that the vorbis files need*/,
+static int vorbisSeek(void *datasource	/* ptr to the data that the vorbis files need*/,
 			   ogg_int64_t offset	/*offset from the point we wish to seek to*/,
 			   int whence			/*where we want to seek to*/)
 {
@@ -116,7 +116,7 @@ int vorbisSeek(void *datasource	/* ptr to the data that the vorbis files need*/,
 	return 0;
 }
 
-long vorbisTell(void *datasource	/* ptr to the data that the vorbis files need*/)
+static long vorbisTell(void *datasource	/* ptr to the data that the vorbis files need*/)
 {
 	SOggFile *vorbisData;
 	vorbisData = (SOggFile *) datasource;

+ 7 - 8
src/modules/sound/wrap_SoundData.h

@@ -31,14 +31,13 @@ namespace sound
 {
 
 SoundData *luax_checksounddata(lua_State *L, int idx);
-int w_getSize(lua_State *L);
-int w_getChannels(lua_State *L);
-int w_getBitDepth(lua_State *L);
-int w_getSampleRate(lua_State *L);
-int w_getSampleCount(lua_State *L);
-int w_getDuration(lua_State *L);
-int w_setSample(lua_State *L);
-int w_getSample(lua_State *L);
+int w_SoundData_getChannels(lua_State *L);
+int w_SoundData_getBitDepth(lua_State *L);
+int w_SoundData_getSampleRate(lua_State *L);
+int w_SoundData_getSampleCount(lua_State *L);
+int w_SoundData_getDuration(lua_State *L);
+int w_SoundData_setSample(lua_State *L);
+int w_SoundData_getSample(lua_State *L);
 extern "C" int luaopen_sounddata(lua_State *L);
 
 } // sound