Merge branch '12.0-development' into metal

This commit is contained in:
Alex Szpakowski
2020-02-28 23:21:08 -04:00
58 changed files with 26065 additions and 6331 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ LOCAL_SRC_FILES := \
))
LOCAL_CXXFLAGS := -std=c++11
LOCAL_SHARED_LIBRARIES := libopenal libmpg123
LOCAL_SHARED_LIBRARIES := libopenal
LOCAL_STATIC_LIBRARIES := libvorbis libogg libtheora libmodplug libfreetype libluajit SDL2_static
# $(info liblove: include dirs $(LOCAL_C_INCLUDES))
+13 -37
View File
@@ -49,7 +49,6 @@ else()
endif()
option(LOVE_JIT "Use LuaJIT" TRUE)
option(LOVE_MPG123 "Use mpg123" TRUE)
if(LOVE_JIT)
if(APPLE)
@@ -60,10 +59,6 @@ else()
message(STATUS "LuaJIT: Disabled")
endif()
if(NOT LOVE_MPG123)
add_definitions(-DLOVE_NOMPG123)
endif()
message(STATUS "Target platform: ${LOVE_TARGET_PLATFORM}")
if(POLICY CMP0072)
@@ -118,17 +113,6 @@ if(MEGA)
${MEGA_OPENAL}
)
if(LOVE_MPG123)
set(LOVE_LINK_LIBRARIES
${LOVE_LINK_LIBRARIES}
${MEGA_MPEG123}
)
set(LOVE_MOVE_DLLS
${LOVE_MOVE_DLLS}
${MEGA_MPEG123}
)
endif()
if(LOVE_JIT)
set(LOVE_LUA_LIBRARY ${MEGA_LUAJIT_LIB})
# LOVE_EXTRA_DLLS are non-runtime DLLs which should be bundled with the
@@ -209,18 +193,6 @@ Please see http://bitbucket.org/rude/megasource
${ZLIB_LIBRARY}
)
if(LOVE_MPG123)
find_package(MPG123 REQUIRED)
set(LOVE_LINK_LIBRARIES
${LOVE_LINK_LIBRARIES}
${MPG123_LIBRARY}
)
set(LOVE_INCLUDE_DIRS
${LOVE_INCLUDE_DIRS}
${MPG123_INCLUDE_DIR}
)
endif()
if(LOVE_JIT)
find_package(LuaJIT REQUIRED)
set(LOVE_LUA_LIBRARY ${LUAJIT_LIBRARY})
@@ -911,6 +883,8 @@ set(LOVE_SRC_MODULE_SOUND_LULLABY
src/modules/sound/lullaby/GmeDecoder.h
src/modules/sound/lullaby/ModPlugDecoder.cpp
src/modules/sound/lullaby/ModPlugDecoder.h
src/modules/sound/lullaby/MP3Decoder.h
src/modules/sound/lullaby/MP3Decoder.cpp
src/modules/sound/lullaby/Sound.cpp
src/modules/sound/lullaby/Sound.h
src/modules/sound/lullaby/VorbisDecoder.cpp
@@ -919,14 +893,6 @@ set(LOVE_SRC_MODULE_SOUND_LULLABY
src/modules/sound/lullaby/WaveDecoder.h
)
if(LOVE_MPG123)
set(LOVE_SRC_MODULE_SOUND_LULLABY
${LOVE_SRC_MODULE_SOUND_LULLABY}
src/modules/sound/lullaby/Mpg123Decoder.cpp
src/modules/sound/lullaby/Mpg123Decoder.h
)
endif()
set(LOVE_SRC_MODULE_SOUND
${LOVE_SRC_MODULE_SOUND_ROOT}
${LOVE_SRC_MODULE_SOUND_LULLABY}
@@ -1242,11 +1208,21 @@ add_library(love_3p_ddsparse ${LOVE_SRC_3P_DDSPARSE})
#
set(LOVE_SRC_3P_DRFLAC
src/libraries/dr_flac/dr_flac.h
src/libraries/dr/dr_flac.h
)
# dr_flac has no implementation files of its own.
#
# dr_mp3
#
set(LOVE_SRC_3P_DRMP3
src/libraries/dr/dr_mp3.h
)
# dr_mp3 has no implementation files of its own.
#
# enet
#
-2
View File
@@ -42,7 +42,6 @@ Section "LOVE" MainProg
File "${LOVEBINDIR}\DevIL.dll"
File "${LOVEBINDIR}\SDL.dll"
File "${LOVEBINDIR}\OpenAL32.dll"
File "${LOVEBINDIR}\libmpg123.dll"
File "${LOVEBINDIR}\gme.dll"
# File "${LOVEBINDIR}\lua51.dll"
File "${LOVEICODIR}\love.ico"
@@ -91,7 +90,6 @@ Section "Uninstall"
Delete $INSTDIR\"SDL.dll"
Delete $INSTDIR\"love.exe"
Delete $INSTDIR\"OpenAL32.dll"
Delete $INSTDIR\"libmpg123.dll"
Delete $INSTDIR\"gme.dll"
# Delete $INSTDIR\"lua51.dll"
Delete $INSTDIR\"game.ico"
Binary file not shown.
+7 -15
View File
@@ -75,24 +75,16 @@ This distribution contains code from the following projects (full license text b
- xxHash source repository : https://github.com/Cyan4973/xxHash
- dr_flac
Website: https://github.com/mackron/dr_libs
Source download: https://github.com/mackron/dr_libs/blob/41bc0e8/dr_flac.h
Website: https://mackron.github.io/dr_libs/
Source download: https://github.com/mackron/dr_libs/blob/d705d31/dr_flac.h
License: MIT/Expat
Copyright 2018 David Reid
- libmpg123
Website: http://www.mpg123.de/
Source download: http://sourceforge.net/projects/mpg123/files/latest/download
License: LGPL 2.1
Copyright (c) 1995-2013 by Michael Hipp and others, free software under the terms of the LGPL v2.1
Detailed information from the debian project:
Copyright 1995-2016 by the mpg123 project
Copyright 2009-2011 by Malcolm Boczek
Copyright 2008 Christian Weisgerber <naddy@openbsd.org>
Copyright 2006-2007 by Zuxy Meng
Copyright 2000-2002 David Olofson
Copyright 1998 Fabrice Bellard
Copyright 1997 Mikko Tommila
- dr_mp3
Website: https://mackron.github.io/dr_libs/
Source download: https://github.com/mackron/dr_libs/blob/47fdc9d/dr_mp3.h
License: MIT/Expat
Copyright 2018 David Reid
- OpenAL Soft
Website: http://kcat.strangesoft.net/openal.html
+1 -6
View File
@@ -55,7 +55,6 @@ with_clean_luaversion=`printf ${with_luaversion} | sed 's/\.//g'`
m4_include([configure-modules-pre.ac])
# Other features that can be enabled/disabled
AC_ARG_ENABLE([mpg123], AC_HELP_STRING([--disable-mpg123], [Disable mp3 support, for patent-free builds]), [], [enable_mpg123=yes])
AC_ARG_ENABLE([gme], AC_HELP_STRING([--enable-gme], [Enable GME support, for more chiptuney goodness]), [], [enable_gme=no])
# Dependencies we always use
@@ -71,12 +70,9 @@ AS_VAR_IF([enable_module_font], [yes], [ACLOVE_DEP_FREETYPE2], [])
AS_VAR_IF([enable_module_sound], [yes], [
ACLOVE_DEP_LIBMODPLUG
ACLOVE_DEP_VORBISFILE
], [enable_mpg123=no])
], [])
AS_VAR_IF([enable_module_video], [yes], [ACLOVE_DEP_THEORA], [])
AS_VAR_IF([enable_gme], [yes], [ACLOVE_DEP_GME], [])
AS_VAR_IF([enable_mpg123], [no],
AC_DEFINE([LOVE_NOMPG123], [], [Build without mpg123]),
[ACLOVE_DEP_MPG123])
# Add flags for optional libraries
AC_ARG_ENABLE([library-enet], [ --disable-library-enet Turn off library enet], [], [enable_library_enet=yes])
@@ -117,7 +113,6 @@ AS_VAR_IF([enable_exe], [no], [], #else
AC_DEFINE([LOVE_BUILD_EXE], [], [Skip building launcher]))
AM_CONDITIONAL([LOVE_BUILD_EXE], [test "x$enable_exe" != xno])
AM_CONDITIONAL([LOVE_NOMPG123], [test "x$enable_mpg123" = xno])
AM_CONDITIONAL([LOVE_TARGET_OSX], [test "x$enable_osx" != xno])
# Automatic script file rebuilding
-1
View File
@@ -11,7 +11,6 @@ Build-Depends: debhelper (>= 9),
luajit,
libluajit-5.1-dev,
libmodplug-dev,
libmpg123-dev,
libopenal-dev,
libphysfs-dev,
libsdl2-dev (>= 2.0.1),
-2
View File
@@ -1,5 +1,3 @@
\./libraries/luasocket/libluasocket/wsocket.*
\./love\.cpp
\./modules/sound/lullaby/Mpg123Decoder\.cpp
\./modules/sound/lullaby/Mpg123Decoder\.h
\./libraries/glslang/glslang/OSDependent/Windows
-8
View File
@@ -45,14 +45,6 @@ genmodules()
printf "${FILES:0:${#FILES}-2}\n\n"
modulelist+=("$module")
fi
if [[ "$module" = "sound" ]]; then
printf "if !LOVE_NOMPG123\n"
printf "liblove_module_$module += \\\\\n"
printf "\t./modules/sound/lullaby/Mpg123Decoder.cpp \\\\\n"
printf "\t./modules/sound/lullaby/Mpg123Decoder.h\n"
printf "endif\n\n"
fi
done
cd ../libraries
@@ -389,7 +389,6 @@
FA0B7D211A95902C000E1D17 /* Rasterizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7B7E1A95902C000E1D17 /* Rasterizer.cpp */; };
FA0B7D221A95902C000E1D17 /* Rasterizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7B7E1A95902C000E1D17 /* Rasterizer.cpp */; };
FA0B7D231A95902C000E1D17 /* Rasterizer.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7B7F1A95902C000E1D17 /* Rasterizer.h */; };
FA0B7D241A95902C000E1D17 /* Vera.ttf.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7B801A95902C000E1D17 /* Vera.ttf.h */; };
FA0B7D251A95902C000E1D17 /* wrap_Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7B811A95902C000E1D17 /* wrap_Font.cpp */; };
FA0B7D261A95902C000E1D17 /* wrap_Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7B811A95902C000E1D17 /* wrap_Font.cpp */; };
FA0B7D271A95902C000E1D17 /* wrap_Font.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7B821A95902C000E1D17 /* wrap_Font.h */; };
@@ -682,8 +681,6 @@
FA0B7E911A95902C000E1D17 /* ModPlugDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C861A95902C000E1D17 /* ModPlugDecoder.cpp */; };
FA0B7E921A95902C000E1D17 /* ModPlugDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C861A95902C000E1D17 /* ModPlugDecoder.cpp */; };
FA0B7E931A95902C000E1D17 /* ModPlugDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7C871A95902C000E1D17 /* ModPlugDecoder.h */; };
FA0B7E941A95902C000E1D17 /* Mpg123Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C881A95902C000E1D17 /* Mpg123Decoder.cpp */; };
FA0B7E961A95902C000E1D17 /* Mpg123Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7C891A95902C000E1D17 /* Mpg123Decoder.h */; };
FA0B7E971A95902C000E1D17 /* Sound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C8A1A95902C000E1D17 /* Sound.cpp */; };
FA0B7E981A95902C000E1D17 /* Sound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C8A1A95902C000E1D17 /* Sound.cpp */; };
FA0B7E991A95902C000E1D17 /* Sound.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7C8B1A95902C000E1D17 /* Sound.h */; };
@@ -899,7 +896,6 @@
FA41A3CA1C0A1F950084430C /* ASTCHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = FA41A3C71C0A1F950084430C /* ASTCHandler.h */; };
FA4B66C91ABBCF1900558F15 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA4B66C81ABBCF1900558F15 /* Timer.cpp */; };
FA4B66CA1ABBCF1900558F15 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA4B66C81ABBCF1900558F15 /* Timer.cpp */; };
FA4C22D122C2E11000BFBB7C /* dr_flac.h in Headers */ = {isa = PBXBuildFile; fileRef = FA4C22D022C2E11000BFBB7C /* dr_flac.h */; };
FA4F2B791DE0125B00CA37D7 /* xxhash.c in Sources */ = {isa = PBXBuildFile; fileRef = FA4F2B771DE0125B00CA37D7 /* xxhash.c */; };
FA4F2B7A1DE0125B00CA37D7 /* xxhash.h in Headers */ = {isa = PBXBuildFile; fileRef = FA4F2B781DE0125B00CA37D7 /* xxhash.h */; };
FA4F2B7B1DE0181B00CA37D7 /* xxhash.c in Sources */ = {isa = PBXBuildFile; fileRef = FA4F2B771DE0125B00CA37D7 /* xxhash.c */; };
@@ -939,13 +935,18 @@
FA4F2C121DE936FE00CA37D7 /* unixtcp.c in Sources */ = {isa = PBXBuildFile; fileRef = 217DFBCF1D9F6D490055D849 /* unixtcp.c */; };
FA4F2C131DE936FE00CA37D7 /* unixudp.c in Sources */ = {isa = PBXBuildFile; fileRef = 217DFBD11D9F6D490055D849 /* unixudp.c */; };
FA4F2C141DE936FE00CA37D7 /* usocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 217DFBD51D9F6D490055D849 /* usocket.c */; };
FA522D4D23F9FE380059EE3C /* MP3Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA522D4B23F9FE370059EE3C /* MP3Decoder.cpp */; };
FA522D4E23F9FE380059EE3C /* MP3Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA522D4B23F9FE370059EE3C /* MP3Decoder.cpp */; };
FA522D4F23F9FE380059EE3C /* MP3Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FA522D4C23F9FE380059EE3C /* MP3Decoder.h */; };
FA522D5323F9FF2A0059EE3C /* dr_mp3.h in Headers */ = {isa = PBXBuildFile; fileRef = FA522D5123F9FF2A0059EE3C /* dr_mp3.h */; };
FA522D5423F9FF2A0059EE3C /* dr_flac.h in Headers */ = {isa = PBXBuildFile; fileRef = FA522D5223F9FF2A0059EE3C /* dr_flac.h */; };
FA522D5A23FA5ED50059EE3C /* NotoSans-Regular.ttf.gzip.h in Headers */ = {isa = PBXBuildFile; fileRef = FA522D5923FA5ED40059EE3C /* NotoSans-Regular.ttf.gzip.h */; };
FA56AA381FAFF02000A43D5F /* memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA56AA361FAFF02000A43D5F /* memory.cpp */; };
FA56AA391FAFF02000A43D5F /* memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA56AA361FAFF02000A43D5F /* memory.cpp */; };
FA56AA3A1FAFF02000A43D5F /* memory.h in Headers */ = {isa = PBXBuildFile; fileRef = FA56AA371FAFF02000A43D5F /* memory.h */; };
FA56D9BC1C208A0200D8D3C7 /* libmodplug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA56D9BA1C2089EE00D8D3C7 /* libmodplug.a */; };
FA577AB016C7507900860150 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA577A7916C71A1700860150 /* Cocoa.framework */; };
FA577AC516C7513400860150 /* libmodplug.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA577A8216C71A5300860150 /* libmodplug.framework */; };
FA577AC716C7513A00860150 /* mpg123.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA577A6F16C719F000860150 /* mpg123.framework */; };
FA577AC816C7513C00860150 /* ogg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA577A7116C719F400860150 /* ogg.framework */; };
FA577ACA16C7514100860150 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA577A7C16C71A2600860150 /* OpenGL.framework */; };
FA577ACD16C7514C00860150 /* vorbis.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA577A7716C71A0800860150 /* vorbis.framework */; };
@@ -1588,7 +1589,6 @@
FA0B7B7D1A95902C000E1D17 /* ImageRasterizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageRasterizer.h; sourceTree = "<group>"; };
FA0B7B7E1A95902C000E1D17 /* Rasterizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Rasterizer.cpp; sourceTree = "<group>"; };
FA0B7B7F1A95902C000E1D17 /* Rasterizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Rasterizer.h; sourceTree = "<group>"; };
FA0B7B801A95902C000E1D17 /* Vera.ttf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vera.ttf.h; sourceTree = "<group>"; };
FA0B7B811A95902C000E1D17 /* wrap_Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Font.cpp; sourceTree = "<group>"; };
FA0B7B821A95902C000E1D17 /* wrap_Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Font.h; sourceTree = "<group>"; };
FA0B7B831A95902C000E1D17 /* wrap_GlyphData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_GlyphData.cpp; sourceTree = "<group>"; };
@@ -1785,8 +1785,6 @@
FA0B7C851A95902C000E1D17 /* GmeDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GmeDecoder.h; sourceTree = "<group>"; };
FA0B7C861A95902C000E1D17 /* ModPlugDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModPlugDecoder.cpp; sourceTree = "<group>"; };
FA0B7C871A95902C000E1D17 /* ModPlugDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModPlugDecoder.h; sourceTree = "<group>"; };
FA0B7C881A95902C000E1D17 /* Mpg123Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mpg123Decoder.cpp; sourceTree = "<group>"; };
FA0B7C891A95902C000E1D17 /* Mpg123Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mpg123Decoder.h; sourceTree = "<group>"; };
FA0B7C8A1A95902C000E1D17 /* Sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Sound.cpp; sourceTree = "<group>"; };
FA0B7C8B1A95902C000E1D17 /* Sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sound.h; sourceTree = "<group>"; };
FA0B7C8C1A95902C000E1D17 /* VorbisDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VorbisDecoder.cpp; sourceTree = "<group>"; };
@@ -1942,7 +1940,6 @@
FA41A3C61C0A1F950084430C /* ASTCHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ASTCHandler.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
FA41A3C71C0A1F950084430C /* ASTCHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ASTCHandler.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
FA4B66C81ABBCF1900558F15 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = "<group>"; };
FA4C22D022C2E11000BFBB7C /* dr_flac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dr_flac.h; sourceTree = "<group>"; };
FA4F2B771DE0125B00CA37D7 /* xxhash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xxhash.c; sourceTree = "<group>"; };
FA4F2B781DE0125B00CA37D7 /* xxhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xxhash.h; sourceTree = "<group>"; };
FA4F2BA21DE1E36400CA37D7 /* RecordingDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RecordingDevice.cpp; sourceTree = "<group>"; };
@@ -1957,11 +1954,15 @@
FA4F2BE01DE6650600CA37D7 /* Transform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Transform.h; sourceTree = "<group>"; };
FA4F2BE11DE6650600CA37D7 /* wrap_Transform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Transform.cpp; sourceTree = "<group>"; };
FA4F2BE21DE6650600CA37D7 /* wrap_Transform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Transform.h; sourceTree = "<group>"; };
FA522D4B23F9FE370059EE3C /* MP3Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MP3Decoder.cpp; sourceTree = "<group>"; };
FA522D4C23F9FE380059EE3C /* MP3Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP3Decoder.h; sourceTree = "<group>"; };
FA522D5123F9FF2A0059EE3C /* dr_mp3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dr_mp3.h; sourceTree = "<group>"; };
FA522D5223F9FF2A0059EE3C /* dr_flac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dr_flac.h; sourceTree = "<group>"; };
FA522D5923FA5ED40059EE3C /* NotoSans-Regular.ttf.gzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NotoSans-Regular.ttf.gzip.h"; sourceTree = "<group>"; };
FA56AA361FAFF02000A43D5F /* memory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = memory.cpp; sourceTree = "<group>"; };
FA56AA371FAFF02000A43D5F /* memory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = memory.h; sourceTree = "<group>"; };
FA56D9BA1C2089EE00D8D3C7 /* libmodplug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libmodplug.a; sourceTree = "<group>"; };
FA577A6D16C719EA00860150 /* Lua.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Lua.framework; path = /Library/Frameworks/Lua.framework; sourceTree = "<absolute>"; };
FA577A6F16C719F000860150 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = "<absolute>"; };
FA577A7116C719F400860150 /* ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ogg.framework; path = /Library/Frameworks/ogg.framework; sourceTree = "<absolute>"; };
FA577A7716C71A0800860150 /* vorbis.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = vorbis.framework; path = /Library/Frameworks/vorbis.framework; sourceTree = "<absolute>"; };
FA577A7916C71A1700860150 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
@@ -2239,7 +2240,6 @@
FAD43ECC1FF312D800831BB8 /* freetype.framework in Frameworks */,
FA577AB016C7507900860150 /* Cocoa.framework in Frameworks */,
FA577AC516C7513400860150 /* libmodplug.framework in Frameworks */,
FA577AC716C7513A00860150 /* mpg123.framework in Frameworks */,
FA577AC816C7513C00860150 /* ogg.framework in Frameworks */,
FA577ACA16C7514100860150 /* OpenGL.framework in Frameworks */,
FA577ACD16C7514C00860150 /* vorbis.framework in Frameworks */,
@@ -2359,7 +2359,7 @@
children = (
FA0B794E1A958EA3000E1D17 /* Box2D */,
FA0B79B41A958EA3000E1D17 /* ddsparse */,
FA4C22CF22C2E11000BFBB7C /* dr_flac */,
FA522D5023F9FF2A0059EE3C /* dr */,
FA0B79B81A958EA3000E1D17 /* enet */,
FA0B79D31A958EA3000E1D17 /* glad */,
FAF13FBF1E20934C00F898D2 /* glslang */,
@@ -2897,11 +2897,11 @@
FA0B7B7B1A95902C000E1D17 /* GlyphData.h */,
FA0B7B7C1A95902C000E1D17 /* ImageRasterizer.cpp */,
FA0B7B7D1A95902C000E1D17 /* ImageRasterizer.h */,
FA522D5923FA5ED40059EE3C /* NotoSans-Regular.ttf.gzip.h */,
FA0B7B7E1A95902C000E1D17 /* Rasterizer.cpp */,
FA0B7B7F1A95902C000E1D17 /* Rasterizer.h */,
FAB2D5A81AABDD8A008224A4 /* TrueTypeRasterizer.cpp */,
FAB2D5A91AABDD8A008224A4 /* TrueTypeRasterizer.h */,
FA0B7B801A95902C000E1D17 /* Vera.ttf.h */,
FA0B7B811A95902C000E1D17 /* wrap_Font.cpp */,
FA0B7B821A95902C000E1D17 /* wrap_Font.h */,
FA0B7B831A95902C000E1D17 /* wrap_GlyphData.cpp */,
@@ -3315,8 +3315,8 @@
FA0B7C851A95902C000E1D17 /* GmeDecoder.h */,
FA0B7C861A95902C000E1D17 /* ModPlugDecoder.cpp */,
FA0B7C871A95902C000E1D17 /* ModPlugDecoder.h */,
FA0B7C881A95902C000E1D17 /* Mpg123Decoder.cpp */,
FA0B7C891A95902C000E1D17 /* Mpg123Decoder.h */,
FA522D4B23F9FE370059EE3C /* MP3Decoder.cpp */,
FA522D4C23F9FE380059EE3C /* MP3Decoder.h */,
FA0B7C8A1A95902C000E1D17 /* Sound.cpp */,
FA0B7C8B1A95902C000E1D17 /* Sound.h */,
FA0B7C8C1A95902C000E1D17 /* VorbisDecoder.cpp */,
@@ -3443,7 +3443,6 @@
FA577A8216C71A5300860150 /* libmodplug.framework */,
FA317EB918F28B6D00B0BCD7 /* libz.dylib */,
FA577A6D16C719EA00860150 /* Lua.framework */,
FA577A6F16C719F000860150 /* mpg123.framework */,
FA577A7116C719F400860150 /* ogg.framework */,
FAAFF04316CB11C700CCDE45 /* OpenAL-Soft.framework */,
FA577A7C16C71A2600860150 /* OpenGL.framework */,
@@ -3568,14 +3567,6 @@
path = theora;
sourceTree = "<group>";
};
FA4C22CF22C2E11000BFBB7C /* dr_flac */ = {
isa = PBXGroup;
children = (
FA4C22D022C2E11000BFBB7C /* dr_flac.h */,
);
path = dr_flac;
sourceTree = "<group>";
};
FA4F2B761DE0125B00CA37D7 /* xxHash */ = {
isa = PBXGroup;
children = (
@@ -3585,6 +3576,15 @@
path = xxHash;
sourceTree = "<group>";
};
FA522D5023F9FF2A0059EE3C /* dr */ = {
isa = PBXGroup;
children = (
FA522D5123F9FF2A0059EE3C /* dr_mp3.h */,
FA522D5223F9FF2A0059EE3C /* dr_flac.h */,
);
path = dr;
sourceTree = "<group>";
};
FA56D9B91C2089CE00D8D3C7 /* modplug */ = {
isa = PBXGroup;
children = (
@@ -3990,7 +3990,6 @@
FA0B7DC61A95902C000E1D17 /* wrap_JoystickModule.h in Headers */,
FA0B7D201A95902C000E1D17 /* ImageRasterizer.h in Headers */,
FAF6C9EA23C2DE2900D7B5BC /* GLSL.ext.NV.h in Headers */,
FA0B7D241A95902C000E1D17 /* Vera.ttf.h in Headers */,
FADF54311E3DABF600012CC0 /* SpriteBatch.h in Headers */,
FA0B7E5F1A95902C000E1D17 /* wrap_MouseJoint.h in Headers */,
217DFC0C1D9F6D490055D849 /* unixtcp.h in Headers */,
@@ -4055,6 +4054,7 @@
FAF6C9E523C2DE2900D7B5BC /* spirv.hpp in Headers */,
FA18CF1F23DCF67900263725 /* image.hpp in Headers */,
FA0B7A541A958EA3000E1D17 /* b2Math.h in Headers */,
FA522D4F23F9FE380059EE3C /* MP3Decoder.h in Headers */,
217DFBEE1D9F6D490055D849 /* luasocket.h in Headers */,
FACA02F31F5E396B0084B28F /* HashFunction.h in Headers */,
FA0B7ED01A95902C000E1D17 /* wrap_LuaThread.h in Headers */,
@@ -4086,6 +4086,7 @@
FA0B7CE71A95902C000E1D17 /* wrap_Source.h in Headers */,
FA0B7B231A958EA3000E1D17 /* luasocket.h in Headers */,
FA0B7D1D1A95902C000E1D17 /* GlyphData.h in Headers */,
FA522D5A23FA5ED50059EE3C /* NotoSans-Regular.ttf.gzip.h in Headers */,
FAC7CD8E1FE35E95006A60C7 /* physfs_lzmasdk.h in Headers */,
FA0B7B391A958EA3000E1D17 /* wuff_internal.h in Headers */,
FAC7CD771FE35E95006A60C7 /* physfs_internal.h in Headers */,
@@ -4181,10 +4182,10 @@
FA4F2BAD1DE1E37000CA37D7 /* RecordingDevice.h in Headers */,
FA0B792B1A958E3B000E1D17 /* Matrix.h in Headers */,
FA0B7DA41A95902C000E1D17 /* PKMHandler.h in Headers */,
FA4C22D122C2E11000BFBB7C /* dr_flac.h in Headers */,
FAF6C9E423C2DE2900D7B5BC /* doc.h in Headers */,
FA0B7AC81A958EA3000E1D17 /* utility.h in Headers */,
217DFC0E1D9F6D490055D849 /* unixudp.h in Headers */,
FA522D5323F9FF2A0059EE3C /* dr_mp3.h in Headers */,
FA0B791F1A958E3B000E1D17 /* Data.h in Headers */,
FA18CF4523DD1A8100263725 /* ShaderStage.h in Headers */,
217DFBE41D9F6D490055D849 /* headers.lua.h in Headers */,
@@ -4200,7 +4201,6 @@
FA93C4531F315B960087CCD4 /* FormatHandler.h in Headers */,
FA0B7CD81A95902C000E1D17 /* Audio.h in Headers */,
FA0B7CF61A95902C000E1D17 /* File.h in Headers */,
FA0B7E961A95902C000E1D17 /* Mpg123Decoder.h in Headers */,
FA18CF2123DCF67900263725 /* spirv.hpp in Headers */,
FA0A3A5F23366CE9001C269E /* floattypes.h in Headers */,
FADF54091E3D78F700012CC0 /* Video.h in Headers */,
@@ -4225,6 +4225,7 @@
FA0B7DFF1A95902C000E1D17 /* ChainShape.h in Headers */,
FA18CEE023DBC6E000263725 /* StreamBuffer.h in Headers */,
FA0B7E4D1A95902C000E1D17 /* wrap_EdgeShape.h in Headers */,
FA522D5423F9FF2A0059EE3C /* dr_flac.h in Headers */,
FAF1405F1E20934C00F898D2 /* ResourceLimits.h in Headers */,
FA0B7DDB1A95902C000E1D17 /* RandomGenerator.h in Headers */,
FA0B7E841A95902C000E1D17 /* Decoder.h in Headers */,
@@ -4807,6 +4808,7 @@
FA0B7D311A95902C000E1D17 /* Graphics.cpp in Sources */,
FA0B7E9E1A95902C000E1D17 /* WaveDecoder.cpp in Sources */,
FA0B7EB31A95902C000E1D17 /* System.cpp in Sources */,
FA522D4E23F9FE380059EE3C /* MP3Decoder.cpp in Sources */,
FA0B7D1C1A95902C000E1D17 /* GlyphData.cpp in Sources */,
FA4F2C061DE936CD00CA37D7 /* except.c in Sources */,
FA0B7AAE1A958EA3000E1D17 /* b2WheelJoint.cpp in Sources */,
@@ -5187,7 +5189,6 @@
FA0B7AD41A958EA3000E1D17 /* unix.c in Sources */,
FA0B7A771A958EA3000E1D17 /* b2CircleContact.cpp in Sources */,
FADF543B1E3DAFF700012CC0 /* wrap_Graphics.cpp in Sources */,
FA0B7E941A95902C000E1D17 /* Mpg123Decoder.cpp in Sources */,
FA0B7E8B1A95902C000E1D17 /* FLACDecoder.cpp in Sources */,
FA0B7B3A1A958EA3000E1D17 /* wuff_memory.c in Sources */,
FA0B7A381A958EA3000E1D17 /* b2DynamicTree.cpp in Sources */,
@@ -5224,6 +5225,7 @@
FA0B7EB21A95902C000E1D17 /* System.cpp in Sources */,
FA0B7D1B1A95902C000E1D17 /* GlyphData.cpp in Sources */,
FA0B7AD11A958EA3000E1D17 /* protocol.c in Sources */,
FA522D4D23F9FE380059EE3C /* MP3Decoder.cpp in Sources */,
FA9D8DD11DEB56C3002CD881 /* pixelformat.cpp in Sources */,
FA0B7E661A95902C000E1D17 /* wrap_PrismaticJoint.cpp in Sources */,
FA0B7DCD1A95902C000E1D17 /* wrap_Keyboard.cpp in Sources */,
@@ -5453,7 +5455,6 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
LOVE_SUPPORT_COREAUDIO,
LOVE_NOMPG123,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
@@ -5495,7 +5496,6 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
LOVE_SUPPORT_COREAUDIO,
LOVE_NOMPG123,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
HEADER_SEARCH_PATHS = (
@@ -5537,7 +5537,6 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
LOVE_SUPPORT_COREAUDIO,
LOVE_NOMPG123,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
HEADER_SEARCH_PATHS = (
@@ -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 */; };
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 */; };
FA0797991BF480A200034B7C /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA0797981BF480A200034B7C /* GameController.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
@@ -87,7 +86,6 @@
FAD4B1731C1F50A3004CF150 /* theora.framework in Copy Frameworks */,
FAAFF04716CB120000CCDE45 /* OpenAL-Soft.framework in Copy Frameworks */,
FAD43ED01FF3136500831BB8 /* freetype.framework in Copy Frameworks */,
A9F169AC109E825000FC83D1 /* mpg123.framework in Copy Frameworks */,
A9F169AD109E825000FC83D1 /* libmodplug.framework in Copy Frameworks */,
A9255F58104324E100BA1496 /* ogg.framework in Copy Frameworks */,
A9255E031043195A00BA1496 /* vorbis.framework in Copy Frameworks */,
@@ -108,7 +106,6 @@
A93E6E5310420B57007D418B /* Lua.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Lua.framework; path = /Library/Frameworks/Lua.framework; sourceTree = "<absolute>"; };
A97E3842132A9EDE00198A2F /* love-macosx.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "love-macosx.plist"; path = "macosx/love-macosx.plist"; sourceTree = "<group>"; };
A9F16926109E7BAD00FC83D1 /* libmodplug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libmodplug.framework; path = /Library/Frameworks/libmodplug.framework; sourceTree = "<absolute>"; };
A9F169A6109E824900FC83D1 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = "<absolute>"; };
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; };
FA0797981BF480A200034B7C /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; };
FA08F69116C765A200F007B5 /* love.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = love.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -235,7 +232,6 @@
A9F16926109E7BAD00FC83D1 /* libmodplug.framework */,
FA08F69116C765A200F007B5 /* love.framework */,
A93E6E5310420B57007D418B /* Lua.framework */,
A9F169A6109E824900FC83D1 /* mpg123.framework */,
A9255F51104324D700BA1496 /* ogg.framework */,
FAAFF04616CB120000CCDE45 /* OpenAL-Soft.framework */,
A93E6E4710420B4A007D418B /* OpenGL.framework */,
+1 -1
View File
@@ -1,6 +1,7 @@
LÖVE is an *awesome* framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, Mac OS X, Linux, Android, and iOS.
[![Build Status: Windows](https://ci.appveyor.com/api/projects/status/chc0hdr08wv1d5c7?svg=true)](https://ci.appveyor.com/project/AlexSzpakowski/love)
[![Build Status: Github CI](https://github.com/love2d/love/workflows/continuous-integration/badge.svg)](https://github.com/love2d/love/actions?query=workflow%3Acontinuous-integration)
Documentation
-------------
@@ -77,7 +78,6 @@ Dependencies
- Lua / LuaJIT / LLVM-lua
- FreeType
- ModPlug
- mpg123
- Vorbisfile
- Theora
+14
View File
@@ -78,6 +78,20 @@ private:
}; // Object
/**
* Structure wrapping an object and its associated Type instance. This is used
* for storing everything necessary to identify an object's properties in
* environments where the Type is not easily obtained otherwise, for example in
* a Lua state.
**/
struct Proxy
{
// Holds type information (see types.h).
love::Type *type;
// Pointer to the actual object.
Object *object;
};
enum class Acquire
{
+4 -153
View File
@@ -26,25 +26,13 @@
namespace love
{
static Proxy *tryextractproxy(lua_State *L, int idx)
{
Proxy *u = (Proxy *)lua_touserdata(L, idx);
if (u == nullptr || u->type == nullptr)
return nullptr;
// We could get rid of the dynamic_cast for more performance, but it would
// be less safe...
if (dynamic_cast<Object *>(u->object) != nullptr)
return u;
return nullptr;
}
Variant::Variant(Type vtype)
: type(vtype)
{}
Variant::Variant()
: type(NIL)
{
}
{}
Variant::Variant(bool boolean)
: type(BOOLEAN)
@@ -152,141 +140,4 @@ Variant &Variant::operator = (const Variant &v)
return *this;
}
Variant Variant::fromLua(lua_State *L, int n, bool allowuserdata, std::set<const void*> *tableSet)
{
size_t len;
const char *str;
Proxy *p = nullptr;
if (n < 0) // Fix the stack position, we might modify it later
n += lua_gettop(L) + 1;
switch (lua_type(L, n))
{
case LUA_TBOOLEAN:
return Variant(luax_toboolean(L, n));
case LUA_TNUMBER:
return Variant(lua_tonumber(L, n));
case LUA_TSTRING:
str = lua_tolstring(L, n, &len);
return Variant(str, len);
case LUA_TLIGHTUSERDATA:
return Variant(lua_touserdata(L, n));
case LUA_TUSERDATA:
if (!allowuserdata)
{
luax_typerror(L, n, "copyable Lua value");
return Variant();
}
p = tryextractproxy(L, n);
if (p != nullptr)
return Variant(p->type, p->object);
else
{
luax_typerror(L, n, "love type");
return Variant();
}
case LUA_TNIL:
return Variant();
case LUA_TTABLE:
{
bool success = true;
std::set<const void *> topTableSet;
// We can use a pointer to a stack-allocated variable because it's
// never used after the stack-allocated variable is destroyed.
if (tableSet == nullptr)
tableSet = &topTableSet;
// Now make sure this table wasn't already serialised
const void *tablePointer = lua_topointer(L, n);
{
auto result = tableSet->insert(tablePointer);
if (!result.second) // insertion failed
throw love::Exception("Cycle detected in table");
}
SharedTable *table = new SharedTable();
size_t len = luax_objlen(L, -1);
if (len > 0)
table->pairs.reserve(len);
lua_pushnil(L);
while (lua_next(L, n))
{
table->pairs.emplace_back(fromLua(L, -2, allowuserdata, tableSet), fromLua(L, -1, allowuserdata, tableSet));
lua_pop(L, 1);
const auto &p = table->pairs.back();
if (p.first.getType() == UNKNOWN || p.second.getType() == UNKNOWN)
{
success = false;
break;
}
}
// And remove the table from the set again
tableSet->erase(tablePointer);
if (success)
return Variant(table);
else
table->release();
}
break;
}
Variant v;
v.type = UNKNOWN;
return v;
}
void Variant::toLua(lua_State *L) const
{
switch (type)
{
case BOOLEAN:
lua_pushboolean(L, data.boolean);
break;
case NUMBER:
lua_pushnumber(L, data.number);
break;
case STRING:
lua_pushlstring(L, data.string->str, data.string->len);
break;
case SMALLSTRING:
lua_pushlstring(L, data.smallstring.str, data.smallstring.len);
break;
case LUSERDATA:
lua_pushlightuserdata(L, data.userdata);
break;
case LOVEOBJECT:
luax_pushtype(L, *data.objectproxy.type, data.objectproxy.object);
break;
case TABLE:
{
std::vector<std::pair<Variant, Variant>> &table = data.table->pairs;
int tsize = (int) table.size();
lua_createtable(L, 0, tsize);
for (int i = 0; i < tsize; ++i)
{
std::pair<Variant, Variant> &kv = table[i];
kv.first.toLua(L);
kv.second.toLua(L);
lua_settable(L, -3);
}
break;
}
case NIL:
default:
lua_pushnil(L);
break;
}
}
} // love
+3 -4
View File
@@ -22,14 +22,12 @@
#define LOVE_VARIANT_H
#include "common/config.h"
#include "common/runtime.h"
#include "common/Object.h"
#include "common/int.h"
#include <cstring>
#include <string>
#include <vector>
#include <set>
namespace love
{
@@ -112,11 +110,12 @@ public:
Type getType() const { return type; }
const Data &getData() const { return data; }
static Variant fromLua(lua_State *L, int n, bool allowuserdata = true, std::set<const void*> *tableSet = nullptr);
void toLua(lua_State *L) const;
static Variant unknown() { return Variant(UNKNOWN); }
private:
Variant(Type vtype);
Type type;
Data data;
-1
View File
@@ -30,7 +30,6 @@
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
# define LOVE_WINDOWS_UWP 1
# define LOVE_NO_MODPLUG 1
# define LOVE_NOMPG123 1
# endif
# endif
#endif
+154
View File
@@ -661,6 +661,160 @@ bool luax_istype(lua_State *L, int idx, love::Type &type)
return false;
}
static Proxy *tryextractproxy(lua_State *L, int idx)
{
Proxy *u = (Proxy *)lua_touserdata(L, idx);
if (u == nullptr || u->type == nullptr)
return nullptr;
// We could get rid of the dynamic_cast for more performance, but it would
// be less safe...
if (dynamic_cast<Object *>(u->object) != nullptr)
return u;
return nullptr;
}
Variant luax_checkvariant(lua_State *L, int n, bool allowuserdata, std::set<const void*> *tableSet)
{
size_t len;
const char *str;
Proxy *p = nullptr;
if (n < 0) // Fix the stack position, we might modify it later
n += lua_gettop(L) + 1;
switch (lua_type(L, n))
{
case LUA_TBOOLEAN:
return Variant(luax_toboolean(L, n));
case LUA_TNUMBER:
return Variant(lua_tonumber(L, n));
case LUA_TSTRING:
str = lua_tolstring(L, n, &len);
return Variant(str, len);
case LUA_TLIGHTUSERDATA:
return Variant(lua_touserdata(L, n));
case LUA_TUSERDATA:
if (!allowuserdata)
{
luax_typerror(L, n, "copyable Lua value");
return Variant();
}
p = tryextractproxy(L, n);
if (p != nullptr)
return Variant(p->type, p->object);
else
{
luax_typerror(L, n, "love type");
return Variant();
}
case LUA_TNIL:
return Variant();
case LUA_TTABLE:
{
bool success = true;
std::set<const void *> topTableSet;
// We can use a pointer to a stack-allocated variable because it's
// never used after the stack-allocated variable is destroyed.
if (tableSet == nullptr)
tableSet = &topTableSet;
// Now make sure this table wasn't already serialised
const void *tablePointer = lua_topointer(L, n);
{
auto result = tableSet->insert(tablePointer);
if (!result.second) // insertion failed
throw love::Exception("Cycle detected in table");
}
Variant::SharedTable *table = new Variant::SharedTable();
size_t len = luax_objlen(L, -1);
if (len > 0)
table->pairs.reserve(len);
lua_pushnil(L);
while (lua_next(L, n))
{
table->pairs.emplace_back(
luax_checkvariant(L, -2, allowuserdata, tableSet),
luax_checkvariant(L, -1, allowuserdata, tableSet)
);
lua_pop(L, 1);
const auto &p = table->pairs.back();
if (p.first.getType() == Variant::UNKNOWN || p.second.getType() == Variant::UNKNOWN)
{
success = false;
break;
}
}
// And remove the table from the set again
tableSet->erase(tablePointer);
if (success)
return Variant(table);
else
table->release();
}
break;
}
return Variant::unknown();
}
void luax_pushvariant(lua_State *L, const Variant &v)
{
const Variant::Data &data = v.getData();
switch (v.getType())
{
case Variant::BOOLEAN:
lua_pushboolean(L, data.boolean);
break;
case Variant::NUMBER:
lua_pushnumber(L, data.number);
break;
case Variant::STRING:
lua_pushlstring(L, data.string->str, data.string->len);
break;
case Variant::SMALLSTRING:
lua_pushlstring(L, data.smallstring.str, data.smallstring.len);
break;
case Variant::LUSERDATA:
lua_pushlightuserdata(L, data.userdata);
break;
case Variant::LOVEOBJECT:
luax_pushtype(L, *data.objectproxy.type, data.objectproxy.object);
break;
case Variant::TABLE:
{
std::vector<std::pair<Variant, Variant>> &table = data.table->pairs;
int tsize = (int) table.size();
lua_createtable(L, 0, tsize);
for (int i = 0; i < tsize; ++i)
{
std::pair<Variant, Variant> &kv = table[i];
luax_pushvariant(L, kv.first);
luax_pushvariant(L, kv.second);
lua_settable(L, -3);
}
break;
}
case Variant::NIL:
default:
lua_pushnil(L);
break;
}
}
int luax_getfunction(lua_State *L, const char *mod, const char *fn)
{
lua_getglobal(L, "love");
+13 -16
View File
@@ -24,6 +24,8 @@
// LOVE
#include "config.h"
#include "types.h"
#include "Object.h"
#include "Variant.h"
#include "deprecation.h"
// Lua
@@ -37,12 +39,12 @@ extern "C" {
// C++
#include <exception>
#include <algorithm>
#include <set>
namespace love
{
// Forward declarations.
class Object;
class Module;
class Reference;
@@ -59,21 +61,6 @@ enum Registry
REGISTRY_OBJECTS
};
/**
* This structure wraps all Lua-exposed objects. It exists in the
* Lua state as a full userdata (so we can catch __gc "events"),
* though the Object it refers to is light userdata in the sense
* that it is not allocated by the Lua VM.
**/
struct Proxy
{
// Holds type information (see types.h).
love::Type *type;
// Pointer to the actual object.
Object *object;
};
/**
* A Module with Lua wrapper functions and other data.
**/
@@ -365,6 +352,16 @@ void luax_pushtype(lua_State *L, StrongRef<T> &object)
**/
void luax_rawnewtype(lua_State *L, love::Type &type, love::Object *object);
/**
* Stores the value at the given index on the stack into a Variant object.
*/
LOVE_EXPORT Variant luax_checkvariant(lua_State *L, int idx, bool allowuserdata = true, std::set<const void*> *tableSet = nullptr);
/**
* Pushes the contents of the given Variant index onto the stack.
*/
LOVE_EXPORT void luax_pushvariant(lua_State *L, const Variant &v);
/**
* Checks whether the value at idx is a certain type.
* @param L The Lua state.
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -205,7 +205,7 @@ static DoneAction runlove(int argc, char **argv, int &retval, love::Variant &res
}
// Set love.restart = restartvalue, and clear restartvalue.
restartvalue.toLua(L);
love::luax_pushvariant(L, restartvalue);
lua_setfield(L, -2, "restart");
restartvalue = love::Variant();
@@ -240,7 +240,7 @@ static DoneAction runlove(int argc, char **argv, int &retval, love::Variant &res
// Disallow userdata (love objects) from being referenced by the restart
// value.
if (retidx < lua_gettop(L))
restartvalue = love::Variant::fromLua(L, retidx + 1, false);
restartvalue = love::luax_checkvariant(L, retidx + 1, false);
}
lua_close(L);
-40
View File
@@ -38,46 +38,6 @@ Message::~Message()
{
}
int Message::toLua(lua_State *L)
{
luax_pushstring(L, name);
for (const Variant &v : args)
v.toLua(L);
return (int) args.size() + 1;
}
Message *Message::fromLua(lua_State *L, int n)
{
std::string name = luax_checkstring(L, n);
std::vector<Variant> vargs;
int count = lua_gettop(L) - n;
n++;
Variant varg;
for (int i = 0; i < count; i++)
{
if (lua_isnoneornil(L, n+i))
break;
luax_catchexcept(L, [&]() {
vargs.push_back(Variant::fromLua(L, n+i));
});
if (vargs.back().getType() == Variant::UNKNOWN)
{
vargs.clear();
luaL_error(L, "Argument %d can't be stored safely\nExpected boolean, number, string or userdata.", n+i);
return nullptr;
}
}
return new Message(name, vargs);
}
Event::~Event()
{
}
-3
View File
@@ -46,9 +46,6 @@ public:
Message(const std::string &name, const std::vector<Variant> &vargs = {});
~Message();
int toLua(lua_State *L);
static Message *fromLua(lua_State *L, int n);
const std::string name;
const std::vector<Variant> args;
+34 -11
View File
@@ -38,13 +38,23 @@ namespace event
#define instance() (Module::getInstance<Event>(Module::M_EVENT))
static int luax_pushmessage(lua_State *L, const Message &m)
{
luax_pushstring(L, m.name);
for (const Variant &v : m.args)
luax_pushvariant(L, v);
return (int) m.args.size() + 1;
}
static int w_poll_i(lua_State *L)
{
Message *m = nullptr;
if (instance()->poll(m))
if (instance()->poll(m) && m != nullptr)
{
int args = m->toLua(L);
int args = luax_pushmessage(L, *m);
m->release();
return args;
}
@@ -63,9 +73,9 @@ int w_wait(lua_State *L)
{
Message *m = nullptr;
luax_catchexcept(L, [&]() { m = instance()->wait(); });
if (m)
if (m != nullptr)
{
int args = m->toLua(L);
int args = luax_pushmessage(L, *m);
m->release();
return args;
}
@@ -75,15 +85,28 @@ int w_wait(lua_State *L)
int w_push(lua_State *L)
{
StrongRef<Message> m;
luax_catchexcept(L, [&]() { m.set(Message::fromLua(L, 1), Acquire::NORETAIN); });
std::string name = luax_checkstring(L, 1);
std::vector<Variant> vargs;
luax_pushboolean(L, m.get() != nullptr);
int nargs = lua_gettop(L);
for (int i = 2; i <= nargs; i++)
{
if (lua_isnoneornil(L, i))
break;
if (m.get() == nullptr)
return 1;
luax_catchexcept(L, [&]() { vargs.push_back(luax_checkvariant(L, i)); });
if (vargs.back().getType() == Variant::UNKNOWN)
{
vargs.clear();
return luaL_error(L, "Argument %d can't be stored safely\nExpected boolean, number, string or userdata.", i);
}
}
StrongRef<Message> m(new Message(name, vargs), Acquire::NORETAIN);
instance()->push(m);
luax_pushboolean(L, true);
return 1;
}
@@ -98,7 +121,7 @@ int w_quit(lua_State *L)
luax_catchexcept(L, [&]() {
std::vector<Variant> args;
for (int i = 1; i <= std::max(1, lua_gettop(L)); i++)
args.push_back(Variant::fromLua(L, i));
args.push_back(luax_checkvariant(L, i));
StrongRef<Message> m(new Message("quit", args), Acquire::NORETAIN);
instance()->push(m);
@@ -115,7 +138,7 @@ int w_restart(lua_State *L)
args.emplace_back("restart", strlen("restart"));
for (int i = 1; i <= lua_gettop(L); i++)
args.push_back(Variant::fromLua(L, i));
args.push_back(luax_checkvariant(L, i));
StrongRef<Message> m(new Message("quit", args), Acquire::NORETAIN);
instance()->push(m);
+1
View File
@@ -24,6 +24,7 @@
// LOVE
#include "common/config.h"
#include "Event.h"
#include "common/runtime.h"
namespace love
{
+13 -12
View File
@@ -22,6 +22,7 @@
#include "Font.h"
#include "BMFontRasterizer.h"
#include "ImageRasterizer.h"
#include "data/DataModule.h"
#include "libraries/utf8/utf8.h"
@@ -30,28 +31,28 @@ namespace love
namespace font
{
// Default TrueType font.
#include "Vera.ttf.h"
// Default TrueType font, gzip-compressed.
#include "NotoSans-Regular.ttf.gzip.h"
class DefaultFontData : public love::Data
Font::Font()
{
public:
auto compressedbytes = (const char *) NotoSans_Regular_ttf_gzip;
size_t compressedsize = NotoSans_Regular_ttf_gzip_len;
Data *clone() const override { return new DefaultFontData(); }
void *getData() const override { return Vera_ttf; }
size_t getSize() const override { return sizeof(Vera_ttf); }
};
size_t rawsize = 0;
char *fontdata = data::decompress(data::Compressor::FORMAT_GZIP, compressedbytes, compressedsize, rawsize);
defaultFontData.set(new data::ByteData(fontdata, rawsize, true), Acquire::NORETAIN);
}
Rasterizer *Font::newTrueTypeRasterizer(int size, TrueTypeRasterizer::Hinting hinting)
{
StrongRef<DefaultFontData> data(new DefaultFontData, Acquire::NORETAIN);
return newTrueTypeRasterizer(data.get(), size, hinting);
return newTrueTypeRasterizer(defaultFontData.get(), size, hinting);
}
Rasterizer *Font::newTrueTypeRasterizer(int size, float dpiscale, TrueTypeRasterizer::Hinting hinting)
{
StrongRef<DefaultFontData> data(new DefaultFontData, Acquire::NORETAIN);
return newTrueTypeRasterizer(data.get(), size, dpiscale, hinting);
return newTrueTypeRasterizer(defaultFontData.get(), size, dpiscale, hinting);
}
Rasterizer *Font::newBMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &images, float dpiscale)
+5
View File
@@ -43,6 +43,7 @@ class Font : public Module
public:
Font();
virtual ~Font() {}
virtual Rasterizer *newRasterizer(love::filesystem::FileData *data) = 0;
@@ -64,6 +65,10 @@ public:
virtual ModuleType getModuleType() const { return M_FONT; }
virtual const char *getName() const = 0;
private:
StrongRef<Data> defaultFontData;
}; // Font
} // font
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -72,7 +72,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
if (lua_type(L, 1) == LUA_TNUMBER || lua_isnone(L, 1))
{
// First argument is a number: use the default TrueType font.
int size = (int) luaL_optinteger(L, 1, 12);
int size = (int) luaL_optinteger(L, 1, 13);
const char *hintstr = lua_isnoneornil(L, 2) ? nullptr : luaL_checkstring(L, 2);
if (hintstr && !TrueTypeRasterizer::getConstant(hintstr, hinting))
+1 -1
View File
@@ -82,7 +82,7 @@ void Deprecations::draw(Graphics *gfx)
font.set(gfx->newDefaultFont(9, hinting), Acquire::NORETAIN);
}
gfx->flushStreamDraws();
gfx->flushBatchedDraws();
gfx->push(Graphics::STACK_ALL);
gfx->reset();
+3 -3
View File
@@ -133,7 +133,7 @@ bool Font::loadVolatile()
void Font::createTexture()
{
auto gfx = Module::getInstance<graphics::Graphics>(Module::M_GRAPHICS);
gfx->flushStreamDraws();
gfx->flushBatchedDraws();
Texture *texture = nullptr;
TextureSize size = {textureWidth, textureHeight};
@@ -645,13 +645,13 @@ void Font::printv(graphics::Graphics *gfx, const Matrix4 &t, const std::vector<D
for (const DrawCommand &cmd : drawcommands)
{
Graphics::StreamDrawCommand streamcmd;
Graphics::BatchedDrawCommand streamcmd;
streamcmd.formats[0] = vertexFormat;
streamcmd.indexMode = vertex::TriangleIndexMode::QUADS;
streamcmd.vertexCount = cmd.vertexcount;
streamcmd.texture = cmd.texture;
Graphics::StreamVertexData data = gfx->requestStreamDraw(streamcmd);
Graphics::BatchedVertexData data = gfx->requestBatchedDraw(streamcmd);
GlyphVertex *vertexdata = (GlyphVertex *) data.stream[0];
memcpy(vertexdata, &vertices[cmd.startvertex], sizeof(GlyphVertex) * cmd.vertexcount);
+22 -22
View File
@@ -145,7 +145,7 @@ Graphics::Graphics()
, created(false)
, active(true)
, writingToStencil(false)
, streamBufferState()
, batchedDrawState()
, projectionMatrix()
, renderTargetSwitchCount(0)
, drawCalls(0)
@@ -188,9 +188,9 @@ Graphics::~Graphics()
defaultFont.set(nullptr);
delete streamBufferState.vb[0];
delete streamBufferState.vb[1];
delete streamBufferState.indexBuffer;
delete batchedDrawState.vb[0];
delete batchedDrawState.vb[1];
delete batchedDrawState.indexBuffer;
for (int i = 0; i < (int) ShaderStage::STAGE_MAX_ENUM; i++)
cachedShaderStages[i].clear();
@@ -535,7 +535,7 @@ void Graphics::checkSetDefaultFont()
// Create a new default font if we don't have one yet.
if (!defaultFont.get())
defaultFont.set(newDefaultFont(12, font::TrueTypeRasterizer::HINTING_NORMAL), Acquire::NORETAIN);
defaultFont.set(newDefaultFont(13, font::TrueTypeRasterizer::HINTING_NORMAL), Acquire::NORETAIN);
states.back().font.set(defaultFont.get());
}
@@ -722,7 +722,7 @@ void Graphics::setRenderTargets(const RenderTargets &rts)
int w = firsttex->getWidth(firsttarget.mipmap);
int h = firsttex->getHeight(firsttarget.mipmap);
flushStreamDraws();
flushBatchedDraws();
if (rts.depthStencil.texture == nullptr && rts.temporaryRTFlags != 0)
{
@@ -772,7 +772,7 @@ void Graphics::setRenderTarget()
if (state.renderTargets.colors.empty() && state.renderTargets.depthStencil.texture == nullptr)
return;
flushStreamDraws();
flushBatchedDraws();
setRenderTargetsInternal(RenderTargets(), width, height, pixelWidth, pixelHeight, isGammaCorrect());
state.renderTargets = RenderTargetsStrongRef();
@@ -1017,11 +1017,11 @@ void Graphics::captureScreenshot(const ScreenshotInfo &info)
pendingScreenshotCallbacks.push_back(info);
}
Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &cmd)
Graphics::BatchedVertexData Graphics::requestBatchedDraw(const BatchedDrawCommand &cmd)
{
using namespace vertex;
StreamBufferState &state = streamBufferState;
BatchedDrawState &state = batchedDrawState;
bool shouldflush = false;
bool shouldresize = false;
@@ -1083,7 +1083,7 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
if (shouldflush || shouldresize)
{
flushStreamDraws();
flushBatchedDraws();
state.primitiveMode = cmd.primitiveMode;
state.formats[0] = cmd.formats[0];
@@ -1127,7 +1127,7 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
state.indexBufferMap.data += reqIndexSize;
}
StreamVertexData d;
BatchedVertexData d;
for (int i = 0; i < 2; i++)
{
@@ -1151,11 +1151,11 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &
return d;
}
void Graphics::flushStreamDraws()
void Graphics::flushBatchedDraws()
{
using namespace vertex;
auto &sbstate = streamBufferState;
auto &sbstate = batchedDrawState;
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
return;
@@ -1226,15 +1226,15 @@ void Graphics::flushStreamDraws()
if (attributes.isEnabled(ATTRIB_COLOR))
setColor(nc);
streamBufferState.vertexCount = 0;
streamBufferState.indexCount = 0;
batchedDrawState.vertexCount = 0;
batchedDrawState.indexCount = 0;
}
void Graphics::flushStreamDrawsGlobal()
void Graphics::flushBatchedDrawsGlobal()
{
Graphics *instance = getInstance<Graphics>(M_GRAPHICS);
if (instance != nullptr)
instance->flushStreamDraws();
instance->flushBatchedDraws();
}
/**
@@ -1301,13 +1301,13 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform();
StreamDrawCommand cmd;
BatchedDrawCommand cmd;
cmd.primitiveMode = PRIMITIVE_POINTS;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.vertexCount = (int) numpoints;
StreamVertexData data = requestStreamDraw(cmd);
BatchedVertexData data = requestBatchedDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], positions, cmd.vertexCount);
@@ -1597,13 +1597,13 @@ void Graphics::polygon(DrawMode mode, const Vector2 *coords, size_t count, bool
const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform();
StreamDrawCommand cmd;
BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.indexMode = vertex::TriangleIndexMode::FAN;
cmd.vertexCount = (int)count - (skipLastFilledVertex ? 1 : 0);
StreamVertexData data = requestStreamDraw(cmd);
BatchedVertexData data = requestBatchedDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], coords, cmd.vertexCount);
@@ -1629,7 +1629,7 @@ Graphics::Stats Graphics::getStats() const
getAPIStats(stats.shaderSwitches);
stats.drawCalls = drawCalls;
if (streamBufferState.vertexCount > 0)
if (batchedDrawState.vertexCount > 0)
stats.drawCalls++;
stats.renderTargetSwitches = renderTargetSwitchCount;
+9 -9
View File
@@ -253,7 +253,7 @@ public:
{}
};
struct StreamDrawCommand
struct BatchedDrawCommand
{
PrimitiveType primitiveMode = PRIMITIVE_TRIANGLES;
vertex::CommonFormat formats[2];
@@ -262,14 +262,14 @@ public:
Texture *texture = nullptr;
Shader::StandardShader standardShaderType = Shader::STANDARD_DEFAULT;
StreamDrawCommand()
BatchedDrawCommand()
{
// VS2013 can't initialize arrays in the above manner...
formats[1] = formats[0] = vertex::CommonFormat::NONE;
}
};
struct StreamVertexData
struct BatchedVertexData
{
void *stream[2];
};
@@ -827,10 +827,10 @@ public:
virtual void draw(const DrawIndexedCommand &cmd) = 0;
virtual void drawQuads(int start, int count, const vertex::Attributes &attributes, const vertex::BufferBindings &buffers, Texture *texture) = 0;
void flushStreamDraws();
StreamVertexData requestStreamDraw(const StreamDrawCommand &command);
void flushBatchedDraws();
BatchedVertexData requestBatchedDraw(const BatchedDrawCommand &command);
static void flushStreamDrawsGlobal();
static void flushBatchedDrawsGlobal();
virtual Shader::Language getShaderLanguageTarget() const = 0;
const DefaultShaderCode &getCurrentDefaultShaderCode() const;
@@ -918,7 +918,7 @@ protected:
SamplerState defaultSamplerState = SamplerState();
};
struct StreamBufferState
struct BatchedDrawState
{
StreamBuffer *vb[2];
StreamBuffer *indexBuffer = nullptr;
@@ -933,7 +933,7 @@ protected:
StreamBuffer::MapInfo vbMap[2];
StreamBuffer::MapInfo indexBufferMap = StreamBuffer::MapInfo();
StreamBufferState()
BatchedDrawState()
{
vb[0] = vb[1] = nullptr;
formats[0] = formats[1] = vertex::CommonFormat::NONE;
@@ -986,7 +986,7 @@ protected:
std::vector<ScreenshotInfo> pendingScreenshotCallbacks;
StreamBufferState streamBufferState;
BatchedDrawState batchedDrawState;
std::vector<Matrix4> transformStack;
Matrix4 projectionMatrix;
+1 -1
View File
@@ -584,7 +584,7 @@ void Mesh::drawInstanced(Graphics *gfx, const Matrix4 &m, int instancecount)
if (instancecount > 1 && !gfx->getCapabilities().features[Graphics::FEATURE_INSTANCING])
throw love::Exception("Instancing is not supported on this system.");
gfx->flushStreamDraws();
gfx->flushBatchedDraws();
if (Shader::isDefaultActive())
Shader::attachDefault(Shader::STANDARD_DEFAULT);
+1 -1
View File
@@ -1029,7 +1029,7 @@ void ParticleSystem::draw(Graphics *gfx, const Matrix4 &m)
if (pCount == 0 || texture.get() == nullptr || pMem == nullptr || buffer == nullptr)
return;
gfx->flushStreamDraws();
gfx->flushBatchedDraws();
if (Shader::isDefaultActive())
Shader::attachDefault(Shader::STANDARD_DEFAULT);
+2 -2
View File
@@ -390,13 +390,13 @@ void Polyline::draw(love::graphics::Graphics *gfx)
{
const Vector2 *verts = vertices + vertex_start;
Graphics::StreamDrawCommand cmd;
Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.indexMode = triangle_mode;
cmd.vertexCount = std::min(maxvertices, total_vertex_count - vertex_start);
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], verts, cmd.vertexCount);
+1 -1
View File
@@ -301,7 +301,7 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m)
if (next == 0)
return;
gfx->flushStreamDraws();
gfx->flushBatchedDraws();
if (texture.get())
{
+1 -1
View File
@@ -246,7 +246,7 @@ void Text::draw(Graphics *gfx, const Matrix4 &m)
if (vertex_buffer == nullptr || draw_commands.empty())
return;
gfx->flushStreamDraws();
gfx->flushBatchedDraws();
if (Shader::isDefaultActive())
Shader::attachDefault(Shader::STANDARD_DEFAULT);
+8 -8
View File
@@ -324,14 +324,14 @@ void Texture::draw(Graphics *gfx, Quad *q, const Matrix4 &localTransform)
const Matrix4 &tm = gfx->getTransform();
bool is2D = tm.isAffine2DTransform();
Graphics::StreamDrawCommand cmd;
Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::STf_RGBAub;
cmd.indexMode = TriangleIndexMode::QUADS;
cmd.vertexCount = 4;
cmd.texture = this;
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
Matrix4 t(tm, localTransform);
@@ -381,7 +381,7 @@ void Texture::drawLayer(Graphics *gfx, int layer, Quad *q, const Matrix4 &m)
Matrix4 t(tm, m);
Graphics::StreamDrawCommand cmd;
Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::STPf_RGBAub;
cmd.indexMode = TriangleIndexMode::QUADS;
@@ -389,7 +389,7 @@ void Texture::drawLayer(Graphics *gfx, int layer, Quad *q, const Matrix4 &m)
cmd.texture = this;
cmd.standardShaderType = Shader::STANDARD_ARRAY;
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], q->getVertexPositions(), 4);
@@ -464,7 +464,7 @@ void Texture::replacePixels(love::image::ImageDataBase *d, int slice, int mipmap
if (isPixelFormatCompressed(d->getFormat()) && (rect.x != 0 || rect.y != 0 || rect.w != mipw || rect.h != miph))
throw love::Exception("Compressed textures only support replacing the entire Texture.");
Graphics::flushStreamDrawsGlobal();
Graphics::flushBatchedDrawsGlobal();
uploadImageData(d, mipmap, slice, x, y);
@@ -481,7 +481,7 @@ void Texture::replacePixels(const void *data, size_t size, int slice, int mipmap
if (gfx != nullptr && gfx->isRenderTargetActive(this))
return;
Graphics::flushStreamDrawsGlobal();
Graphics::flushBatchedDrawsGlobal();
uploadByteData(format, data, size, mipmap, slice, rect, nullptr);
@@ -631,7 +631,7 @@ void Texture::setSamplerState(const SamplerState &s)
if (s.depthSampleMode.hasValue && !isPixelFormatDepth(format))
throw love::Exception("Only depth textures can have a depth sample compare mode.");
Graphics::flushStreamDrawsGlobal();
Graphics::flushBatchedDrawsGlobal();
samplerState = s;
@@ -908,7 +908,7 @@ static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM>::Entry setting
{ "type", Texture::SETTING_TYPE },
{ "dpiscale", Texture::SETTING_DPI_SCALE },
{ "msaa", Texture::SETTING_MSAA },
{ "rendertarget", Texture::SETTING_RENDER_TARGET },
{ "canvas", Texture::SETTING_RENDER_TARGET },
{ "readable", Texture::SETTING_READABLE },
};
+3 -3
View File
@@ -120,14 +120,14 @@ void Video::draw(Graphics *gfx, const Matrix4 &m)
Matrix4 t(tm, m);
Graphics::StreamDrawCommand cmd;
Graphics::BatchedDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::STf_RGBAub;
cmd.indexMode = vertex::TriangleIndexMode::QUADS;
cmd.vertexCount = 4;
cmd.standardShaderType = Shader::STANDARD_VIDEO;
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
Graphics::BatchedVertexData data = gfx->requestBatchedDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], vertices, 4);
@@ -148,7 +148,7 @@ void Video::draw(Graphics *gfx, const Matrix4 &m)
if (Shader::current != nullptr)
Shader::current->setVideoTextures(textures[0], textures[1], textures[2]);
gfx->flushStreamDraws();
gfx->flushBatchedDraws();
}
void Video::update()
+24 -24
View File
@@ -251,13 +251,13 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
setDebug(isDebugEnabled());
if (streamBufferState.vb[0] == nullptr)
if (batchedDrawState.vb[0] == nullptr)
{
// Initial sizes that should be good enough for most cases. It will
// resize to fit if needed, later.
streamBufferState.vb[0] = CreateStreamBuffer(BUFFER_VERTEX, 1024 * 1024 * 1);
streamBufferState.vb[1] = CreateStreamBuffer(BUFFER_VERTEX, 256 * 1024 * 1);
streamBufferState.indexBuffer = CreateStreamBuffer(BUFFER_INDEX, sizeof(uint16) * LOVE_UINT16_MAX);
batchedDrawState.vb[0] = CreateStreamBuffer(BUFFER_VERTEX, 1024 * 1024 * 1);
batchedDrawState.vb[1] = CreateStreamBuffer(BUFFER_VERTEX, 256 * 1024 * 1);
batchedDrawState.indexBuffer = CreateStreamBuffer(BUFFER_INDEX, sizeof(uint16) * LOVE_UINT16_MAX);
}
// Reload all volatile objects.
@@ -310,7 +310,7 @@ void Graphics::unSetMode()
if (!isCreated())
return;
flushStreamDraws();
flushBatchedDraws();
// Unload all volatile objects. These must be reloaded after the display
// mode change.
@@ -338,7 +338,7 @@ void Graphics::unSetMode()
void Graphics::setActive(bool enable)
{
flushStreamDraws();
flushBatchedDraws();
// Make sure all pending OpenGL commands have fully executed before
// returning, when going from active to inactive. This is required on iOS.
@@ -637,7 +637,7 @@ void Graphics::endPass()
void Graphics::clear(OptionalColorf c, OptionalInt stencil, OptionalDouble depth)
{
if (c.hasValue || stencil.hasValue || depth.hasValue)
flushStreamDraws();
flushBatchedDraws();
GLbitfield flags = 0;
@@ -694,7 +694,7 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors, OptionalInt sten
return;
}
flushStreamDraws();
flushBatchedDraws();
bool drawbuffersmodified = false;
ncolors = std::min(ncolors, ncolorRTs);
@@ -770,7 +770,7 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors, OptionalInt sten
void Graphics::discard(const std::vector<bool> &colorbuffers, bool depthstencil)
{
flushStreamDraws();
flushBatchedDraws();
discard(OpenGL::FRAMEBUFFER_ALL, colorbuffers, depthstencil);
}
@@ -951,7 +951,7 @@ void Graphics::present(void *screenshotCallbackData)
deprecations.draw(this);
flushStreamDraws();
flushBatchedDraws();
endPass();
gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, gl.getDefaultFBO());
@@ -1054,9 +1054,9 @@ void Graphics::present(void *screenshotCallbackData)
glBindRenderbuffer(GL_RENDERBUFFER, info.info.uikit.colorbuffer);
#endif
for (StreamBuffer *buffer : streamBufferState.vb)
for (StreamBuffer *buffer : batchedDrawState.vb)
buffer->nextFrame();
streamBufferState.indexBuffer->nextFrame();
batchedDrawState.indexBuffer->nextFrame();
auto window = getInstance<love::window::Window>(M_WINDOW);
if (window != nullptr)
@@ -1084,7 +1084,7 @@ void Graphics::present(void *screenshotCallbackData)
void Graphics::setScissor(const Rect &rect)
{
flushStreamDraws();
flushBatchedDraws();
DisplayState &state = states.back();
@@ -1109,7 +1109,7 @@ void Graphics::setScissor(const Rect &rect)
void Graphics::setScissor()
{
if (states.back().scissor)
flushStreamDraws();
flushBatchedDraws();
states.back().scissor = false;
@@ -1127,7 +1127,7 @@ void Graphics::drawToStencilBuffer(StencilAction action, int value)
else if (isRenderTargetActive() && (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) == 0 && (dstexture == nullptr || !isPixelFormatStencil(dstexture->getPixelFormat())))
throw love::Exception("Drawing to the stencil buffer with a render target active requires either stencil=true or a custom stencil-type texture to be used, in setRenderTarget.");
flushStreamDraws();
flushBatchedDraws();
writingToStencil = true;
@@ -1172,7 +1172,7 @@ void Graphics::stopDrawToStencilBuffer()
if (!writingToStencil)
return;
flushStreamDraws();
flushBatchedDraws();
writingToStencil = false;
@@ -1190,7 +1190,7 @@ void Graphics::setStencilTest(CompareMode compare, int value)
DisplayState &state = states.back();
if (state.stencilCompare != compare || state.stencilTestValue != value)
flushStreamDraws();
flushBatchedDraws();
state.stencilCompare = compare;
state.stencilTestValue = value;
@@ -1227,7 +1227,7 @@ void Graphics::setDepthMode(CompareMode compare, bool write)
DisplayState &state = states.back();
if (state.depthTest != compare || state.depthWrite != write)
flushStreamDraws();
flushBatchedDraws();
state.depthTest = compare;
state.depthWrite = write;
@@ -1249,7 +1249,7 @@ void Graphics::setFrontFaceWinding(vertex::Winding winding)
DisplayState &state = states.back();
if (state.winding != winding)
flushStreamDraws();
flushBatchedDraws();
state.winding = winding;
@@ -1271,7 +1271,7 @@ void Graphics::setColor(Colorf c)
void Graphics::setColorMask(ColorChannelMask mask)
{
flushStreamDraws();
flushBatchedDraws();
glColorMask(mask.r, mask.g, mask.b, mask.a);
states.back().colorMask = mask;
@@ -1280,7 +1280,7 @@ void Graphics::setColorMask(ColorChannelMask mask)
void Graphics::setBlendState(const BlendState &blend)
{
if (!(blend == states.back().blend))
flushStreamDraws();
flushBatchedDraws();
if (blend.operationRGB == BLENDOP_MAX || blend.operationA == BLENDOP_MAX
|| blend.operationRGB == BLENDOP_MIN || blend.operationA == BLENDOP_MIN)
@@ -1310,8 +1310,8 @@ void Graphics::setBlendState(const BlendState &blend)
void Graphics::setPointSize(float size)
{
if (streamBufferState.primitiveMode == PRIMITIVE_POINTS)
flushStreamDraws();
if (batchedDrawState.primitiveMode == PRIMITIVE_POINTS)
flushBatchedDraws();
gl.setPointSize(size * getCurrentDPIScale());
states.back().pointSize = size;
@@ -1323,7 +1323,7 @@ void Graphics::setWireframe(bool enable)
if (GLAD_ES_VERSION_2_0)
return;
flushStreamDraws();
flushBatchedDraws();
glPolygonMode(GL_FRONT_AND_BACK, enable ? GL_LINE : GL_FILL);
states.back().wireframe = enable;
+5 -5
View File
@@ -429,7 +429,7 @@ void Shader::attach()
{
if (current != this)
{
Graphics::flushStreamDrawsGlobal();
Graphics::flushBatchedDrawsGlobal();
gl.useProgram(program);
current = this;
@@ -480,7 +480,7 @@ void Shader::updateUniform(const UniformInfo *info, int count, bool internalupda
}
if (!internalupdate)
flushStreamDraws();
flushBatchedDraws();
int location = info->location;
UniformType type = info->baseType;
@@ -578,7 +578,7 @@ void Shader::sendTextures(const UniformInfo *info, love::graphics::Texture **tex
bool shaderactive = current == this;
if (!internalUpdate && shaderactive)
flushStreamDraws();
flushBatchedDraws();
count = std::min(count, info->count);
@@ -644,10 +644,10 @@ void Shader::sendTextures(const UniformInfo *info, love::graphics::Texture **tex
}
}
void Shader::flushStreamDraws() const
void Shader::flushBatchedDraws() const
{
if (current == this)
Graphics::flushStreamDrawsGlobal();
Graphics::flushBatchedDrawsGlobal();
}
bool Shader::hasUniform(const std::string &name) const
+1 -1
View File
@@ -90,7 +90,7 @@ private:
TextureType getUniformTextureType(GLenum type) const;
bool isDepthTextureType(GLenum type) const;
void flushStreamDraws() const;
void flushBatchedDraws() const;
// Get any warnings or errors generated only by the shader program object.
std::string getProgramWarnings() const;
+10 -31
View File
@@ -263,7 +263,7 @@ static Graphics::RenderTarget checkRenderTarget(lua_State *L, int idx)
return target;
}
int w_setRenderTarget(lua_State *L)
int w_setCanvas(lua_State *L)
{
// Disable stencil writes.
luax_catchexcept(L, [](){ instance()->stopDrawToStencilBuffer(); });
@@ -295,7 +295,7 @@ int w_setRenderTarget(lua_State *L)
targets.colors.emplace_back(luax_checktexture(L, -1), 0);
if (targets.colors.back().texture->getTextureType() != TEXTURE_2D)
return luaL_error(L, "Non-2D textures must use the table-of-tables variant of setRenderTargets.");
return luaL_error(L, "Non-2D textures must use the table-of-tables variant of setCanvas.");
}
lua_pop(L, 1);
@@ -341,7 +341,7 @@ int w_setRenderTarget(lua_State *L)
}
if (i > 1 && type != TEXTURE_2D)
return luaL_error(L, "This variant of setRenderTarget only supports 2D texture types.");
return luaL_error(L, "This variant of setCanvas only supports 2D texture types.");
targets.colors.push_back(target);
}
@@ -357,12 +357,6 @@ int w_setRenderTarget(lua_State *L)
return 0;
}
int w_setCanvas(lua_State *L)
{
luax_markdeprecated(L, "love.graphics.setCanvas", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.setRenderTarget");
return w_setRenderTarget(L);
}
static void pushRenderTarget(lua_State *L, const Graphics::RenderTarget &rt)
{
lua_createtable(L, 1, 2);
@@ -387,7 +381,7 @@ static void pushRenderTarget(lua_State *L, const Graphics::RenderTarget &rt)
lua_setfield(L, -2, "mipmap");
}
int w_getRenderTarget(lua_State *L)
int w_getCanvas(lua_State *L)
{
Graphics::RenderTargets targets = instance()->getRenderTargets();
int ntargets = (int) targets.colors.size();
@@ -439,12 +433,6 @@ int w_getRenderTarget(lua_State *L)
}
}
int w_getCanvas(lua_State *L)
{
luax_markdeprecated(L, "love.graphics.getCanvas", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.getRenderTarget");
return w_getRenderTarget(L);
}
static void screenshotFunctionCallback(const Graphics::ScreenshotInfo *info, love::image::ImageData *i, void *gd)
{
if (info == nullptr)
@@ -831,7 +819,7 @@ static void luax_checktexturesettings(lua_State *L, int idx, bool opt, bool chec
lua_pop(L, 1);
}
int w_newRenderTarget(lua_State *L)
int w_newCanvas(lua_State *L)
{
luax_checkgraphicscreated(L);
@@ -1209,12 +1197,6 @@ int w_newVolumeTexture(lua_State *L)
return w__pushNewTexture(L, slicesref, settings);
}
int w_newCanvas(lua_State *L)
{
luax_markdeprecated(L, "love.graphics.newCanvas", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newRenderTarget");
return w_newRenderTarget(L);
}
int w_newImage(lua_State *L)
{
luax_markdeprecated(L, "love.graphics.newImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newTexture");
@@ -2562,7 +2544,7 @@ int w_getStats(lua_State *L)
lua_setfield(L, -2, "drawcallsbatched");
lua_pushinteger(L, stats.renderTargetSwitches);
lua_setfield(L, -2, "rendertargetswitches");
lua_setfield(L, -2, "canvasswitches");
lua_pushinteger(L, stats.shaderSwitches);
lua_setfield(L, -2, "shaderswitches");
@@ -3047,7 +3029,7 @@ int w_polygon(lua_State *L)
int w_flushBatch(lua_State *)
{
instance()->flushStreamDraws();
instance()->flushBatchedDraws();
return 0;
}
@@ -3163,7 +3145,7 @@ static const luaL_Reg functions[] =
{ "discard", w_discard },
{ "present", w_present },
{ "newRenderTarget", w_newRenderTarget },
{ "newCanvas", w_newCanvas },
{ "newTexture", w_newTexture },
{ "newCubeTexture", w_newCubeTexture },
{ "newArrayTexture", w_newArrayTexture },
@@ -3180,8 +3162,8 @@ static const luaL_Reg functions[] =
{ "validateShader", w_validateShader },
{ "setRenderTarget", w_setRenderTarget },
{ "getRenderTarget", w_getRenderTarget },
{ "setCanvas", w_setCanvas },
{ "getCanvas", w_getCanvas },
{ "setColor", w_setColor },
{ "getColor", w_getColor },
@@ -3282,13 +3264,10 @@ static const luaL_Reg functions[] =
{ "inverseTransformPoint", w_inverseTransformPoint },
// Deprecated
{ "newCanvas", w_newCanvas },
{ "newImage", w_newImage },
{ "newArrayImage", w_newArrayImage },
{ "newVolumeImage", w_newVolumeImage },
{ "newCubeImage", w_newCubeImage },
{ "setCanvas", w_setCanvas },
{ "getCanvas", w_getCanvas },
{ "getCanvasFormats", w_getCanvasFormats },
{ "getImageFormats", w_getImageFormats },
+19 -9
View File
@@ -411,14 +411,18 @@ int w_Shader_send(lua_State *L)
const Shader::UniformInfo *info = shader->getUniformInfo(name);
if (info == nullptr)
return luaL_error(L, "Shader uniform '%s' does not exist.\nA common error is to define but not use the variable.", name);
{
luax_pushboolean(L, false);
return 1;
}
int startidx = 3;
if (luax_istype(L, startidx, Data::type))
return w_Shader_sendData(L, startidx, shader, info, false);
if (luax_istype(L, 3, Data::type))
w_Shader_sendData(L, 3, shader, info, false);
else
return w_Shader_sendLuaValues(L, startidx, shader, info, name);
w_Shader_sendLuaValues(L, 3, shader, info, name);
luax_pushboolean(L, true);
return 1;
}
int w_Shader_sendColors(lua_State *L)
@@ -428,15 +432,21 @@ int w_Shader_sendColors(lua_State *L)
const Shader::UniformInfo *info = shader->getUniformInfo(name);
if (info == nullptr)
return luaL_error(L, "Shader uniform '%s' does not exist.\nA common error is to define but not use the variable.", name);
{
luax_pushboolean(L, false);
return 1;
}
if (info->baseType != Shader::UNIFORM_FLOAT || info->components < 3)
return luaL_error(L, "sendColor can only be used on vec3 or vec4 uniforms.");
if (luax_istype(L, 3, Data::type))
return w_Shader_sendData(L, 3, shader, info, true);
w_Shader_sendData(L, 3, shader, info, true);
else
return w_Shader_sendFloats(L, 3, shader, info, true);
w_Shader_sendFloats(L, 3, shader, info, true);
luax_pushboolean(L, true);
return 1;
}
int w_Shader_hasUniform(lua_State *L)
+1 -1
View File
@@ -25,7 +25,7 @@
#include "common/Data.h"
#include "sound/Decoder.h"
#include "dr_flac/dr_flac.h"
#include "dr/dr_flac.h"
#include <string.h>
namespace love
+144
View File
@@ -0,0 +1,144 @@
/**
* Copyright (c) 2006-2020 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.
**/
#define DR_MP3_IMPLEMENTATION
#define DR_MP3_NO_STDIO
#include "MP3Decoder.h"
namespace love
{
namespace sound
{
namespace lullaby
{
MP3Decoder::MP3Decoder(Data *data, int bufferSize)
: Decoder(data, bufferSize)
{
// initialize mp3 handle
if(drmp3_init_memory(&mp3, data->getData(), data->getSize(), nullptr, nullptr) == 0)
throw love::Exception("Could not read mp3 data.");
sampleRate = mp3.sampleRate;
// calculate duration
drmp3_uint64 pcmCount, mp3FrameCount;
if (!drmp3_get_mp3_and_pcm_frame_count(&mp3, &mp3FrameCount, &pcmCount))
{
drmp3_uninit(&mp3);
throw love::Exception("Could not calculate duration.");
}
duration = ((double) pcmCount) / ((double) mp3.sampleRate);
// create seek table
uint32_t mp3FrameInt = mp3FrameCount;
seekTable.resize(mp3FrameCount, {0ULL, 0ULL, 0, 0});
if (!drmp3_calculate_seek_points(&mp3, &mp3FrameInt, seekTable.data()))
{
drmp3_uninit(&mp3);
throw love::Exception("Could not calculate seek table");
}
mp3FrameInt = mp3FrameInt > mp3FrameCount ? mp3FrameCount : mp3FrameInt;
// bind seek table
if (!drmp3_bind_seek_table(&mp3, mp3FrameInt, seekTable.data()))
{
drmp3_uninit(&mp3);
throw love::Exception("Could not bind seek table");
}
}
MP3Decoder::~MP3Decoder()
{
drmp3_uninit(&mp3);
}
bool MP3Decoder::accepts(const std::string &ext)
{
static const std::string supported[] =
{
"mp3", ""
};
for (int i = 0; !(supported[i].empty()); i++)
{
if (supported[i].compare(ext) == 0)
return true;
}
return false;
}
love::sound::Decoder *MP3Decoder::clone()
{
return new MP3Decoder(data, bufferSize);
}
int MP3Decoder::decode()
{
// bufferSize is in char
int maxRead = bufferSize / sizeof(int16_t) / mp3.channels;
int read = (int) drmp3_read_pcm_frames_s16(&mp3, maxRead, (drmp3_int16 *) buffer);
if (read < maxRead)
eof = true;
return read * sizeof(int16_t) * mp3.channels;
}
bool MP3Decoder::seek(double s)
{
drmp3_uint64 targetSample = s * mp3.sampleRate;
drmp3_bool32 success = drmp3_seek_to_pcm_frame(&mp3, targetSample);
if (success)
eof = false;
return success;
}
bool MP3Decoder::rewind()
{
return seek(0.0);
}
bool MP3Decoder::isSeekable()
{
return true;
}
int MP3Decoder::getChannelCount() const
{
return mp3.channels;
}
int MP3Decoder::getBitDepth() const
{
return 16;
}
double MP3Decoder::getDuration()
{
return duration;
}
} // lullaby
} // sound
} // love
@@ -18,21 +18,17 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#ifndef LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H
#define LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H
#ifndef LOVE_SOUND_LULLABY_MP3_DECODER_H
#define LOVE_SOUND_LULLABY_MP3_DECODER_H
// LOVE
#include "common/Data.h"
#include "sound/Decoder.h"
#ifndef LOVE_NOMPG123
// dr_mp3
#include "dr/dr_mp3.h"
// libmpg123
#ifdef LOVE_APPLE_USE_FRAMEWORKS
#include <mpg123/mpg123.h>
#else
#include <mpg123.h>
#endif
#include <vector>
namespace love
{
@@ -41,29 +37,14 @@ namespace sound
namespace lullaby
{
struct DecoderFile
{
unsigned char *data;
size_t size;
size_t offset;
DecoderFile(Data *d)
: data((unsigned char *) d->getData())
, size(d->getSize())
, offset(0)
{}
};
class Mpg123Decoder : public Decoder
class MP3Decoder: public love::sound::Decoder
{
public:
Mpg123Decoder(Data *data, int bufferSize);
virtual ~Mpg123Decoder();
MP3Decoder(Data *data, int bufsize);
virtual ~MP3Decoder();
static bool accepts(const std::string &ext);
static void quit();
love::sound::Decoder *clone();
int decode();
bool seek(double s);
@@ -75,21 +56,16 @@ public:
private:
DecoderFile decoder_file;
mpg123_handle *handle;
static bool inited;
int channels;
// MP3 handle
drmp3 mp3;
// Used for fast seeking
std::vector<drmp3_seek_point> seekTable;
double duration;
}; // Decoder
}; // MP3Decoder
} // lullaby
} // sound
} // love
#endif // LOVE_NOMPG123
#endif // LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H
#endif
-298
View File
@@ -1,298 +0,0 @@
/**
* Copyright (c) 2006-2020 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 "Mpg123Decoder.h"
#include "common/Exception.h"
#include <iostream>
#ifndef LOVE_NOMPG123
namespace love
{
namespace sound
{
namespace lullaby
{
/**
* mpg123 callbacks for seekable streams.
**/
static ssize_t read_callback(void *udata, void *buffer, size_t count)
{
DecoderFile *file = (DecoderFile *) udata;
// Calculates how much data is still left and takes that value or
// the buffer size, whichever is lower, as the number of bytes to write.
size_t countLeft = file->size - file->offset;
size_t countWrite = countLeft < count ? countLeft : count;
if (countWrite > 0)
{
memcpy(buffer, file->data + file->offset, countWrite);
file->offset += countWrite;
}
// Returns the number of written bytes. 0 means EOF.
return countWrite;
}
static off_t seek_callback(void *udata, off_t offset, int whence)
{
DecoderFile *file = (DecoderFile *) udata;
switch (whence)
{
case SEEK_SET:
// Negative values are invalid at this point.
if (offset < 0)
return -1;
// Prevents the offset from going over EOF.
if (file->size > (size_t) offset)
file->offset = offset;
else
file->offset = file->size;
break;
case SEEK_END:
// Offset is set to EOF. Offset calculation is just like SEEK_CUR.
file->offset = file->size;
case SEEK_CUR:
// Prevents the offset from going over EOF or below 0.
if (offset > 0)
{
if (file->size > file->offset + (size_t) offset)
file->offset = file->offset + offset;
else
file->offset = file->size;
}
else if (offset < 0)
{
if (file->offset >= (size_t) (-offset))
file->offset = file->offset - (size_t) (-offset);
else
file->offset = 0;
}
break;
default:
return -1;
};
return file->offset;
}
static void cleanup_callback(void *)
{
// Cleanup is done by the Decoder class.
}
bool Mpg123Decoder::inited = false;
Mpg123Decoder::Mpg123Decoder(Data *data, int bufferSize)
: Decoder(data, bufferSize)
, decoder_file(data)
, handle(0)
, channels(MPG123_STEREO)
, duration(-2.0)
{
int ret = 0;
if (!inited)
{
ret = mpg123_init();
if (ret != MPG123_OK)
throw love::Exception("Could not initialize mpg123.");
inited = (ret == MPG123_OK);
}
// Intialize the handle.
handle = mpg123_new(nullptr, nullptr);
if (handle == nullptr)
throw love::Exception("Could not create decoder.");
// Suppressing all mpg123 messages.
mpg123_param(handle, MPG123_ADD_FLAGS, MPG123_QUIET, 0);
try
{
ret = mpg123_replace_reader_handle(handle, &read_callback, &seek_callback, &cleanup_callback);
if (ret != MPG123_OK)
throw love::Exception("Could not set decoder callbacks.");
ret = mpg123_open_handle(handle, &decoder_file);
if (ret != MPG123_OK)
throw love::Exception("Could not open decoder.");
// mpg123_getformat should be able to tell us the properties of the stream's first frame.
long rate = 0;
ret = mpg123_getformat(handle, &rate, &channels, nullptr);
if (ret == MPG123_ERR)
throw love::Exception("Could not get stream information.");
// I forgot what this was about.
if (channels == 0)
channels = 2;
// Force signed 16-bit output.
mpg123_param(handle, MPG123_FLAGS, (channels == 2 ? MPG123_FORCE_STEREO : MPG123_MONO_MIX), 0);
mpg123_format_none(handle);
mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16);
sampleRate = (int) rate;
// Force a read, so we can determine if it's actually an mp3
struct mpg123_frameinfo info;
ret = mpg123_info(handle, &info);
if (ret != MPG123_OK)
throw love::Exception("Could not read mp3 data.");
}
catch (love::Exception &)
{
mpg123_delete(handle);
throw;
}
}
Mpg123Decoder::~Mpg123Decoder()
{
mpg123_delete(handle);
}
bool Mpg123Decoder::accepts(const std::string &ext)
{
static const std::string supported[] =
{
"mp3", ""
};
for (int i = 0; !(supported[i].empty()); i++)
{
if (supported[i].compare(ext) == 0)
return true;
}
return false;
}
void Mpg123Decoder::quit()
{
if (inited)
mpg123_exit();
}
love::sound::Decoder *Mpg123Decoder::clone()
{
return new Mpg123Decoder(data.get(), bufferSize);
}
int Mpg123Decoder::decode()
{
int size = 0;
while (size < bufferSize && !eof)
{
size_t numbytes = 0;
int res = mpg123_read(handle, (unsigned char *) buffer + size, bufferSize - size, &numbytes);
switch (res)
{
case MPG123_NEED_MORE:
case MPG123_NEW_FORMAT:
case MPG123_OK:
size += numbytes;
continue;
case MPG123_DONE:
size += numbytes;
eof = true;
default:
return size;
}
}
return size;
}
bool Mpg123Decoder::seek(double s)
{
off_t offset = (off_t) (s * (double) sampleRate);
if (offset < 0)
return false;
if (mpg123_seek(handle, offset, SEEK_SET) >= 0)
{
eof = false;
return true;
}
else
return false;
}
bool Mpg123Decoder::rewind()
{
eof = false;
if (mpg123_seek(handle, 0, SEEK_SET) >= 0)
return true;
else
return false;
}
bool Mpg123Decoder::isSeekable()
{
return true;
}
int Mpg123Decoder::getChannelCount() const
{
return channels;
}
int Mpg123Decoder::getBitDepth() const
{
return 16;
}
double Mpg123Decoder::getDuration()
{
// Only calculate the duration if we haven't done so already.
if (duration == -2.0)
{
mpg123_scan(handle);
off_t length = mpg123_length(handle);
if (length == MPG123_ERR || length < 0)
duration = -1.0;
else
duration = (double) length / (double) sampleRate;
}
return duration;
}
} // lullaby
} // sound
} // love
#endif // LOVE_NOMPG123
+2 -10
View File
@@ -30,10 +30,7 @@
#include "GmeDecoder.h"
#include "WaveDecoder.h"
#include "FLACDecoder.h"
#ifndef LOVE_NOMPG123
# include "Mpg123Decoder.h"
#endif // LOVE_NOMPG123
#include "MP3Decoder.h"
#ifdef LOVE_SUPPORT_COREAUDIO
# include "CoreAudioDecoder.h"
@@ -73,9 +70,6 @@ Sound::Sound()
Sound::~Sound()
{
#ifndef LOVE_NOMPG123
Mpg123Decoder::quit();
#endif // LOVE_NOMPG123
}
const char *Sound::getName() const
@@ -92,9 +86,7 @@ sound::Decoder *Sound::newDecoder(love::filesystem::FileData *data, int bufferSi
#ifndef LOVE_NO_MODPLUG
DecoderImplFor<ModPlugDecoder>(),
#endif // LOVE_NO_MODPLUG
#ifndef LOVE_NOMPG123
DecoderImplFor<Mpg123Decoder>(),
#endif // LOVE_NOMPG123
DecoderImplFor<MP3Decoder>(),
DecoderImplFor<VorbisDecoder>(),
#ifdef LOVE_SUPPORT_GME
DecoderImplFor<GmeDecoder>(),
+1 -1
View File
@@ -37,7 +37,7 @@ namespace lullaby
/**
* The love.sound.lullaby module is the custom sound decoder module for LOVE. Instead
* of using an intermediate library like SDL_sound, it interfaces with relevant libraries
* directly (libmpg123, libmodplug, libFLAC, etc).
* directly (libvorbis, dr_mp3, dr_flac, etc).
*
* It was Mike that came up with the name Lullaby, which we both instantly recognized as awesome.
**/
+2 -5
View File
@@ -36,9 +36,6 @@ namespace thread
class Channel : public love::Object
{
// FOR WRAPPER USE ONLY
friend int w_Channel_performAtomic(lua_State *);
public:
static love::Type type;
@@ -57,11 +54,11 @@ public:
bool hasRead(uint64 id) const;
void clear();
private:
void lockMutex();
void unlockMutex();
private:
MutexRef mutex;
ConditionalRef cond;
std::queue<Variant> queue;
+2 -1
View File
@@ -21,6 +21,7 @@
#include "LuaThread.h"
#include "event/Event.h"
#include "common/config.h"
#include "common/runtime.h"
#ifdef LOVE_BUILD_STANDALONE
extern "C" int luaopen_love(lua_State * L);
@@ -76,7 +77,7 @@ void LuaThread::threadFunction()
int pushedargs = (int) args.size();
for (int i = 0; i < pushedargs; i++)
args[i].toLua(L);
luax_pushvariant(L, args[i]);
args.clear();
+5 -5
View File
@@ -34,7 +34,7 @@ int w_Channel_push(lua_State *L)
{
Channel *c = luax_checkchannel(L, 1);
luax_catchexcept(L, [&]() {
Variant var = Variant::fromLua(L, 2);
Variant var = luax_checkvariant(L, 2);
if (var.getType() == Variant::UNKNOWN)
luaL_argerror(L, 2, "boolean, number, string, love type, or table expected");
uint64 id = c->push(var);
@@ -48,7 +48,7 @@ int w_Channel_supply(lua_State *L)
Channel *c = luax_checkchannel(L, 1);
bool result = false;
luax_catchexcept(L, [&]() {
Variant var = Variant::fromLua(L, 2);
Variant var = luax_checkvariant(L, 2);
if (var.getType() == Variant::UNKNOWN)
luaL_argerror(L, 2, "boolean, number, string, love type, or table expected");
if (lua_isnumber(L, 3))
@@ -66,7 +66,7 @@ int w_Channel_pop(lua_State *L)
Channel *c = luax_checkchannel(L, 1);
Variant var;
if (c->pop(&var))
var.toLua(L);
luax_pushvariant(L, var);
else
lua_pushnil(L);
return 1;
@@ -84,7 +84,7 @@ int w_Channel_demand(lua_State *L)
result = c->demand(&var);
if (result)
var.toLua(L);
luax_pushvariant(L, var);
else
lua_pushnil(L);
return 1;
@@ -95,7 +95,7 @@ int w_Channel_peek(lua_State *L)
Channel *c = luax_checkchannel(L, 1);
Variant var;
if (c->peek(&var))
var.toLua(L);
luax_pushvariant(L, var);
else
lua_pushnil(L);
return 1;
+1
View File
@@ -23,6 +23,7 @@
// LOVE
#include "Channel.h"
#include "common/runtime.h"
namespace love
{
+1 -1
View File
@@ -39,7 +39,7 @@ int w_Thread_start(lua_State *L)
for (int i = 0; i < nargs; ++i)
{
luax_catchexcept(L, [&]() {
args.push_back(Variant::fromLua(L, i+2));
args.push_back(luax_checkvariant(L, i+2));
});
if (args.back().getType() == Variant::UNKNOWN)
+1
View File
@@ -23,6 +23,7 @@
// LOVE
#include "ThreadModule.h"
#include "common/runtime.h"
namespace love
{