Browse Source

Fixes to make Löve compile on Windows 10 UWP

T-Bone 9 years ago
parent
commit
b2291fb62a

+ 7 - 0
src/common/config.h

@@ -24,6 +24,11 @@
 // Platform stuff.
 #if defined(WIN32) || defined(_WIN32)
 #	define LOVE_WINDOWS 1
+#if WINAPI_FAMILY==WINAPI_FAMILY_APP
+#	define LOVE_WINDOWS_UWP 1
+#	define LOVE_NO_MODPLUG 1
+#	define LOVE_NO_MPG123 1
+#endif
 #endif
 #if defined(linux) || defined(__linux) || defined(__linux__)
 # define LOVE_LINUX 1
@@ -76,7 +81,9 @@
 #endif
 
 #if defined(LOVE_WINDOWS)
+#ifndef LOVE_WINDOWS_UWP
 #	define LOVE_LEGENDARY_CONSOLE_IO_HACK
+#endif // LOVE_WINDOWS_UWP
 #	define NOMINMAX
 #endif
 

+ 3 - 1
src/modules/filesystem/physfs/Filesystem.cpp

@@ -519,7 +519,9 @@ std::string Filesystem::getAppdataDirectory()
 {
 	if (appdata.empty())
 	{
-#ifdef LOVE_WINDOWS
+#ifdef LOVE_WINDOWS_UWP
+		appdata = getUserDirectory();
+#elif LOVE_WINDOWS
 		wchar_t *w_appdata = _wgetenv(L"APPDATA");
 		appdata = to_utf8(w_appdata);
 		replace_char(appdata, '\\', '/');

+ 1 - 1
src/modules/filesystem/physfs/Filesystem.h

@@ -62,7 +62,7 @@ public:
 	bool mount(const char *archive, const char *mountpoint, bool appendToPath = false);
 	bool unmount(const char *archive);
 
-	File *newFile(const char *filename) const;
+	love::filesystem::File *newFile(const char *filename) const;
 
 	FileData *newFileData(void *data, unsigned int size, const char *filename) const;
 	FileData *newFileData(const char *b64, const char *filename) const;

+ 3 - 1
src/modules/love/love.cpp

@@ -307,7 +307,9 @@ int luaopen_love(lua_State *L)
 	lua_pushcfunction(L, w_love_isVersionCompatible);
 	lua_setfield(L, -2, "isVersionCompatible");
 
-#ifdef LOVE_WINDOWS
+#ifdef LOVE_WINDOWS_UWP
+	lua_pushstring(L, "Universal Windows Platform");
+#elif LOVE_WINDOWS
 	lua_pushstring(L, "Windows");
 #elif defined(LOVE_MACOSX)
 	lua_pushstring(L, "OS X");

+ 4 - 0
src/modules/sound/lullaby/Mpg123Decoder.cpp

@@ -24,6 +24,8 @@
 
 #include <iostream>
 
+#ifndef LOVE_NO_MPG123
+
 namespace love
 {
 namespace sound
@@ -286,3 +288,5 @@ double Mpg123Decoder::getDuration()
 } // lullaby
 } // sound
 } // love
+
+#endif // LOVE_NO_MPG123

+ 4 - 0
src/modules/sound/lullaby/Mpg123Decoder.h

@@ -25,6 +25,8 @@
 #include "common/Data.h"
 #include "Decoder.h"
 
+#ifndef LOVE_NO_MPG123
+
 // libmpg123
 #ifdef LOVE_APPLE_USE_FRAMEWORKS
 #include <mpg123/mpg123.h>
@@ -88,4 +90,6 @@ private:
 } // sound
 } // love
 
+#endif // LOVE_NO_MPG123
+
 #endif // LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H

+ 6 - 6
src/modules/sound/lullaby/Sound.cpp

@@ -30,9 +30,9 @@
 #include "WaveDecoder.h"
 //#include "FLACDecoder.h"
 
-#ifndef LOVE_NOMPG123
+#ifndef LOVE_NO_MPG123
 #	include "Mpg123Decoder.h"
-#endif // LOVE_NOMPG123
+#endif // LOVE_NO_MPG123
 
 #ifdef LOVE_SUPPORT_COREAUDIO
 #	include "CoreAudioDecoder.h"
@@ -51,9 +51,9 @@ Sound::Sound()
 
 Sound::~Sound()
 {
-#ifndef LOVE_NOMPG123
+#ifndef LOVE_NO_MPG123
 	Mpg123Decoder::quit();
-#endif // LOVE_NOMPG123
+#endif // LOVE_NO_MPG123
 }
 
 const char *Sound::getName() const
@@ -75,10 +75,10 @@ sound::Decoder *Sound::newDecoder(love::filesystem::FileData *data, int bufferSi
 	else if (ModPlugDecoder::accepts(ext))
 		decoder = new ModPlugDecoder(data, ext, bufferSize);
 #endif // LOVE_NO_MODPLUG
-#ifndef LOVE_NOMPG123
+#ifndef LOVE_NO_MPG123
 	else if (Mpg123Decoder::accepts(ext))
 		decoder = new Mpg123Decoder(data, ext, bufferSize);
-#endif // LOVE_NOMPG123
+#endif // LOVE_NO_MPG123
 	else if (VorbisDecoder::accepts(ext))
 		decoder = new VorbisDecoder(data, ext, bufferSize);
 #ifdef LOVE_SUPPORT_GME

+ 12 - 6
src/modules/system/System.cpp

@@ -147,12 +147,18 @@ bool System::openURL(const std::string &url) const
 	// Unicode-aware WinAPI functions don't accept UTF-8, so we need to convert.
 	std::wstring wurl = to_widestr(url);
 
-	HINSTANCE result = ShellExecuteW(nullptr,
-	                                 L"open",
-	                                 wurl.c_str(),
-	                                 nullptr,
-	                                 nullptr,
-	                                 SW_SHOW);
+	HINSTANCE result = 0;
+
+	#if !defined(LOVE_WINDOWS_UWP)
+
+	result = ShellExecuteW(nullptr,
+		L"open",
+		wurl.c_str(),
+		nullptr,
+		nullptr,
+		SW_SHOW);
+
+	#endif // LOVE_WINDOWS_UWP
 
 	return (int) result > 32;
 

+ 9 - 2
src/modules/window/sdl/Window.cpp

@@ -229,7 +229,14 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
 	};
 
 	// OpenGL ES 3+ contexts are only properly supported in SDL 2.0.4+.
-	if (hasSDL203orEarlier)
+	bool removeES3 = hasSDL203orEarlier;
+
+	// While UWP SDL is above 2.0.4, it still doesn't support OpenGL ES 3+
+#ifdef LOVE_WINDOWS_UWP
+	removeES3 = true;
+#endif
+	
+	if (removeES3)
 	{
 		auto it = attribslist.begin();
 		while (it != attribslist.end())
@@ -1019,7 +1026,7 @@ int Window::showMessageBox(const MessageBoxData &data)
 
 void Window::requestAttention(bool continuous)
 {
-#if defined(LOVE_WINDOWS)
+#if defined(LOVE_WINDOWS) && !defined(LOVE_WINDOWS_UWP)
 
 	if (hasFocus())
 		return;