for non-OSX hosts, make GNU Autotools revert to using SDL 1.x, if SDL 2.x can't be found

This commit is contained in:
David Ludwig 2017-09-08 23:43:01 +00:00
parent 68ee5f23f9
commit 1c0e8655dc
5 changed files with 60 additions and 16 deletions

View File

@ -30,6 +30,12 @@
#include "util_windows.h"
#endif
// Import SDL-backend-specific functions
#ifdef USE_SDL_VIDEO
extern void update_sdl_video(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
extern void update_sdl_video(SDL_Surface *screen, int numrects, SDL_Rect *rects);
#endif
// Glue for SDL and X11 support
#ifdef TEST_VOSF_PERFORMANCE
#define MONITOR_INIT /* nothing */
@ -514,8 +520,7 @@ static void update_display_window_vosf(VIDEO_DRV_WIN_INIT)
VIDEO_DRV_UNLOCK_PIXELS;
#ifdef USE_SDL_VIDEO
//SDL_UpdateRect(drv->s, 0, y1, VIDEO_MODE_X, height);
update_sdl_video();
update_sdl_video(drv->s, 0, y1, VIDEO_MODE_X, height);
#else
if (VIDEO_DRV_HAVE_SHM)
XShmPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height, 0);
@ -559,8 +564,7 @@ static void update_display_dga_vosf(VIDEO_DRV_DGA_INIT)
i2 += scr_bytes_per_row;
}
#ifdef USE_SDL_VIDEO
//SDL_UpdateRect(drv->s, 0, 0, VIDEO_MODE_X, VIDEO_MODE_Y);
update_sdl_video();
update_sdl_video(drv->s, 0, 0, VIDEO_MODE_X, VIDEO_MODE_Y);
#endif
VIDEO_DRV_UNLOCK_PIXELS;
return;
@ -666,8 +670,7 @@ static void update_display_dga_vosf(VIDEO_DRV_DGA_INIT)
#endif
}
#ifdef USE_SDL_VIDEO
//SDL_UpdateRects(drv->s, bbi, bb);
update_sdl_video();
update_sdl_video(drv->s, bbi, bb);
#endif
VIDEO_DRV_UNLOCK_PIXELS;
}

View File

@ -28,6 +28,7 @@
#include <SDL_mutex.h>
#include <SDL_audio.h>
#include <SDL_version.h>
#define DEBUG 0
#include "debug.h"
@ -87,7 +88,7 @@ static bool open_sdl_audio(void)
}
SDL_AudioSpec audio_spec;
SDL_zero(audio_spec);
memset(&audio_spec, 0, sizeof(audio_spec));
audio_spec.freq = audio_sample_rates[audio_sample_rate_index] >> 16;
audio_spec.format = (audio_sample_sizes[audio_sample_size_index] == 8) ? AUDIO_U8 : AUDIO_S16MSB;
audio_spec.channels = audio_channel_counts[audio_channel_count_index];
@ -101,18 +102,25 @@ static bool open_sdl_audio(void)
return false;
}
#if SDL_VERSION_ATLEAST(2,0,0)
// HACK: workaround a bug in SDL pre-2.0.6 (reported via https://bugzilla.libsdl.org/show_bug.cgi?id=3710 )
// whereby SDL does not update audio_spec.size
if (audio_spec.size == 0) {
audio_spec.size = (SDL_AUDIO_BITSIZE(audio_spec.format) / 8) * audio_spec.channels * audio_spec.samples;
}
#endif
#if defined(BINCUE)
OpenAudio_bincue(audio_spec.freq, audio_spec.format, audio_spec.channels,
audio_spec.silence);
#endif
#if SDL_VERSION_ATLEAST(2,0,0)
const char * driver_name = SDL_GetCurrentAudioDriver();
#else
char driver_name[32];
SDL_AudioDriverName(driver_name, sizeof(driver_name) - 1);
#endif
printf("Using SDL/%s audio output\n", driver_name ? driver_name : "");
silence_byte = audio_spec.silence;
SDL_PauseAudio(0);

View File

@ -587,6 +587,16 @@ static void migrate_screen_prefs(void)
#endif
}
void update_sdl_video(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
{
SDL_UpdateRect(screen, x, y, w, h);
}
void update_sdl_video(SDL_Surface *screen, int numrects, SDL_Rect *rects)
{
SDL_UpdateRects(screen, numrects, rects);
}
/*
* Display "driver" classes

View File

@ -883,7 +883,18 @@ static int update_sdl_video()
return 0;
}
static int update_sdl_video(SDL_Surface *s, int x, int y, int w, int h)
void update_sdl_video(SDL_Surface *s, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
{
// HACK, dludwig@pobox.com: for now, just update the whole screen, via
// VideoInterrupt(), which gets called on the main thread.
//
// TODO: make sure SDL_Renderer resources get displayed, if and when
// MacsBug is running (and VideoInterrupt() might not get called)
//
// TODO: cache rects to update, then use rects in present_sdl_video()
}
void update_sdl_video(SDL_Surface *s, int numrects, SDL_Rect *rects)
{
// HACK, dludwig@pobox.com: for now, just update the whole screen, via
// VideoInterrupt(), which gets called on the main thread.
@ -892,7 +903,6 @@ static int update_sdl_video(SDL_Surface *s, int x, int y, int w, int h)
// MacsBug is running (and VideoInterrupt() might not get called)
//
// TODO: cache rects to update, then use rects in present_sdl_video()
return 0;
}
void driver_base::set_video_mode(int flags)

View File

@ -300,13 +300,26 @@ if [[ "x$WANT_SDL" = "xyes" ]]; then
ac_cv_framework_SDL=no
fi
if [[ "x$ac_cv_framework_SDL" = "xno" ]]; then
PKG_CHECK_MODULES([sdl2], [sdl2 >= 2.0], [
CFLAGS="$CFLAGS $sdl2_CFLAGS"
CXXFLAGS="$CXXFLAGS $sdl2_CFLAGS"
LIBS="$LIBS $sdl2_LIBS"
], [
WANT_SDL=no
])
WANT_SDL_VERSION_MAJOR=2
if [[ "x$WANT_SDL_VERSION_MAJOR" = "x2" ]]; then
PKG_CHECK_MODULES([sdl2], [sdl2 >= 2.0], [
CFLAGS="$CFLAGS $sdl2_CFLAGS"
CXXFLAGS="$CXXFLAGS $sdl2_CFLAGS"
LIBS="$LIBS $sdl2_LIBS"
], [
WANT_SDL_VERSION_MAJOR=1
])
fi
if [[ "x$WANT_SDL_VERSION_MAJOR" = "x1" ]]; then
PKG_CHECK_MODULES([sdl], [sdl >= 1.2], [
CFLAGS="$CFLAGS $sdl_CFLAGS"
CXXFLAGS="$CXXFLAGS $sdl_CFLAGS"
LIBS="$LIBS $sdl_LIBS"
], [
WANT_SDL=no
WANT_SDL_VERSION_MAJOR=
])
fi
fi
SDL_SUPPORT=`echo "$SDL_SUPPORT" | sed -e "s/^ //"`
else