From c186a70b144d01580899fa2692d72436ad11416d Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 15 Apr 2018 21:22:56 +0200 Subject: [PATCH] Updated love sources to changeset 0ab246b5045d and updated android version --- app/build.gradle | 4 +- love/src/jni/love/.hg_archival.txt | 6 +- love/src/jni/love/CMakeLists.txt | 4 +- love/src/jni/love/changes.txt | 16 +++- love/src/jni/love/extra/appveyor/appveyor.yml | 2 +- love/src/jni/love/extra/windows/love.rc | Bin 3636 -> 3632 bytes love/src/jni/love/platform/unix/configure.ac | 2 +- love/src/jni/love/platform/unix/love.6 | 2 +- .../love/platform/xcode/ios/love-ios.plist | 2 +- .../xcode/love.xcodeproj/project.pbxproj | 20 ++++- .../xcode/macosx/liblove-macosx.plist | 2 +- .../platform/xcode/macosx/love-macosx.plist | 2 +- love/src/jni/love/src/common/version.h | 6 +- .../love/src/modules/audio/wrap_Source.cpp | 2 +- .../love/src/modules/graphics/Graphics.cpp | 31 ++++++- .../jni/love/src/modules/graphics/Graphics.h | 18 ++++ .../src/modules/graphics/opengl/Canvas.cpp | 22 +++++ .../src/modules/graphics/opengl/Graphics.cpp | 83 ++++++++---------- .../src/modules/graphics/opengl/Graphics.h | 26 +++++- .../src/modules/graphics/opengl/OpenGL.cpp | 2 +- .../modules/joystick/wrap_JoystickModule.cpp | 16 ++-- love/src/jni/love/src/modules/love/love.cpp | 31 +++---- .../src/modules/physics/box2d/ChainShape.cpp | 14 +-- .../src/modules/physics/box2d/ChainShape.h | 5 +- .../love/src/modules/window/sdl/Window.cpp | 15 ++-- .../jni/love/src/modules/window/sdl/Window.h | 2 + 26 files changed, 213 insertions(+), 122 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7e7e06d3..f8a8e39e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,8 +5,8 @@ android { buildToolsVersion "26.0.2" defaultConfig { applicationId "org.love2d.android" - versionCode 25 - versionName "11.0.0a" + versionCode 26 + versionName "11.1" minSdkVersion 14 targetSdkVersion 22 } diff --git a/love/src/jni/love/.hg_archival.txt b/love/src/jni/love/.hg_archival.txt index 85969ce5..6cd43b02 100644 --- a/love/src/jni/love/.hg_archival.txt +++ b/love/src/jni/love/.hg_archival.txt @@ -1,6 +1,4 @@ repo: d362ae6ab7f5005b8dbc7cba9ce592637de60f99 -node: 6504209dc45bbd317a663c02db084a703b9d42c5 +node: 0ab246b5045d2e697a516fcc0f8b12496a2d5c78 branch: default -latesttag: 11.0 -latesttagdistance: 1 -changessincelatesttag: 1 +tag: 11.1 diff --git a/love/src/jni/love/CMakeLists.txt b/love/src/jni/love/CMakeLists.txt index 9ab59cfd..fbe61b2e 100755 --- a/love/src/jni/love/CMakeLists.txt +++ b/love/src/jni/love/CMakeLists.txt @@ -1853,7 +1853,7 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt") set(CPACK_NSIS_EXECUTABLES_DIRECTORY .) -set(CPACK_NSIS_PACKAGE_NAME "LÖVE") +set(CPACK_NSIS_PACKAGE_NAME "LOVE") set(CPACK_NSIS_DISPLAY_NAME "LOVE ${LOVE_VERSION_STR}") set(CPACK_NSIS_MODIFY_PATH OFF) @@ -1874,7 +1874,7 @@ set(NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/extra/nsis\\\\love.ico") set(NSIS_MUI_UNICON "${CMAKE_CURRENT_SOURCE_DIR}/extra/nsis\\\\love.ico") set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE " - !define MUI_WELCOMEPAGE_TITLE \\\"LÖVE ${LOVE_VERSION_STR} Setup\\\" + !define MUI_WELCOMEPAGE_TITLE \\\"LOVE ${LOVE_VERSION_STR} Setup\\\" !define MUI_WELCOMEFINISHPAGE_BITMAP \\\"${NSIS_LEFT_BMP}\\\" !define MUI_HEADERIMAGE_BITMAP \\\"${NSIS_TOP_BMP}\\\" !define MUI_ICON \\\"${NSIS_MUI_ICON}\\\" diff --git a/love/src/jni/love/changes.txt b/love/src/jni/love/changes.txt index 4e360129..22074210 100644 --- a/love/src/jni/love/changes.txt +++ b/love/src/jni/love/changes.txt @@ -1,5 +1,19 @@ +LOVE 11.1 [Mysterious Mysteries] +-------------------------------- + +Released: 2018-04-15 + +* Fixed love.graphics.setCanvas failing randomly. +* Fixed love.graphics.clear(colortable) when no Canvas is active. +* Fixed stencil and depth support on older phones. +* Fixed love.event.quit causing crashes and other unexpected behaviour if a Canvas is active. +* Fixed Fixture:getShape crashing when returning a ChainShape. +* Fixed love.joystick.loadJoystickMappings outputting a deprecation warning about love.filesystem.isFile. +* Fixed Source:queue to show the correct argument name in the error message when an invalid data parameter is given. +* Fixed t.console=true causing an error on Windows if lovec.exe is used. + LOVE 11.0 [Mysterious Mysteries] --------------- +-------------------------------- Released: 2018-04-01 diff --git a/love/src/jni/love/extra/appveyor/appveyor.yml b/love/src/jni/love/extra/appveyor/appveyor.yml index 131e165a..5f659f78 100644 --- a/love/src/jni/love/extra/appveyor/appveyor.yml +++ b/love/src/jni/love/extra/appveyor/appveyor.yml @@ -1,4 +1,4 @@ -version: 11.0.{build} +version: 11.1.{build} image: Visual Studio 2013 diff --git a/love/src/jni/love/extra/windows/love.rc b/love/src/jni/love/extra/windows/love.rc index 3ab8535ef3d65cb8c9f8ee325e7f13a054382705..91482de60376c4d2cd87ea68e75b737236ced11f 100644 GIT binary patch delta 61 zcmdlYvq5Hq91Eu*gCT<+5Gze?WEGw4z#=xeiA8Dh9(JzD4J<5^n^;9AZ(!z{?8Ppy Qc?(MpJEO&BMIK=$0OscpssI20 delta 63 zcmdlWvqffu91E`jgC2t+5b7})FepuKWRd6fWpHHhV(@1OVo+c(0EtZ2W9OP2z@oBw P0ZR=#qxoi89$_W`me&m6 diff --git a/love/src/jni/love/platform/unix/configure.ac b/love/src/jni/love/platform/unix/configure.ac index dca7e953..d08119fd 100644 --- a/love/src/jni/love/platform/unix/configure.ac +++ b/love/src/jni/love/platform/unix/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([love], [11.0]) +AC_INIT([love], [11.1]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([platform/unix]) AC_CONFIG_MACRO_DIR([platform/unix/m4]) diff --git a/love/src/jni/love/platform/unix/love.6 b/love/src/jni/love/platform/unix/love.6 index 20f7dfe3..2123c37a 100644 --- a/love/src/jni/love/platform/unix/love.6 +++ b/love/src/jni/love/platform/unix/love.6 @@ -12,7 +12,7 @@ .\" 3. This notice may not be removed or altered from any source distribution. .Dd March 31, 2018 .Dt LOVE 6 -.Os LÖVE 11.0 +.Os LÖVE 11.1 .Sh NAME .Nm love .Nd 2D game development framework diff --git a/love/src/jni/love/platform/xcode/ios/love-ios.plist b/love/src/jni/love/platform/xcode/ios/love-ios.plist index 997fa8d8..0c57052c 100644 --- a/love/src/jni/love/platform/xcode/ios/love-ios.plist +++ b/love/src/jni/love/platform/xcode/ios/love-ios.plist @@ -40,7 +40,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 11.0 + 11.1 CFBundleSignature ???? CFBundleVersion diff --git a/love/src/jni/love/platform/xcode/love.xcodeproj/project.pbxproj b/love/src/jni/love/platform/xcode/love.xcodeproj/project.pbxproj index 4fadca74..e7d27316 100644 --- a/love/src/jni/love/platform/xcode/love.xcodeproj/project.pbxproj +++ b/love/src/jni/love/platform/xcode/love.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ A9255F58104324E100BA1496 /* ogg.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F51104324D700BA1496 /* ogg.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; A93E6E5510420B57007D418B /* Lua.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E5310420B57007D418B /* Lua.framework */; }; A93E6EED10420BA8007D418B /* love.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A3410420AC0007D418B /* love.cpp */; }; - A9D307F2106635D3004FEDF8 /* physfs.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9D307E9106635C3004FEDF8 /* physfs.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; A9F169AC109E825000FC83D1 /* mpg123.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9F169A6109E824900FC83D1 /* mpg123.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; A9F169AD109E825000FC83D1 /* libmodplug.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9F16926109E7BAD00FC83D1 /* libmodplug.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; CE73F8001EEB64150052DAB3 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE73F7FF1EEB64150052DAB3 /* AVFoundation.framework */; }; @@ -42,6 +41,7 @@ FAC1A449196F5DC600125284 /* license.txt in Resources */ = {isa = PBXBuildFile; fileRef = FAC1A448196F5DC600125284 /* license.txt */; }; FAD43ED01FF3136500831BB8 /* freetype.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = FAD43ECF1FF3133700831BB8 /* freetype.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; FAD4B1731C1F50A3004CF150 /* theora.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = FA27B3CA1B498696008A9DCE /* theora.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + FAE64A9D2072738600BC7981 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE64A9C2072738600BC7981 /* Metal.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -89,7 +89,6 @@ FAD43ED01FF3136500831BB8 /* freetype.framework in Copy Frameworks */, A9F169AC109E825000FC83D1 /* mpg123.framework in Copy Frameworks */, A9F169AD109E825000FC83D1 /* libmodplug.framework in Copy Frameworks */, - A9D307F2106635D3004FEDF8 /* physfs.framework in Copy Frameworks */, A9255F58104324E100BA1496 /* ogg.framework in Copy Frameworks */, A9255E031043195A00BA1496 /* vorbis.framework in Copy Frameworks */, A9255DD31043183600BA1496 /* Lua.framework in Copy Frameworks */, @@ -108,7 +107,6 @@ A93E6E4710420B4A007D418B /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = ""; }; A93E6E5310420B57007D418B /* Lua.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Lua.framework; path = /Library/Frameworks/Lua.framework; sourceTree = ""; }; A97E3842132A9EDE00198A2F /* love-macosx.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "love-macosx.plist"; path = "macosx/love-macosx.plist"; sourceTree = ""; }; - A9D307E9106635C3004FEDF8 /* physfs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = physfs.framework; path = /Library/Frameworks/physfs.framework; sourceTree = ""; }; A9F16926109E7BAD00FC83D1 /* libmodplug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libmodplug.framework; path = /Library/Frameworks/libmodplug.framework; sourceTree = ""; }; A9F169A6109E824900FC83D1 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = ""; }; CE73F7FF1EEB64150052DAB3 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; @@ -134,6 +132,7 @@ FAAFF04616CB120000CCDE45 /* OpenAL-Soft.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "OpenAL-Soft.framework"; path = "/Library/Frameworks/OpenAL-Soft.framework"; sourceTree = ""; }; FAC1A448196F5DC600125284 /* license.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = license.txt; path = ../../license.txt; sourceTree = ""; }; FAD43ECF1FF3133700831BB8 /* freetype.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = freetype.framework; path = /Library/Frameworks/freetype.framework; sourceTree = ""; }; + FAE64A9C2072738600BC7981 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -153,6 +152,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FAE64A9D2072738600BC7981 /* Metal.framework in Frameworks */, FA15DFB41F9B8D9E0042AB22 /* libbz2.tbd in Frameworks */, CE73F8001EEB64150052DAB3 /* AVFoundation.framework in Frameworks */, FA5D24D11A96E73300C6FC8F /* liblove.a in Frameworks */, @@ -175,6 +175,7 @@ 1058C7A0FEA54F0111CA2CBB /* Frameworks */ = { isa = PBXGroup; children = ( + FAE64A9C2072738600BC7981 /* Metal.framework */, FA15DFB31F9B8D9E0042AB22 /* libbz2.tbd */, CE73F7FF1EEB64150052DAB3 /* AVFoundation.framework */, FA5D24801A96C97900C6FC8F /* ios */, @@ -236,7 +237,6 @@ A9255F51104324D700BA1496 /* ogg.framework */, FAAFF04616CB120000CCDE45 /* OpenAL-Soft.framework */, A93E6E4710420B4A007D418B /* OpenGL.framework */, - A9D307E9106635C3004FEDF8 /* physfs.framework */, FA9B4A0916E1579F00074F42 /* SDL2.framework */, FA27B3CA1B498696008A9DCE /* theora.framework */, A9255E021043195A00BA1496 /* vorbis.framework */, @@ -667,6 +667,10 @@ COPY_PHASE_STRIP = NO; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); GCC_DYNAMIC_NO_PIC = NO; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -715,6 +719,10 @@ ENABLE_BITCODE = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -758,6 +766,10 @@ ENABLE_BITCODE = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; diff --git a/love/src/jni/love/platform/xcode/macosx/liblove-macosx.plist b/love/src/jni/love/platform/xcode/macosx/liblove-macosx.plist index 4491a523..94af9b3c 100644 --- a/love/src/jni/love/platform/xcode/macosx/liblove-macosx.plist +++ b/love/src/jni/love/platform/xcode/macosx/liblove-macosx.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 11.0 + 11.1 CFBundleSignature LoVe NSPrincipalClass diff --git a/love/src/jni/love/platform/xcode/macosx/love-macosx.plist b/love/src/jni/love/platform/xcode/macosx/love-macosx.plist index be2b6b16..1ad5f9f8 100644 --- a/love/src/jni/love/platform/xcode/macosx/love-macosx.plist +++ b/love/src/jni/love/platform/xcode/macosx/love-macosx.plist @@ -62,7 +62,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 11.0 + 11.1 CFBundleSignature LoVe LSApplicationCategoryType diff --git a/love/src/jni/love/src/common/version.h b/love/src/jni/love/src/common/version.h index f34d3fa0..23e5f777 100644 --- a/love/src/jni/love/src/common/version.h +++ b/love/src/jni/love/src/common/version.h @@ -25,12 +25,12 @@ namespace love { // Version stuff. -#define LOVE_VERSION_STRING "11.0" +#define LOVE_VERSION_STRING "11.1" static const int VERSION_MAJOR = 11; -static const int VERSION_MINOR = 0; +static const int VERSION_MINOR = 1; static const int VERSION_REV = 0; static const char *VERSION = LOVE_VERSION_STRING; -static const char *VERSION_COMPATIBILITY[] = { VERSION, 0 }; +static const char *VERSION_COMPATIBILITY[] = { VERSION, "11.0", 0 }; static const char *VERSION_CODENAME = "Mysterious Mysteries"; } // love diff --git a/love/src/jni/love/src/modules/audio/wrap_Source.cpp b/love/src/jni/love/src/modules/audio/wrap_Source.cpp index 6a120817..273b48f0 100644 --- a/love/src/jni/love/src/modules/audio/wrap_Source.cpp +++ b/love/src/jni/love/src/modules/audio/wrap_Source.cpp @@ -564,7 +564,7 @@ int w_Source_queue(lua_State *L) }); } else - return luax_typerror(L, 1, "Sound Data or lightuserdata"); + return luax_typerror(L, 2, "SoundData or lightuserdata"); luax_pushboolean(L, success); return 1; diff --git a/love/src/jni/love/src/modules/graphics/Graphics.cpp b/love/src/jni/love/src/modules/graphics/Graphics.cpp index 38543fb4..6acd45d7 100644 --- a/love/src/jni/love/src/modules/graphics/Graphics.cpp +++ b/love/src/jni/love/src/modules/graphics/Graphics.cpp @@ -628,6 +628,7 @@ void Graphics::setCanvas(const RenderTargets &rts) bool hasSRGBcanvas = firstcolorformat == PIXELFORMAT_sRGBA8; int pixelw = firstcanvas->getPixelWidth(firsttarget.mipmap); int pixelh = firstcanvas->getPixelHeight(firsttarget.mipmap); + int reqmsaa = firstcanvas->getRequestedMSAA(); for (int i = 1; i < ncanvases; i++) { @@ -648,7 +649,7 @@ void Graphics::setCanvas(const RenderTargets &rts) if (!multiformatsupported && format != firstcolorformat) throw love::Exception("This system doesn't support multi-canvas rendering with different canvas formats."); - if (c->getRequestedMSAA() != firstcanvas->getRequestedMSAA()) + if (c->getRequestedMSAA() != reqmsaa) throw love::Exception("All Canvases must have the same MSAA value."); if (isPixelFormatDepthStencil(format)) @@ -684,7 +685,33 @@ void Graphics::setCanvas(const RenderTargets &rts) int h = firstcanvas->getHeight(firsttarget.mipmap); flushStreamDraws(); - setCanvasInternal(rts, w, h, pixelw, pixelh, hasSRGBcanvas); + + if (rts.depthStencil.canvas == nullptr && rts.temporaryRTFlags != 0) + { + bool wantsdepth = (rts.temporaryRTFlags & TEMPORARY_RT_DEPTH) != 0; + bool wantsstencil = (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) != 0; + + PixelFormat dsformat = PIXELFORMAT_STENCIL8; + if (wantsdepth && wantsstencil) + dsformat = PIXELFORMAT_DEPTH24_STENCIL8; + else if (wantsdepth && isCanvasFormatSupported(PIXELFORMAT_DEPTH24, false)) + dsformat = PIXELFORMAT_DEPTH24; + else if (wantsdepth) + dsformat = PIXELFORMAT_DEPTH16; + else if (wantsstencil) + dsformat = PIXELFORMAT_STENCIL8; + + // We want setCanvasInternal to have a pointer to the temporary RT, but + // we don't want to directly store it in the main graphics state. + RenderTargets realRTs = rts; + + realRTs.depthStencil.canvas = getTemporaryCanvas(dsformat, pixelw, pixelh, reqmsaa); + realRTs.depthStencil.slice = 0; + + setCanvasInternal(realRTs, w, h, pixelw, pixelh, hasSRGBcanvas); + } + else + setCanvasInternal(rts, w, h, pixelw, pixelh, hasSRGBcanvas); RenderTargetsStrongRef refs; refs.colors.reserve(rts.colors.size()); diff --git a/love/src/jni/love/src/modules/graphics/Graphics.h b/love/src/jni/love/src/modules/graphics/Graphics.h index 439caa5b..3586f9c1 100644 --- a/love/src/jni/love/src/modules/graphics/Graphics.h +++ b/love/src/jni/love/src/modules/graphics/Graphics.h @@ -422,6 +422,24 @@ public: { return colors.empty() ? depthStencil : colors[0]; } + + bool operator == (const RenderTargets &other) const + { + size_t ncolors = colors.size(); + if (ncolors != other.colors.size()) + return false; + + for (size_t i = 0; i < ncolors; i++) + { + if (colors[i] != other.colors[i]) + return false; + } + + if (depthStencil != other.depthStencil || temporaryRTFlags != other.temporaryRTFlags) + return false; + + return true; + } }; struct RenderTargetsStrongRef diff --git a/love/src/jni/love/src/modules/graphics/opengl/Canvas.cpp b/love/src/jni/love/src/modules/graphics/opengl/Canvas.cpp index af6eda7e..221a3e34 100644 --- a/love/src/jni/love/src/modules/graphics/opengl/Canvas.cpp +++ b/love/src/jni/love/src/modules/graphics/opengl/Canvas.cpp @@ -20,6 +20,7 @@ #include "Canvas.h" #include "graphics/Graphics.h" +#include "Graphics.h" #include // For min/max @@ -270,6 +271,15 @@ bool Canvas::loadVolatile() void Canvas::unloadVolatile() { + if (fbo != 0 || renderbuffer != 0 || texture != 0) + { + // This is a bit ugly, but we need some way to destroy the cached FBO + // when this Canvas' texture is destroyed. + auto gfx = Module::getInstance(Module::M_GRAPHICS); + if (gfx != nullptr) + gfx->cleanupCanvas(this); + } + if (fbo != 0) gl.deleteFramebuffer(fbo); @@ -503,6 +513,18 @@ bool Canvas::isFormatSupported(PixelFormat format, bool readable) GLuint texture = 0; GLuint renderbuffer = 0; + // Avoid the test for depth/stencil formats - not every GL version + // guarantees support for depth/stencil-only render targets (which we would + // need for the test below to work), and we already do some finagling in + // convertPixelFormat to try to use the best-supported internal + // depth/stencil format for a particular driver. + if (isPixelFormatDepthStencil(format)) + { + checkedFormats[format].set(readable, true); + supportedFormats[format].set(readable, true); + return true; + } + bool unusedSRGB = false; OpenGL::TextureFormat fmt = OpenGL::convertPixelFormat(format, readable, unusedSRGB); diff --git a/love/src/jni/love/src/modules/graphics/opengl/Graphics.cpp b/love/src/jni/love/src/modules/graphics/opengl/Graphics.cpp index f528c20c..03481ae4 100644 --- a/love/src/jni/love/src/modules/graphics/opengl/Graphics.cpp +++ b/love/src/jni/love/src/modules/graphics/opengl/Graphics.cpp @@ -642,7 +642,7 @@ void Graphics::clear(const std::vector &colors, OptionalInt sten return; int ncolorcanvases = (int) states.back().renderTargets.colors.size(); - int ncolors = std::min((int) colors.size(), ncolorcanvases); + int ncolors = (int) colors.size(); if (ncolors <= 1 && ncolorcanvases <= 1) { @@ -653,6 +653,7 @@ void Graphics::clear(const std::vector &colors, OptionalInt sten flushStreamDraws(); bool drawbuffersmodified = false; + ncolors = std::min(ncolors, ncolorcanvases); for (int i = 0; i < ncolors; i++) { @@ -779,21 +780,38 @@ void Graphics::discard(OpenGL::FramebufferTarget target, const std::vector glDiscardFramebufferEXT(gltarget, (GLint) attachments.size(), &attachments[0]); } +void Graphics::cleanupCanvas(Canvas *canvas) +{ + for (auto it = framebufferObjects.begin(); it != framebufferObjects.end(); /**/) + { + bool hascanvas = false; + const auto &rts = it->first; + + for (const RenderTarget &rt : rts.colors) + { + if (rt.canvas == canvas) + { + hascanvas = true; + break; + } + } + + hascanvas = hascanvas || rts.depthStencil.canvas == canvas; + + if (hascanvas) + { + if (isCreated()) + gl.deleteFramebuffer(it->second); + it = framebufferObjects.erase(it); + } + else + ++it; + } +} + void Graphics::bindCachedFBO(const RenderTargets &targets) { - RenderTarget hashtargets[MAX_COLOR_RENDER_TARGETS + 1]; - int hashcount = 0; - - for (int i = 0; i < (int) targets.colors.size(); i++) - hashtargets[hashcount++] = targets.colors[i]; - - if (targets.depthStencil.canvas != nullptr) - hashtargets[hashcount++] = targets.depthStencil; - else if (targets.temporaryRTFlags != 0) - hashtargets[hashcount++] = RenderTarget(nullptr, -1, targets.temporaryRTFlags); - - uint32 hash = XXH32(hashtargets, sizeof(RenderTarget) * hashcount, 0); - GLuint fbo = framebufferObjects[hash]; + GLuint fbo = framebufferObjects[targets]; if (fbo != 0) { @@ -801,34 +819,7 @@ void Graphics::bindCachedFBO(const RenderTargets &targets) } else { - RenderTarget firstRT = targets.getFirstTarget(); - - int mip = firstRT.mipmap; - int w = firstRT.canvas->getPixelWidth(mip); - int h = firstRT.canvas->getPixelHeight(mip); - int msaa = firstRT.canvas->getMSAA(); - int reqmsaa = firstRT.canvas->getRequestedMSAA(); - - RenderTarget depthstencil = targets.depthStencil; - - if (depthstencil.canvas == nullptr && targets.temporaryRTFlags != 0) - { - bool wantsdepth = (targets.temporaryRTFlags & TEMPORARY_RT_DEPTH) != 0; - bool wantsstencil = (targets.temporaryRTFlags & TEMPORARY_RT_STENCIL) != 0; - - PixelFormat dsformat = PIXELFORMAT_STENCIL8; - if (wantsdepth && wantsstencil) - dsformat = PIXELFORMAT_DEPTH24_STENCIL8; - else if (wantsdepth && isCanvasFormatSupported(PIXELFORMAT_DEPTH24, false)) - dsformat = PIXELFORMAT_DEPTH24; - else if (wantsdepth) - dsformat = PIXELFORMAT_DEPTH16; - else if (wantsstencil) - dsformat = PIXELFORMAT_STENCIL8; - - depthstencil.canvas = getTemporaryCanvas(dsformat, w, h, reqmsaa); - depthstencil.slice = 0; - } + int msaa = targets.getFirstTarget().canvas->getMSAA(); glGenFramebuffers(1, &fbo); gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, fbo); @@ -873,8 +864,8 @@ void Graphics::bindCachedFBO(const RenderTargets &targets) for (const auto &rt : targets.colors) attachCanvas(rt); - if (depthstencil.canvas != nullptr) - attachCanvas(depthstencil); + if (targets.depthStencil.canvas != nullptr) + attachCanvas(targets.depthStencil); if (ncolortargets > 1) glDrawBuffers(ncolortargets, drawbuffers); @@ -887,8 +878,8 @@ void Graphics::bindCachedFBO(const RenderTargets &targets) const char *sstr = OpenGL::framebufferStatusString(status); throw love::Exception("Could not create Framebuffer Object! %s", sstr); } - - framebufferObjects[hash] = fbo; + + framebufferObjects[targets] = fbo; } } diff --git a/love/src/jni/love/src/modules/graphics/opengl/Graphics.h b/love/src/jni/love/src/modules/graphics/opengl/Graphics.h index 33888874..2ca43a33 100644 --- a/love/src/jni/love/src/modules/graphics/opengl/Graphics.h +++ b/love/src/jni/love/src/modules/graphics/opengl/Graphics.h @@ -40,6 +40,8 @@ #include "Canvas.h" #include "Shader.h" +#include "libraries/xxHash/xxhash.h" + namespace love { @@ -110,8 +112,30 @@ public: Shader::Language getShaderLanguageTarget() const override; + // Internal use. + void cleanupCanvas(Canvas *canvas); + private: + struct CachedFBOHasher + { + size_t operator() (const RenderTargets &rts) const + { + RenderTarget hashtargets[MAX_COLOR_RENDER_TARGETS + 1]; + int hashcount = 0; + + for (size_t i = 0; i < rts.colors.size(); i++) + hashtargets[hashcount++] = rts.colors[i]; + + if (rts.depthStencil.canvas != nullptr) + hashtargets[hashcount++] = rts.depthStencil; + else if (rts.temporaryRTFlags != 0) + hashtargets[hashcount++] = RenderTarget(nullptr, -1, rts.temporaryRTFlags); + + return XXH32(hashtargets, sizeof(RenderTarget) * hashcount, 0); + } + }; + love::graphics::ShaderStage *newShaderStageInternal(ShaderStage::StageType stage, const std::string &cachekey, const std::string &source, bool gles) override; love::graphics::Shader *newShaderInternal(love::graphics::ShaderStage *vertex, love::graphics::ShaderStage *pixel) override; love::graphics::StreamBuffer *newStreamBuffer(BufferType type, size_t size) override; @@ -125,7 +149,7 @@ private: void setDebug(bool enable); - std::unordered_map framebufferObjects; + std::unordered_map framebufferObjects; bool windowHasStencil; GLuint mainVAO; diff --git a/love/src/jni/love/src/modules/graphics/opengl/OpenGL.cpp b/love/src/jni/love/src/modules/graphics/opengl/OpenGL.cpp index edded237..7c12de62 100644 --- a/love/src/jni/love/src/modules/graphics/opengl/OpenGL.cpp +++ b/love/src/jni/love/src/modules/graphics/opengl/OpenGL.cpp @@ -705,7 +705,7 @@ void OpenGL::setVertexAttributes(const vertex::Attributes &attributes, const ver GLboolean normalized = GL_FALSE; GLenum gltype = getGLVertexDataType(attrib.type, normalized); - const void *offsetpointer = BUFFER_OFFSET(bufferinfo.offset + attrib.offsetfromvertex); + const void *offsetpointer = reinterpret_cast(bufferinfo.offset + attrib.offsetfromvertex); bindBuffer(BUFFER_VERTEX, (GLuint) bufferinfo.buffer->getHandle()); glVertexAttribPointer(i, attrib.components, gltype, normalized, attrib.stride, offsetpointer); diff --git a/love/src/jni/love/src/modules/joystick/wrap_JoystickModule.cpp b/love/src/jni/love/src/modules/joystick/wrap_JoystickModule.cpp index 72865a88..7605898f 100644 --- a/love/src/jni/love/src/modules/joystick/wrap_JoystickModule.cpp +++ b/love/src/jni/love/src/modules/joystick/wrap_JoystickModule.cpp @@ -21,6 +21,7 @@ #include "wrap_JoystickModule.h" #include "wrap_Joystick.h" +#include "filesystem/Filesystem.h" #include "filesystem/wrap_Filesystem.h" #include "sdl/JoystickModule.h" @@ -116,15 +117,15 @@ int w_setGamepadMapping(lua_State *L) int w_loadGamepadMappings(lua_State *L) { - bool isfile = true; - std::string mappings; + bool isfile = false; + std::string mappings = luax_checkstring(L, 1); - if (lua_isstring(L, 1)) + auto fs = Module::getInstance(Module::M_FILESYSTEM); + if (fs) { - lua_pushvalue(L, 1); - luax_convobj(L, -1, "filesystem", "isFile"); - isfile = luax_toboolean(L, -1); - lua_pop(L, 1); + love::filesystem::Filesystem::Info info = {}; + bool exists = fs->getInfo(mappings.c_str(), info); + isfile = exists && info.type == love::filesystem::Filesystem::FILETYPE_FILE; } if (isfile) @@ -132,7 +133,6 @@ int w_loadGamepadMappings(lua_State *L) love::filesystem::FileData *fd = love::filesystem::luax_getfiledata(L, 1); mappings = std::string((const char *) fd->getData(), fd->getSize()); fd->release(); - } else mappings = luax_checkstring(L, 1); diff --git a/love/src/jni/love/src/modules/love/love.cpp b/love/src/jni/love/src/modules/love/love.cpp index 14a6756f..89b5ac0a 100644 --- a/love/src/jni/love/src/modules/love/love.cpp +++ b/love/src/jni/love/src/modules/love/love.cpp @@ -439,22 +439,6 @@ int luaopen_love(lua_State *L) #ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK -// Mostly taken from the Windows 8.1 SDK's VersionHelpers.h. -static bool IsWindowsVistaOrGreater() -{ - OSVERSIONINFOEXW osvi = {sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0}; - - osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_VISTA); - osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_VISTA); - osvi.wServicePackMajor = 0; - - DWORDLONG majorversionmask = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL); - DWORDLONG versionmask = VerSetConditionMask(majorversionmask, VER_MINORVERSION, VER_GREATER_EQUAL); - DWORDLONG mask = VerSetConditionMask(versionmask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); - - return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, mask) != FALSE; -} - bool love_openConsole(const char *&err) { static bool is_open = false; @@ -465,11 +449,18 @@ bool love_openConsole(const char *&err) is_open = true; - // FIXME: we don't call AttachConsole in Windows XP because it seems to - // break later AllocConsole calls if it fails. A better workaround might be - // possible, but it's hard to find a WinXP system to test on these days... - if (!IsWindowsVistaOrGreater() || !AttachConsole(ATTACH_PARENT_PROCESS)) + if (!AttachConsole(ATTACH_PARENT_PROCESS)) { + DWORD winerr = GetLastError(); + + if (winerr == ERROR_ACCESS_DENIED) + { + // The process is already attached to a console. We'll assume stdout + // and friends are already being directed there. + is_open = true; + return is_open; + } + // Create our own console if we can't attach to an existing one. if (!AllocConsole()) { diff --git a/love/src/jni/love/src/modules/physics/box2d/ChainShape.cpp b/love/src/jni/love/src/modules/physics/box2d/ChainShape.cpp index 476d01f2..4c1b5462 100644 --- a/love/src/jni/love/src/modules/physics/box2d/ChainShape.cpp +++ b/love/src/jni/love/src/modules/physics/box2d/ChainShape.cpp @@ -36,8 +36,8 @@ namespace box2d love::Type ChainShape::type("ChainShape", &Shape::type); -ChainShape::ChainShape(b2ChainShape *c, bool loop, bool own) - : Shape(c, own), loop(loop) +ChainShape::ChainShape(b2ChainShape *c, bool own) + : Shape(c, own) { } @@ -47,11 +47,6 @@ ChainShape::~ChainShape() void ChainShape::setNextVertex(float x, float y) { - if (loop) - { - throw love::Exception("Physics error: Can't call setNextVertex on a loop ChainShape"); - return; - } b2Vec2 v(x, y); b2ChainShape *c = (b2ChainShape *)shape; c->SetNextVertex(Physics::scaleDown(v)); @@ -65,11 +60,6 @@ void ChainShape::setNextVertex() void ChainShape::setPreviousVertex(float x, float y) { - if (loop) - { - throw love::Exception("Physics error: Can't call setPreviousVertex on a loop ChainShape"); - return; - } b2Vec2 v(x, y); b2ChainShape *c = (b2ChainShape *)shape; c->SetPrevVertex(Physics::scaleDown(v)); diff --git a/love/src/jni/love/src/modules/physics/box2d/ChainShape.h b/love/src/jni/love/src/modules/physics/box2d/ChainShape.h index d51441d7..98e264eb 100644 --- a/love/src/jni/love/src/modules/physics/box2d/ChainShape.h +++ b/love/src/jni/love/src/modules/physics/box2d/ChainShape.h @@ -45,7 +45,7 @@ public: * Create a new ChainShape from a Box2D chain shape. * @param c The chain shape. **/ - ChainShape(b2ChainShape *c, bool loop = false, bool own = true); + ChainShape(b2ChainShape *c, bool own = true); virtual ~ChainShape(); @@ -103,9 +103,6 @@ public: **/ const b2Vec2 *getPoints() const; -private: - // True if this ChainShape is a loop. - bool loop; }; } // box2d diff --git a/love/src/jni/love/src/modules/window/sdl/Window.cpp b/love/src/jni/love/src/modules/window/sdl/Window.cpp index 6672947a..f175feef 100644 --- a/love/src/jni/love/src/modules/window/sdl/Window.cpp +++ b/love/src/jni/love/src/modules/window/sdl/Window.cpp @@ -77,7 +77,7 @@ Window::Window() Window::~Window() { - close(); + close(false); graphics.set(nullptr); @@ -413,7 +413,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings) graphics.set(Module::getInstance(Module::M_GRAPHICS)); if (graphics.get() && graphics->isCanvasActive()) - throw love::Exception("setMode cannot be called while a Canvas is active in love.graphics."); + throw love::Exception("love.window.setMode cannot be called while a Canvas is active in love.graphics."); WindowSettings f; @@ -640,11 +640,16 @@ void Window::getWindow(int &width, int &height, WindowSettings &newsettings) } void Window::close() +{ + close(true); +} + +void Window::close(bool allowExceptions) { if (graphics.get()) { - if (graphics->isCanvasActive()) - throw love::Exception("close cannot be called while a Canvas is active in love.graphics."); + if (allowExceptions && graphics->isCanvasActive()) + throw love::Exception("love.window.close cannot be called while a Canvas is active in love.graphics."); graphics->unSetMode(); } @@ -674,7 +679,7 @@ bool Window::setFullscreen(bool fullscreen, Window::FullscreenType fstype) return false; if (graphics.get() && graphics->isCanvasActive()) - throw love::Exception("setFullscreen cannot be called while a Canvas is active in love.graphics."); + throw love::Exception("love.window.setFullscreen cannot be called while a Canvas is active in love.graphics."); WindowSettings newsettings = settings; newsettings.fullscreen = fullscreen; diff --git a/love/src/jni/love/src/modules/window/sdl/Window.h b/love/src/jni/love/src/modules/window/sdl/Window.h index ec643e22..0ed8bc5d 100644 --- a/love/src/jni/love/src/modules/window/sdl/Window.h +++ b/love/src/jni/love/src/modules/window/sdl/Window.h @@ -121,6 +121,8 @@ public: private: + void close(bool allowExceptions); + struct ContextAttribs { int versionMajor;