-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors building with SDL backend on windows/mac #1335
Comments
There's multiple places where other platform's implementations take precedence over SDL. If I move the SDL implementation above them, the examples build. Here's my patch so far: patchdiff --git a/CMakeLists.txt b/CMakeLists.txt
index ca16bdc16..a284e8f65 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -912,7 +912,7 @@ if(WIN32)
endif(MINGW AND NOT SHARED)
endif(WIN32)
-if(MACOSX)
+if(MACOSX AND NOT ALLEGRO_SDL)
list(APPEND LIBRARY_SOURCES ${ALLEGRO_SRC_MACOSX_FILES})
find_library(APPKIT_LIBRARY AppKit)
find_library(IOKIT_LIBRARY IOKit)
diff --git a/addons/main/CMakeLists.txt b/addons/main/CMakeLists.txt
index c8a589d69..51f89add9 100644
--- a/addons/main/CMakeLists.txt
+++ b/addons/main/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(MACOSX)
+if(MACOSX AND NOT ALLEGRO_SDL)
set(MAIN_SOURCES osx_main.m)
set(SUPPORT_ALLEGRO_MAIN 1)
endif(MACOSX)
diff --git a/include/allegro5/internal/alconfig.h b/include/allegro5/internal/alconfig.h
index 50367595a..f637a9c79 100644
--- a/include/allegro5/internal/alconfig.h
+++ b/include/allegro5/internal/alconfig.h
@@ -29,7 +29,9 @@
-#if defined ALLEGRO_WATCOM
+#if defined ALLEGRO_SDL
+ #include "allegro5/platform/allegro_sdl_config.h"
+#elif defined ALLEGRO_WATCOM
#include "allegro5/platform/alwatcom.h"
#elif defined ALLEGRO_MINGW32
#include "allegro5/platform/almngw32.h"
@@ -47,8 +49,6 @@
#include "allegro5/platform/alraspberrypicfg.h"
#elif defined ALLEGRO_UNIX
#include "allegro5/platform/alucfg.h"
-#elif defined ALLEGRO_SDL
- #include "allegro5/platform/allegro_sdl_config.h"
#else
#error platform not supported
#endif
diff --git a/src/allegro.c b/src/allegro.c
index b63c50f75..c33b7fb84 100644
--- a/src/allegro.c
+++ b/src/allegro.c
@@ -35,7 +35,7 @@ uint32_t al_get_allegro_version(void)
*/
int al_run_main(int argc, char **argv, int (*user_main)(int, char **))
{
-#ifdef ALLEGRO_MACOSX
+#if defined ALLEGRO_MACOSX && !defined ALLEGRO_SDL
return _al_osx_run_main(argc, argv, user_main);
#else
return user_main(argc, argv);
diff --git a/src/system.c b/src/system.c
index bbf81d2b0..f3a7799e1 100644
--- a/src/system.c
+++ b/src/system.c
@@ -98,7 +98,12 @@ static void shutdown_system_driver(void)
*/
static ALLEGRO_PATH *early_get_exename_path(void)
{
-#if defined(ALLEGRO_WINDOWS)
+#if defined(ALLEGRO_SDL)
+ char* p = SDL_GetBasePath();
+ ALLEGRO_PATH *path = al_create_path_for_directory(p);
+ SDL_free(p);
+ return path;
+#elif defined(ALLEGRO_WINDOWS)
return _al_win_get_path(ALLEGRO_EXENAME_PATH);
#elif defined(ALLEGRO_MACOSX)
return _al_osx_get_path(ALLEGRO_EXENAME_PATH);
@@ -108,11 +113,6 @@ static ALLEGRO_PATH *early_get_exename_path(void)
return _al_unix_get_path(ALLEGRO_EXENAME_PATH);
#elif defined(ALLEGRO_ANDROID)
return _al_android_get_path(ALLEGRO_EXENAME_PATH);
-#elif defined(ALLEGRO_SDL)
- char* p = SDL_GetBasePath();
- ALLEGRO_PATH *path = al_create_path_for_directory(p);
- SDL_free(p);
- return path;
#else
#error early_get_exename_path not implemented
#endif
diff --git a/src/tls.c b/src/tls.c
index 9e0903f1b..546df6c08 100644
--- a/src/tls.c
+++ b/src/tls.c
@@ -164,7 +164,7 @@ static void initialize_tls_values(thread_local_state *tls)
#if defined(ALLEGRO_CFG_DLL_TLS)
#include "tls_dll.inc"
-#elif defined(ALLEGRO_MACOSX) || defined(ALLEGRO_IPHONE) || defined(ALLEGRO_ANDROID) || defined(ALLEGRO_RASPBERRYPI)
+#elif !defined(ALLEGRO_SDL) && (defined(ALLEGRO_MACOSX) || defined(ALLEGRO_IPHONE) || defined(ALLEGRO_ANDROID) || defined(ALLEGRO_RASPBERRYPI))
#include "tls_pthread.inc"
#else
#include "tls_native.inc" But when I run the example I get this error:
I copied all the lib/ files into examples/, but same error. (also had to build with |
OK, just had to disable some stuff in a similar manner in the images addon. patchdiff --git a/addons/image/CMakeLists.txt b/addons/image/CMakeLists.txt
index 710a49744..7e6732937 100644
--- a/addons/image/CMakeLists.txt
+++ b/addons/image/CMakeLists.txt
@@ -72,7 +72,7 @@ if(WANT_NATIVE_IMAGE_LOADER)
endif(SUPPORT_GDIPLUS)
endif(WIN32)
- if (MACOSX)
+ if (MACOSX AND NOT ALLEGRO_SDL)
set(ALLEGRO_CFG_IIO_SUPPORT_PNG 1)
set(ALLEGRO_CFG_IIO_SUPPORT_JPG 1)
list(APPEND IMAGE_SOURCES macosx.m)
diff --git a/addons/image/iio.c b/addons/image/iio.c
index c593438d7..ac64b4196 100644
--- a/addons/image/iio.c
+++ b/addons/image/iio.c
@@ -150,7 +150,7 @@ bool al_init_image_addon(void)
}
#endif
-#ifdef ALLEGRO_MACOSX
+#if defined ALLEGRO_MACOSX && !defined ALLEGRO_SDL
success |= _al_osx_register_image_loader();
#endif
#endif Now the example works. This is quite a lot of conditions to change, so I'm looking into simply setting |
#1336 enables building some simple programs with the SDL backend, but anything using threads throws an error at runtime:
I think this is because EDIT: seems
|
Any idea on how to progress here? |
I think a first step would be to understand how you're meant to use SDL on OSX. Do they have functionality similar to allegro_main-addon? |
From memory, SDL runs on the main thread - so it's OK to call Cocoa directly but the downside is that you need to call SDL_PumpEvents frequently (directly or indirectly via one of the other SDL_ event functions) otherwise you get the beachball. |
The SDL backend works for building with emscripten, but I can't get it to build on Windows or Mac.
For reference, I am using SDL 2.0.22. I tried with master allegro and with most recent published version 5.2.7.0, same issue.
Related: #1002
The text was updated successfully, but these errors were encountered: