From 12c22be647c4040250d46b5c16b966ea0ea096cb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 17 Mar 2009 03:58:53 +0000 Subject: [PATCH] Date: Fri, 6 Mar 2009 12:41:17 -0800 From: scott mc Subject: Re: [SDL] patch for building on haiku Ok. I've combined the various Haiku patches for the SDL-1.2 branch into one .diff file --- configure.in | 16 ++++++++++++---- include/SDL_platform.h | 8 ++++++++ include/begin_code.h | 2 +- src/video/bwindow/SDL_sysvideo.cc | 10 +++++++--- src/video/bwindow/SDL_sysyuv.cc | 2 +- src/video/bwindow/SDL_sysyuv.h | 2 +- test/configure.in | 2 +- test/testplatform.c | 2 ++ 8 files changed, 33 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index 252bdbda4..a641df1ec 100644 --- a/configure.in +++ b/configure.in @@ -40,7 +40,7 @@ AC_SUBST(LT_REVISION) AC_SUBST(LT_AGE) dnl Detect the canonical build and host environments -AC_CONFIG_AUX_DIRS($srcdir/build-scripts) +AC_CONFIG_AUX_DIR([build-scripts]) AC_CANONICAL_HOST AC_C_BIGENDIAN if test x$ac_cv_c_bigendian = xyes; then @@ -2493,7 +2493,7 @@ case "$host" in SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420" SDL_LIBS="-lSDLmain $SDL_LIBS" ;; - *-*-beos*) + *-*-beos* | *-*-haiku*) ARCH=beos ac_default_prefix=/boot/develop/tools/gnupro CheckDummyVideo @@ -2536,8 +2536,16 @@ case "$host" in fi # Set up files for the shared object loading library if test x$enable_loadso = xyes; then - AC_DEFINE(SDL_LOADSO_BEOS) - SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c" + case "$host" in + *-*-beos*) + AC_DEFINE(SDL_LOADSO_BEOS) + SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c" + ;; + *-*-haiku*) + AC_DEFINE(SDL_LOADSO_DLOPEN) + SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c" + ;; + esac have_loadso=yes fi # The BeOS platform requires special setup. diff --git a/include/SDL_platform.h b/include/SDL_platform.h index 79544e9ba..2b14103b0 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -33,6 +33,10 @@ #undef __BEOS__ #define __BEOS__ 1 #endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) #undef __BSDI__ #define __BSDI__ 1 @@ -45,6 +49,10 @@ #undef __FREEBSD__ #define __FREEBSD__ 1 #endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif #if defined(hpux) || defined(__hpux) || defined(__hpux__) #undef __HPUX__ #define __HPUX__ 1 diff --git a/include/begin_code.h b/include/begin_code.h index 3cc620404..f70fe9477 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -33,7 +33,7 @@ /* Some compilers use a special export keyword */ #ifndef DECLSPEC -# if defined(__BEOS__) +# if defined(__BEOS__) || defined(__HAIKU__) # if defined(__GNUC__) # define DECLSPEC __declspec(dllexport) # else diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc index 04e46067c..d0ffe9929 100644 --- a/src/video/bwindow/SDL_sysvideo.cc +++ b/src/video/bwindow/SDL_sysvideo.cc @@ -57,7 +57,7 @@ static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface); static void BE_FreeHWSurface(_THIS, SDL_Surface *surface); static int BE_ToggleFullScreen(_THIS, int fullscreen); -static SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display); +SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display); /* OpenGL functions */ #if SDL_VIDEO_OPENGL @@ -637,8 +637,12 @@ int BE_GL_LoadLibrary(_THIS, const char *path) int32 cookie = 0; while (get_next_image_info(0,&cookie,&info) == B_OK) { void *location = NULL; - if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { - _this->gl_config.dll_handle = (void*)cookie; +#ifdef __HAIKU__ + if (get_image_symbol(info.id,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { // This is how it actually works in Haiku +#else + if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { // I don't know if that *did* work in BeOS +#endif + _this->gl_config.dll_handle = (void*)info.id; _this->gl_config.driver_loaded = 1; SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", SDL_arraysize(_this->gl_config.driver_path)); } diff --git a/src/video/bwindow/SDL_sysyuv.cc b/src/video/bwindow/SDL_sysyuv.cc index 37f907633..552fc7a7f 100644 --- a/src/video/bwindow/SDL_sysyuv.cc +++ b/src/video/bwindow/SDL_sysyuv.cc @@ -94,7 +94,7 @@ BBitmap * BE_GetOverlayBitmap(BRect bounds, color_space cs) { // See [btw: Cb=U, Cr=V] // See also http://www.fourcc.org/indexyuv.htm -enum color_space convert_color_space(Uint32 format) { +color_space convert_color_space(Uint32 format) { switch (format) { case SDL_YV12_OVERLAY: return B_YUV9; diff --git a/src/video/bwindow/SDL_sysyuv.h b/src/video/bwindow/SDL_sysyuv.h index aafaa2707..6681d49fd 100644 --- a/src/video/bwindow/SDL_sysyuv.h +++ b/src/video/bwindow/SDL_sysyuv.h @@ -62,7 +62,7 @@ struct private_yuvhwdata }; extern BBitmap * BE_GetOverlayBitmap(BRect bounds, color_space cs); -extern SDL_Overlay* BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface* display); +SDL_Overlay* BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface* display); extern int BE_LockYUVOverlay(_THIS, SDL_Overlay* overlay); extern void BE_UnlockYUVOverlay(_THIS, SDL_Overlay* overlay); extern int BE_DisplayYUVOverlay(_THIS, SDL_Overlay* overlay, SDL_Rect* src, SDL_Rect* dst); diff --git a/test/configure.in b/test/configure.in index 4455bb9c0..7c25c17af 100644 --- a/test/configure.in +++ b/test/configure.in @@ -20,7 +20,7 @@ case "$host" in MATHLIB="" SYS_GL_LIBS="-lopengl32" ;; - *-*-beos*) + *-*-beos* | *-*-haiku*) EXE="" MATHLIB="" SYS_GL_LIBS="-lGL" diff --git a/test/testplatform.c b/test/testplatform.c index a68f42b02..c29a6a8ed 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -162,6 +162,8 @@ int main(int argc, char *argv[]) "Dreamcast" #elif __FREEBSD__ "FreeBSD" +#elif __HAIKU__ + "Haiku" #elif __HPUX__ "HP-UX" #elif __IRIX__