Browse Source

Merge default into minor

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

+ 0 - 3
CMakeLists.txt

@@ -200,9 +200,6 @@ Please see http://bitbucket.org/rude/megasource
 		${LOVE_LUA_LIBRARY}
 	)
 	
-	# Work-around for gcc bug 1568899.
-	set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} gcc_s gcc)
-
 	if(LOVE_MPG123)
 		find_package(MPG123 REQUIRED)
 		set(LOVE_LINK_LIBRARIES

+ 8 - 1
changes.txt

@@ -48,8 +48,11 @@ Released: N/A
   * Added lovec.exe in Windows. It is the same as love.exe but built with the Console subsystem, so it always uses or provides a console.
   * Added the ability to restart the game via love.event.quit("restart").
   * Added support for passing a table to love.mouse.isDown, love.keyboard.isDown, love.keyboard.isScancodeDown, Joystick:isDown, and Joystick:isGamepadDown.
+  * Added love.window.isMaximized.
   * Added 'shaderswitches' field to the table returned by love.graphics.getStats.
   * Added Quad:getTextureDimensions.
+  * Added 'ellipse' area distribution to ParticleSystems.
+  * Added support for BC4-7 compressed texture formats in KTX files.
   * Added PrismaticJoint:getAxis and WheelJoint:getAxis.
   * Added 2-point version of love.physics.newRevoluteJoint.
   * Added table variants of Fixture:setCategory and Fixture:setMask.
@@ -57,11 +60,13 @@ Released: N/A
   * Added optional reference angle arguments to RevoluteJoint, PrismaticJoint, and WeldJoint constructors.
   * Added RevoluteJoint:getReferenceAngle, PrismaticJoint:getReferenceAngle, and WeldJoint:getReferenceAngle.
 
-  * Deprecated Shader:sendTexture, Shader:sendMatrix, Shader:sendInt, and Shader:sendFloat.
+  * Deprecated undocumented Shader:sendTexture, Shader:sendMatrix, Shader:sendInt, and Shader:sendFloat functions.
 
   * Fixed love on iOS 6.
   * Fixed os.execute always returning -1 on Linux.
   * Fixed the love.lowmemory callback to call collectgarbage() after the callback has fired, instead of before.
+  * Fixed love.math.noise(nil) to error instead of returning nil.
+  * Fixed an occasional crash when a Thread ends.
   * Fixed a hang at the end of video playback with some video files.
   * Fixed the video decoding thread to not do any work when there are no videos to decode.
   * Fixed love.graphics.newVideo(file) to no longer error if love.audio is disabled.
@@ -70,6 +75,7 @@ Released: N/A
   * Fixed stencils inside Canvases on some OpenGL ES 2 devices.
   * Fixed an OpenGL error in OpenGL ES 3 when multiple render targets are used.
   * Fixed love.window.setMode crashing when called with a Canvas active.
+  * Fixed love.window.maximize to update the reported window dimensions immediately.
   * Fixed gamma correction of ImageFonts and BMFonts with colored images.
   * Fixed the default shader improperly applying gamma correction to per-vertex colors when gamma correction is requested but not supported on OpenGL ES.
   * Fixed text coloring breaking because of an empty string.
@@ -78,6 +84,7 @@ Released: N/A
   * Fixed MouseJoint:getBodies unconditionally erroring.
   * Fixed memory leak in Text:set.
   * Fixed incorrect kerning caused by using kerning information for the wrong character in some fonts.
+  * Fixed ImageData:setPixel/getPixel/mapPixel and SoundData:setSample/getSample to properly handle non-integer coordinates.
 
   * Improved performance of Channel methods by roughly 2x in many cases.
   * Improved performance of Shader:send when small numbers of arguments are given.

+ 6 - 0
platform/unix/configure.ac

@@ -37,6 +37,12 @@ AS_VAR_IF([enable_osx], [no], [], #else
 		  AC_SUBST([LDFLAGS], ["${LDFLAGS} -framework CoreFoundation -framework Cocoa"])
 		  AC_SUBST([CPPFLAGS], ["${CPPFLAGS} -I../platform/macosx"]))
 
+# stb_image sse2 override (https://github.com/nothings/stb/issues/280)
+AC_ARG_ENABLE([stbi-sse2-override],
+			  AC_HELP_STRING([--enable-stbi-sse2-override], [Force stb_image SSE2 support]), [], [enable_stbi_sse2_override=no])
+AS_VAR_IF([enable_stbi_sse2_override], [no], [], #else
+		  AC_SUBST([CPPFLAGS], ["${CPPFLAGS} -DLOVE_STBI_SSE2_OVERRIDE"]))
+
 # --with-lua and --with-luaversion
 AC_ARG_WITH([lua], [AS_HELP_STRING([--with-lua], [Select the lua implementation])],
 	[], [with_lua=luajit])

+ 17 - 0
src/common/Matrix.cpp

@@ -73,6 +73,11 @@ Matrix4::Matrix4()
 {
 	setIdentity();
 }
+	
+Matrix4::Matrix4(float t00, float t10, float t01, float t11, float x, float y)
+{
+	setRawTransformation(t00, t10, t01, t11, x, y);
+}
 
 Matrix4::Matrix4(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
 {
@@ -138,6 +143,18 @@ void Matrix4::setShear(float kx, float ky)
 	e[1] = ky;
 	e[4] = kx;
 }
+	
+void Matrix4::setRawTransformation(float t00, float t10, float t01, float t11, float x, float y)
+{
+	memset(e, 0, sizeof(float)*16); // zero out matrix
+	e[10] = e[15] = 1.0f;
+	e[0] = t00;
+	e[1] = t10;
+	e[4] = t01;
+	e[5] = t11;
+	e[12] = x;
+	e[13] = y;
+}
 
 void Matrix4::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
 {

+ 20 - 0
src/common/Matrix.h

@@ -46,6 +46,11 @@ public:
 	 * Creates a new identity matrix.
 	 **/
 	Matrix4();
+	
+	/**
+	 * Creates a new matrix with the transform values set.
+	 **/
+	Matrix4(float t00, float t10, float t01, float t11, float x, float y);
 
 	/**
 	 * Creates a new matrix set to a transformation.
@@ -107,6 +112,21 @@ public:
 	 * @param ky Shear along y-axis.
 	 **/
 	void setShear(float kx, float ky);
+	
+	/**
+	 * Sets a transformation's values directly. Useful if you want to modify them inplace,
+	 * or if you want to create a transformation that's not buildable with setTransformation()
+	 * i.e. the inverse of setTransformation() is not easily built with another call
+	 * to setTransformation() with tweaked values.
+	 *
+	 * @param t00 The sx*cos(angle) component of the transformation.
+	 * @param t10 The sx*sin(angle) component of the transformation.
+	 * @param t01 The sy*(-sin(angle)) component of the transformation.
+	 * @param t11 The sy*cos(angle) component of the transformation.
+	 * @param x The x translation component of the transformation.
+	 * @param y The y translation component of the transformation.
+	 **/
+	void setRawTransformation(float t00, float t10, float t01, float t11, float x, float y);
 
 	/**
 	 * Creates a transformation with a certain position, orientation, scale

+ 11 - 5
src/libraries/stb/stb_image.h

@@ -712,12 +712,18 @@ static int stbi__sse2_available()
 
 static int stbi__sse2_available()
 {
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later
-   // GCC 4.8+ has a nice way to do this
-   return __builtin_cpu_supports("sse2");
+#if defined(STBI__X64_TARGET)
+   // on x64, SSE2 can be assumed to be available.
+   return 1;
+#elif defined(LOVE_STBI_SSE2_OVERRIDE)
+   return 1;
 #else
-   // portable way to do this, preferably without using GCC inline ASM?
-   // just bail for now.
+#	warning "stb_image compiled without SSE2 support, define LOVE_STBI_SSE2_OVERRIDE to force SSE2 support"
+   // __builtin_cpu_supports is buggy on GCC 5 and above, causing problems if
+   // referenced in a shared object, giving missing __cpu_model hidden symbol errors.
+   // To get around that, just assume that SSE2 is not available on x86.
+   //
+   // See https://github.com/nothings/stb/issues/280 for more information.
    return 0;
 #endif
 }

+ 8 - 0
src/modules/graphics/ParticleSystem.cpp

@@ -242,6 +242,7 @@ void ParticleSystem::initParticle(Particle *p, float t)
 
 	p->position = pos;
 
+	float rand_x, rand_y;
 	switch (areaSpreadDistribution)
 	{
 	case DISTRIBUTION_UNIFORM:
@@ -252,6 +253,12 @@ void ParticleSystem::initParticle(Particle *p, float t)
 		p->position.x += (float) rng.randomNormal(areaSpread.getX());
 		p->position.y += (float) rng.randomNormal(areaSpread.getY());
 		break;
+	case DISTRIBUTION_ELLIPSE:
+		rand_x = (float) rng.random(-1, 1);
+		rand_y = (float) rng.random(-1, 1);
+		p->position.x += areaSpread.getX() * (rand_x * sqrt(1 - 0.5f*pow(rand_y, 2)));
+		p->position.y += areaSpread.getY() * (rand_y * sqrt(1 - 0.5f*pow(rand_x, 2)));
+		break;
 	case DISTRIBUTION_NONE:
 	default:
 		break;
@@ -949,6 +956,7 @@ StringMap<ParticleSystem::AreaSpreadDistribution, ParticleSystem::DISTRIBUTION_M
 	{ "none",    DISTRIBUTION_NONE },
 	{ "uniform", DISTRIBUTION_UNIFORM },
 	{ "normal",  DISTRIBUTION_NORMAL },
+	{ "ellipse",  DISTRIBUTION_ELLIPSE },
 };
 
 StringMap<ParticleSystem::AreaSpreadDistribution, ParticleSystem::DISTRIBUTION_MAX_ENUM> ParticleSystem::distributions(ParticleSystem::distributionsEntries, sizeof(ParticleSystem::distributionsEntries));

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

@@ -46,13 +46,14 @@ class ParticleSystem : public Drawable
 {
 public:
 	/**
-	 * Type of distribution new particles are drawn from: None, uniform, normal.
+	 * Type of distribution new particles are drawn from: None, uniform, normal, ellipse.
 	 */
 	enum AreaSpreadDistribution
 	{
 		DISTRIBUTION_NONE,
 		DISTRIBUTION_UNIFORM,
 		DISTRIBUTION_NORMAL,
+		DISTRIBUTION_ELLIPSE,
 		DISTRIBUTION_MAX_ENUM
 	};
 

+ 57 - 6
src/modules/image/magpie/KTXHandler.cpp

@@ -67,6 +67,7 @@ enum KTXGLInternalFormat
 {
 	KTX_GL_ETC1_RGB8_OES = 0x8D64,
 
+	// ETC2 and EAC.
 	KTX_GL_COMPRESSED_R11_EAC                        = 0x9270,
 	KTX_GL_COMPRESSED_SIGNED_R11_EAC                 = 0x9271,
 	KTX_GL_COMPRESSED_RG11_EAC                       = 0x9272,
@@ -78,17 +79,33 @@ enum KTXGLInternalFormat
 	KTX_GL_COMPRESSED_RGBA8_ETC2_EAC                 = 0x9278,
 	KTX_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC          = 0x9279,
 
-	// I don't know if any KTX file contains PVR data, but why not support it.
+	// PVRTC1.
 	KTX_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG  = 0x8C00,
 	KTX_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG  = 0x8C01,
 	KTX_GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02,
 	KTX_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03,
 
-	// Same with DXT1/3/5.
-	KTX_GL_COMPRESSED_RGB_S3TC_DXT1_EXT  = 0x83F0,
-	KTX_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2,
-	KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3,
-
+	// DXT1, DXT3, and DXT5.
+	KTX_GL_COMPRESSED_RGB_S3TC_DXT1_EXT        = 0x83F0,
+	KTX_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT       = 0x83F2,
+	KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT       = 0x83F3,
+	KTX_GL_COMPRESSED_SRGB_S3TC_DXT1_EXT       = 0x8C4C,
+	KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E,
+	KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F,
+
+	// BC4 and BC5.
+	KTX_GL_COMPRESSED_RED_RGTC1        = 0x8DBB,
+	KTX_GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC,
+	KTX_GL_COMPRESSED_RG_RGTC2         = 0x8DBD,
+	KTX_GL_COMPRESSED_SIGNED_RG_RGTC2  = 0x8DBE,
+
+	// BC6 and BC7.
+	KTX_GL_COMPRESSED_RGBA_BPTC_UNORM         = 0x8E8C,
+	KTX_GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM   = 0x8E8D,
+	KTX_GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT   = 0x8E8E,
+	KTX_GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F,
+
+	// ASTC.
 	KTX_GL_COMPRESSED_RGBA_ASTC_4x4_KHR           = 0x93B0,
 	KTX_GL_COMPRESSED_RGBA_ASTC_5x4_KHR           = 0x93B1,
 	KTX_GL_COMPRESSED_RGBA_ASTC_5x5_KHR           = 0x93B2,
@@ -129,6 +146,8 @@ CompressedImageData::Format convertFormat(uint32 glformat, bool &sRGB)
 	{
 	case KTX_GL_ETC1_RGB8_OES:
 		return CompressedImageData::FORMAT_ETC1;
+
+	// EAC and ETC2.
 	case KTX_GL_COMPRESSED_R11_EAC:
 		return CompressedImageData::FORMAT_EAC_R;
 	case KTX_GL_COMPRESSED_SIGNED_R11_EAC:
@@ -152,6 +171,8 @@ CompressedImageData::Format convertFormat(uint32 glformat, bool &sRGB)
 	case KTX_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
 		sRGB = true;
 		return CompressedImageData::FORMAT_ETC2_RGBA;
+
+	// PVRTC.
 	case KTX_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
 		return CompressedImageData::FORMAT_PVR1_RGB4;
 	case KTX_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
@@ -160,12 +181,42 @@ CompressedImageData::Format convertFormat(uint32 glformat, bool &sRGB)
 		return CompressedImageData::FORMAT_PVR1_RGBA4;
 	case KTX_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
 		return CompressedImageData::FORMAT_PVR1_RGBA2;
+
+	// DXT.
+	case KTX_GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+		sRGB = true;
 	case KTX_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
 		return CompressedImageData::FORMAT_DXT1;
+	case KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+		sRGB = true;
 	case KTX_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
 		return CompressedImageData::FORMAT_DXT3;
+	case KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+		sRGB = true;
 	case KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
 		return CompressedImageData::FORMAT_DXT5;
+
+	// BC4 and BC5.
+	case KTX_GL_COMPRESSED_RED_RGTC1:
+		return CompressedImageData::FORMAT_BC4;
+	case KTX_GL_COMPRESSED_SIGNED_RED_RGTC1:
+		return CompressedImageData::FORMAT_BC4s;
+	case KTX_GL_COMPRESSED_RG_RGTC2:
+		return CompressedImageData::FORMAT_BC5;
+	case KTX_GL_COMPRESSED_SIGNED_RG_RGTC2:
+		return CompressedImageData::FORMAT_BC5s;
+
+	// BC6 and BC7.
+	case KTX_GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
+		sRGB = true;
+	case KTX_GL_COMPRESSED_RGBA_BPTC_UNORM:
+		return CompressedImageData::FORMAT_BC7;
+	case KTX_GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
+		return CompressedImageData::FORMAT_BC6Hs;
+	case KTX_GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
+		return CompressedImageData::FORMAT_BC6H;
+
+	// ASTC.
 	case KTX_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
 		sRGB = true;
 	case KTX_GL_COMPRESSED_RGBA_ASTC_4x4_KHR:

+ 2 - 0
src/modules/window/Window.h

@@ -143,6 +143,8 @@ public:
 	virtual void minimize() = 0;
 	virtual void maximize() = 0;
 
+	virtual bool isMaximized() const = 0;
+
 	// default no-op implementation
 	virtual void swapBuffers();
 

+ 5 - 0
src/modules/window/sdl/Window.cpp

@@ -886,6 +886,11 @@ void Window::maximize()
 	}
 }
 
+bool Window::isMaximized() const
+{
+	return window != nullptr && (SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED);
+}
+
 void Window::swapBuffers()
 {
 	SDL_GL_SwapWindow(window);

+ 2 - 0
src/modules/window/sdl/Window.h

@@ -76,6 +76,8 @@ public:
 	void minimize();
 	void maximize();
 
+	bool isMaximized() const;
+
 	void swapBuffers();
 
 	bool hasFocus() const;

+ 7 - 0
src/modules/window/wrap_Window.cpp

@@ -466,6 +466,12 @@ int w_maximize(lua_State *)
 	return 0;
 }
 
+int w_isMaximized(lua_State *L)
+{
+	luax_pushboolean(L, instance()->isMaximized());
+	return 0;
+}
+
 int w_showMessageBox(lua_State *L)
 {
 	Window::MessageBoxData data = {};
@@ -567,6 +573,7 @@ static const luaL_Reg functions[] =
 	{ "fromPixels", w_fromPixels },
 	{ "minimize", w_minimize },
 	{ "maximize", w_maximize },
+	{ "isMaximized", w_isMaximized },
 	{ "showMessageBox", w_showMessageBox },
 	{ "requestAttention", w_requestAttention },
 	{ 0, 0 }