diff --git a/Makefile.in b/Makefile.in index 897a43c..824fdd9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -264,8 +264,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ SCM_REVISION = @SCM_REVISION@ +SDL2_CONFIG = @SDL2_CONFIG@ +SDL2_FRAMEWORK = @SDL2_FRAMEWORK@ SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ SDL_CXXFLAGS = @SDL_CXXFLAGS@ SDL_LIBS = @SDL_LIBS@ SET_MAKE = @SET_MAKE@ diff --git a/README b/README index ec4cca5..1d0bd1e 100644 --- a/README +++ b/README @@ -9,7 +9,7 @@ COMPILE/INSTALL/RUN Windows ------- Windows users can download and run a pre-compiled Windows binary -[here](https://github.com/ttsiodras/MandelbrotSSE/releases/download/2.7/mandelSSE-win32-2.7.zip). +[here](https://github.com/ttsiodras/MandelbrotSSE/releases/download/2.8/mandelSSE-win32-2.8.zip). After decompressing, you can simply execute either one of the two .bat files. The 'autopilot' one zooms in a specific location, while the other @@ -22,11 +22,13 @@ cross-compilation instructions later in this document. For Linux/BSD/OSX users ----------------------- -Make sure you have libSDL installed - then... +Make sure you have libSDL2 installed - then... $ ./configure $ make +You can then simply... + $ src/mandelSSE -h Usage: ./src/mandelSSE [-a|-m] [-h] [-f rate] [WIDTH HEIGHT] @@ -40,7 +42,7 @@ Make sure you have libSDL installed - then... If WIDTH and HEIGHT are not provided, they default to: 1024 768 $ src/mandelSSE - (Runs in autopilot in 1024x768 window, using XaoS) + (Runs in autopilot in a 1024x768 window) $ src/mandelSSE -m 1280 720 (Runs in mouse-driven mode, in a 1280x720 window) @@ -183,29 +185,27 @@ Have a look! Cross compiling for Windows via MinGW ------------------------------------- -After decompressing the SDL 1.2.15 tarball, install MinGW: +After decompressing the SDL 2.0.22 tarball, install MinGW: $ sudo apt install gcc-mingw-w64 Then download the source code of libSDL and compile it as follows: - $ cd SDL-1.2.15 - $ ./configure --host=x86_64-w64-mingw32 --disable-dga \ - --disable-video-dga --disable-video-x11-dgamouse \ + $ cd SDL-2.0.22 + $ ./configure --host=x86_64-w64-mingw32 \ --disable-video-x11 --disable-x11-shared \ - --prefix=/usr/local/packages/SDL-1.2.15-win32 + --prefix=/usr/local/packages/SDL-2.0.22-win32 $ make $ sudo make install -Finally, come back to this source folder, and compile the XaoS -version: +Finally, come back to this source folder, and compile: $ ./configure --host=x86_64-w64-mingw32 \ - --with-sdl-prefix=/usr/local/packages/SDL-1.2.15-win32 \ + --with-sdl-prefix=/usr/local/packages/SDL-2.0.22-win32 \ --disable-sdltest $ make $ cp src/mandelSSE.exe \ - /usr/local/packages/SDL-1.2.15-win32/bin/SDL.dll \ + /usr/local/packages/SDL-2.0.22-win32/bin/SDL.dll \ /some/path/for/Windows/ MISC diff --git a/README.md b/README.md index 914d946..1d0bd1e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ COMPILE/INSTALL/RUN Windows ------- Windows users can download and run a pre-compiled Windows binary -[here](https://github.com/ttsiodras/MandelbrotSSE/releases/download/2.7/mandelSSE-win32-2.7.zip). +[here](https://github.com/ttsiodras/MandelbrotSSE/releases/download/2.8/mandelSSE-win32-2.8.zip). After decompressing, you can simply execute either one of the two .bat files. The 'autopilot' one zooms in a specific location, while the other @@ -22,7 +22,7 @@ cross-compilation instructions later in this document. For Linux/BSD/OSX users ----------------------- -Make sure you have libSDL installed - then... +Make sure you have libSDL2 installed - then... $ ./configure $ make @@ -42,7 +42,7 @@ You can then simply... If WIDTH and HEIGHT are not provided, they default to: 1024 768 $ src/mandelSSE - (Runs in autopilot in 1024x768 window, using XaoS) + (Runs in autopilot in a 1024x768 window) $ src/mandelSSE -m 1280 720 (Runs in mouse-driven mode, in a 1280x720 window) @@ -185,29 +185,27 @@ Have a look! Cross compiling for Windows via MinGW ------------------------------------- -After decompressing the SDL 1.2.15 tarball, install MinGW: +After decompressing the SDL 2.0.22 tarball, install MinGW: $ sudo apt install gcc-mingw-w64 Then download the source code of libSDL and compile it as follows: - $ cd SDL-1.2.15 - $ ./configure --host=x86_64-w64-mingw32 --disable-dga \ - --disable-video-dga --disable-video-x11-dgamouse \ + $ cd SDL-2.0.22 + $ ./configure --host=x86_64-w64-mingw32 \ --disable-video-x11 --disable-x11-shared \ - --prefix=/usr/local/packages/SDL-1.2.15-win32 + --prefix=/usr/local/packages/SDL-2.0.22-win32 $ make $ sudo make install -Finally, come back to this source folder, and compile the XaoS -version: +Finally, come back to this source folder, and compile: $ ./configure --host=x86_64-w64-mingw32 \ - --with-sdl-prefix=/usr/local/packages/SDL-1.2.15-win32 \ + --with-sdl-prefix=/usr/local/packages/SDL-2.0.22-win32 \ --disable-sdltest $ make $ cp src/mandelSSE.exe \ - /usr/local/packages/SDL-1.2.15-win32/bin/SDL.dll \ + /usr/local/packages/SDL-2.0.22-win32/bin/SDL.dll \ /some/path/for/Windows/ MISC diff --git a/aclocal.m4 b/aclocal.m4 index e22f81b..22aeb84 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -370,15 +370,20 @@ AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor +# +# Changelog: +# * also look for SDL2.framework under Mac OS X +# * removed HP/UX 9 support. +# * updated for newer autoconf. # serial 2 -dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl -AC_DEFUN([AM_PATH_SDL], +AC_DEFUN([AM_PATH_SDL2], [dnl -dnl Get the cflags and libraries from the sdl-config script +dnl Get the cflags and libraries from the sdl2-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], sdl_prefix="$withval", sdl_prefix="") @@ -386,53 +391,79 @@ AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL sdl_exec_prefix="$withval", sdl_exec_prefix="") AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], , enable_sdltest=yes) +AC_ARG_ENABLE(sdlframework, [ --disable-sdlframework Do not search for SDL2.framework], + , search_sdl_framework=yes) + +AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework]) - min_sdl_version=ifelse([$1], ,1.2.0,$1) + min_sdl_version=ifelse([$1], ,2.0.0,$1) if test "x$sdl_prefix$sdl_exec_prefix" = x ; then - PKG_CHECK_MODULES([SDL], [sdl >= $min_sdl_version], + PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], [sdl_pc=yes], [sdl_pc=no]) else sdl_pc=no if test x$sdl_exec_prefix != x ; then sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + if test x${SDL2_CONFIG+set} != xset ; then + SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config fi fi if test x$sdl_prefix != x ; then sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_prefix/bin/sdl-config + if test x${SDL2_CONFIG+set} != xset ; then + SDL2_CONFIG=$sdl_prefix/bin/sdl2-config fi fi fi if test "x$sdl_pc" = xyes ; then no_sdl="" - SDL_CONFIG="pkg-config sdl" + SDL2_CONFIG="pkg-config sdl2" else as_save_PATH="$PATH" if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then PATH="$prefix/bin:$prefix/usr/bin:$PATH" fi - AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) + AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) PATH="$as_save_PATH" - AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) no_sdl="" - if test "$SDL_CONFIG" = "no" ; then - no_sdl=yes - else - SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags` - SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` + if test "$SDL2_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then + AC_MSG_CHECKING(for SDL2.framework) + if test "x$SDL2_FRAMEWORK" != x; then + sdl_framework=$SDL2_FRAMEWORK + else + for d in / ~/ /System/; do + if test -d "$dLibrary/Frameworks/SDL2.framework"; then + sdl_framework="$dLibrary/Frameworks/SDL2.framework" + fi + done + fi + + if test x"$sdl_framework" != x && test -d "$sdl_framework"; then + AC_MSG_RESULT($sdl_framework) + sdl_framework_dir=`dirname $sdl_framework` + SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include" + SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL2" + else + no_sdl=yes + fi + fi + + if test "$SDL2_CONFIG" != "no"; then + if test "x$sdl_pc" = "xno"; then + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` + SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` + fi - sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ + sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \ + sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_sdltest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" @@ -443,7 +474,7 @@ AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run LIBS="$LIBS $SDL_LIBS" dnl dnl Now check if the installed SDL is sufficiently new. (Also sanity -dnl checks the results of sdl-config to some extent +dnl checks the results of sdl2-config to some extent dnl rm -f conf.sdltest AC_RUN_IFELSE([AC_LANG_SOURCE([[ @@ -471,11 +502,11 @@ int main (int argc, char *argv[]) } else { - printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); - printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); - printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); + printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } @@ -485,22 +516,25 @@ int main (int argc, char *argv[]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" + + fi + if test "x$sdl_pc" = "xno"; then + if test "x$no_sdl" = "xyes"; then + AC_MSG_RESULT(no) + else + AC_MSG_RESULT(yes) + fi fi - fi - if test "x$no_sdl" = x ; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) fi fi if test "x$no_sdl" = x ; then ifelse([$2], , :, [$2]) else - if test "$SDL_CONFIG" = "no" ; then - echo "*** The sdl-config script installed by SDL could not be found" + if test "$SDL2_CONFIG" = "no" ; then + echo "*** The sdl2-config script installed by SDL could not be found" echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the SDL_CONFIG environment variable to the" - echo "*** full path to sdl-config." + echo "*** your path, or set the SDL2_CONFIG environment variable to the" + echo "*** full path to sdl2-config." else if test -f conf.sdltest ; then : @@ -530,7 +564,7 @@ int main(int argc, char *argv[]) [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means SDL was incorrectly installed" echo "*** or that you have moved SDL since it was installed. In the latter case, you" - echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) + echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" diff --git a/configure b/configure index cd9a917..e7ee4c8 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for mandelSSE 2.7. +# Generated by GNU Autoconf 2.71 for mandelSSE 2.8. # # Report bugs to . # @@ -611,8 +611,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='mandelSSE' PACKAGE_TARNAME='mandelsse' -PACKAGE_VERSION='2.7' -PACKAGE_STRING='mandelSSE 2.7' +PACKAGE_VERSION='2.8' +PACKAGE_STRING='mandelSSE 2.8' PACKAGE_BUGREPORT='ttsiodras@gmail.com' PACKAGE_URL='' @@ -654,12 +654,13 @@ am__EXEEXT_TRUE LTLIBOBJS LIBOBJS SDL_CXXFLAGS -SDL_CONFIG +SDL2_CONFIG SDL_LIBS SDL_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG +SDL2_FRAMEWORK OPENMP_LIBS EGREP GREP @@ -780,6 +781,7 @@ enable_dependency_tracking with_sdl_prefix with_sdl_exec_prefix enable_sdltest +enable_sdlframework ' ac_precious_vars='build_alias host_alias @@ -792,6 +794,7 @@ CPPFLAGS CCC CC CFLAGS +SDL2_FRAMEWORK PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR @@ -1345,7 +1348,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures mandelSSE 2.7 to adapt to many kinds of systems. +\`configure' configures mandelSSE 2.8 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1417,7 +1420,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of mandelSSE 2.7:";; + short | recursive ) echo "Configuration of mandelSSE 2.8:";; esac cat <<\_ACEOF @@ -1435,6 +1438,7 @@ Optional Features: --disable-dependency-tracking speeds up one-time build --disable-sdltest Do not try to compile and run a test SDL program + --disable-sdlframework Do not search for SDL2.framework Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1452,6 +1456,8 @@ Some influential environment variables: you have headers in a nonstandard directory CC C compiler command CFLAGS C compiler flags + SDL2_FRAMEWORK + Path to SDL2.framework PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path @@ -1527,7 +1533,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -mandelSSE configure 2.7 +mandelSSE configure 2.8 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -1827,7 +1833,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by mandelSSE $as_me 2.7, which was +It was created by mandelSSE $as_me 2.8, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3510,7 +3516,7 @@ fi # Define the identity of the package. PACKAGE='mandelsse' - VERSION='2.7' + VERSION='2.8' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -6282,8 +6288,8 @@ printf "%s\n" "#define USE_OPENMP 1" >>confdefs.h fi -# Check for SDL (minimum: 1.2.0) -SDL_VERSION=1.2.0 +# Check for SDL (minimum: 2.0.0) +SDL_VERSION=2.0.0 @@ -6440,6 +6446,16 @@ else $as_nop enable_sdltest=yes fi +# Check whether --enable-sdlframework was given. +if test ${enable_sdlframework+y} +then : + enableval=$enable_sdlframework; +else $as_nop + search_sdl_framework=yes +fi + + + min_sdl_version=$SDL_VERSION @@ -6453,12 +6469,12 @@ if test -n "$SDL_CFLAGS"; then pkg_cv_SDL_CFLAGS="$SDL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl >= \$min_sdl_version\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl >= $min_sdl_version") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5 + ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl >= $min_sdl_version" 2>/dev/null` + pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl2 >= $min_sdl_version" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -6470,12 +6486,12 @@ if test -n "$SDL_LIBS"; then pkg_cv_SDL_LIBS="$SDL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl >= \$min_sdl_version\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl >= $min_sdl_version") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5 + ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl >= $min_sdl_version" 2>/dev/null` + pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl2 >= $min_sdl_version" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -6496,9 +6512,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sdl >= $min_sdl_version" 2>&1` + SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sdl2 >= $min_sdl_version" 2>&1` else - SDL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sdl >= $min_sdl_version" 2>&1` + SDL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sdl2 >= $min_sdl_version" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SDL_PKG_ERRORS" >&5 @@ -6519,37 +6535,37 @@ fi sdl_pc=no if test x$sdl_exec_prefix != x ; then sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + if test x${SDL2_CONFIG+set} != xset ; then + SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config fi fi if test x$sdl_prefix != x ; then sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_prefix/bin/sdl-config + if test x${SDL2_CONFIG+set} != xset ; then + SDL2_CONFIG=$sdl_prefix/bin/sdl2-config fi fi fi if test "x$sdl_pc" = xyes ; then no_sdl="" - SDL_CONFIG="pkg-config sdl" + SDL2_CONFIG="pkg-config sdl2" else as_save_PATH="$PATH" if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then PATH="$prefix/bin:$prefix/usr/bin:$PATH" fi - # Extract the first word of "sdl-config", so it can be a program name with args. -set dummy sdl-config; ac_word=$2 + # Extract the first word of "sdl2-config", so it can be a program name with args. +set dummy sdl2-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_SDL_CONFIG+y} +if test ${ac_cv_path_SDL2_CONFIG+y} then : printf %s "(cached) " >&6 else $as_nop - case $SDL_CONFIG in + case $SDL2_CONFIG in [\\/]* | ?:[\\/]*) - ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path. + ac_cv_path_SDL2_CONFIG="$SDL2_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -6563,7 +6579,7 @@ do esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_SDL_CONFIG="$as_dir$ac_word$ac_exec_ext" + ac_cv_path_SDL2_CONFIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6571,14 +6587,14 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no" + test -z "$ac_cv_path_SDL2_CONFIG" && ac_cv_path_SDL2_CONFIG="no" ;; esac fi -SDL_CONFIG=$ac_cv_path_SDL_CONFIG -if test -n "$SDL_CONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SDL_CONFIG" >&5 -printf "%s\n" "$SDL_CONFIG" >&6; } +SDL2_CONFIG=$ac_cv_path_SDL2_CONFIG +if test -n "$SDL2_CONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SDL2_CONFIG" >&5 +printf "%s\n" "$SDL2_CONFIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } @@ -6586,21 +6602,45 @@ fi PATH="$as_save_PATH" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SDL - version >= $min_sdl_version" >&5 -printf %s "checking for SDL - version >= $min_sdl_version... " >&6; } no_sdl="" - if test "$SDL_CONFIG" = "no" ; then - no_sdl=yes - else - SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags` - SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` + if test "$SDL2_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SDL2.framework" >&5 +printf %s "checking for SDL2.framework... " >&6; } + if test "x$SDL2_FRAMEWORK" != x; then + sdl_framework=$SDL2_FRAMEWORK + else + for d in / ~/ /System/; do + if test -d "$dLibrary/Frameworks/SDL2.framework"; then + sdl_framework="$dLibrary/Frameworks/SDL2.framework" + fi + done + fi - sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ + if test x"$sdl_framework" != x && test -d "$sdl_framework"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sdl_framework" >&5 +printf "%s\n" "$sdl_framework" >&6; } + sdl_framework_dir=`dirname $sdl_framework` + SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include" + SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL2" + else + no_sdl=yes + fi + fi + + if test "$SDL2_CONFIG" != "no"; then + if test "x$sdl_pc" = "xno"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SDL - version >= $min_sdl_version" >&5 +printf %s "checking for SDL - version >= $min_sdl_version... " >&6; } + SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` + SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` + fi + + sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` - sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \ + sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` - sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` if test "x$enable_sdltest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" @@ -6641,11 +6681,11 @@ int main (int argc, char *argv[]) } else { - printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); - printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); - printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); + printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } @@ -6666,24 +6706,27 @@ fi CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" + fi - fi - if test "x$no_sdl" = x ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + if test "x$sdl_pc" = "xno"; then + if test "x$no_sdl" = "xyes"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + fi + fi fi fi if test "x$no_sdl" = x ; then : else - if test "$SDL_CONFIG" = "no" ; then - echo "*** The sdl-config script installed by SDL could not be found" + if test "$SDL2_CONFIG" = "no" ; then + echo "*** The sdl2-config script installed by SDL could not be found" echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the SDL_CONFIG environment variable to the" - echo "*** full path to sdl-config." + echo "*** your path, or set the SDL2_CONFIG environment variable to the" + echo "*** full path to sdl2-config." else if test -f conf.sdltest ; then : @@ -6726,7 +6769,7 @@ else $as_nop echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means SDL was incorrectly installed" echo "*** or that you have moved SDL since it was installed. In the latter case, you" - echo "*** may want to edit the sdl-config script: $SDL_CONFIG" + echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext @@ -7276,7 +7319,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by mandelSSE $as_me 2.7, which was +This file was extended by mandelSSE $as_me 2.8, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7344,7 +7387,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -mandelSSE config.status 2.7 +mandelSSE config.status 2.8 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index be1da64..e1eda25 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([mandelSSE], [2.7], [ttsiodras@gmail.com]) +AC_INIT([mandelSSE], [2.8], [ttsiodras@gmail.com]) AC_LANG(C++) AC_CONFIG_HEADERS([src/config.h]) @@ -84,9 +84,9 @@ if test x"${HAVE_OPENMP}" = xyes ; then AC_SUBST(OPENMP_LIBS) fi -# Check for SDL (minimum: 1.2.0) -SDL_VERSION=1.2.0 -AM_PATH_SDL($SDL_VERSION, :, +# Check for SDL (minimum: 2.0.0) +SDL_VERSION=2.0.0 +AM_PATH_SDL2($SDL_VERSION, :, AC_MSG_ERROR([*** SDL version $SDL_VERSION or later was not found!])) AC_SUBST(SDL_CXXFLAGS) AC_SUBST(SDL_LIBS) diff --git a/src/Makefile.in b/src/Makefile.in index 8709880..c5fda20 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -239,8 +239,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ SCM_REVISION = @SCM_REVISION@ +SDL2_CONFIG = @SDL2_CONFIG@ +SDL2_FRAMEWORK = @SDL2_FRAMEWORK@ SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ SDL_CXXFLAGS = @SDL_CXXFLAGS@ SDL_LIBS = @SDL_LIBS@ SET_MAKE = @SET_MAKE@ diff --git a/src/common.cc b/src/common.cc index 6ecd059..185916d 100644 --- a/src/common.cc +++ b/src/common.cc @@ -18,16 +18,23 @@ void init256() panic("[x] Couldn't initialize SDL: %d\n", SDL_GetError()); atexit(SDL_Quit); - surface = SDL_SetVideoMode(MAXX, - MAXY, 8, SDL_HWSURFACE | SDL_HWPALETTE); - if (!surface) - panic("[x] Couldn't set video mode: %d", SDL_GetError()); + window = SDL_CreateWindow( + windowTitle, + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + MAXX, MAXY, 0); + if (!window) + panic("[x] Couldn't create window: %d", SDL_GetError()); - if (SDL_MUSTLOCK(surface)) { - if (SDL_LockSurface(surface) < 0) - panic("[x] Couldn't lock surface: %d", SDL_GetError()); - } - buffer = (Uint8*)surface->pixels; + if (!minimum_ms_per_frame) + renderer = SDL_CreateRenderer(window, -1, 0); + else + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC); + if (!renderer) + panic("[x] Couldn't create renderer: %d", SDL_GetError()); + + surface = SDL_CreateRGBSurface( + SDL_SWSURFACE, MAXX, MAXY, 8, 0, 0, 0, 0); // A palette for Mandelbrot zooms... { @@ -71,11 +78,13 @@ void init256() palette[value].r = red; palette[value].g = green; palette[value].b = blue; + palette[value].a = 255; } palette[0].r = 0; palette[0].g = 0; palette[0].b = 0; - SDL_SetColors(surface, palette, 0, 256); + palette[0].a = 255; + SDL_SetPaletteColors(surface->format->palette, palette, 0, 256); } } @@ -87,8 +96,8 @@ int kbhit(int *xx, int *yy) int x,y; SDL_Event event; - Uint8 *keystate = SDL_GetKeyState(NULL); - if ( keystate[SDLK_ESCAPE] ) + const Uint8 *keystate = SDL_GetKeyboardState(NULL); + if ( keystate[SDL_SCANCODE_ESCAPE] ) return 1; if(SDL_PollEvent(&event)) { diff --git a/src/common.h b/src/common.h index 3a1afa5..3a70d4e 100644 --- a/src/common.h +++ b/src/common.h @@ -24,11 +24,13 @@ GLOBAL long MAXX, MAXY; // Default value set in getopt parsing in main. GLOBAL unsigned minimum_ms_per_frame; -// SDL surface we draw in +// SDL stuff... +GLOBAL SDL_Window *window; +GLOBAL SDL_Renderer *renderer; GLOBAL SDL_Surface *surface; -// The surface buffer; this is where we place our pixel data in -GLOBAL Uint8 *buffer; +// Window title +GLOBAL const char *windowTitle; // Dispatching in AVX/non-AVX code. GLOBAL void (*CoreLoopDouble)(double xcur, double ycur, double xstep, unsigned char **p); diff --git a/src/mandel.cc b/src/mandel.cc index 6fd84b4..f98ed14 100644 --- a/src/mandel.cc +++ b/src/mandel.cc @@ -114,12 +114,10 @@ int main(int argc, char *argv[]) init256(); - const char *usage; if (bAutoPilot) - usage = "ESC to quit..."; + windowTitle = "ESC to quit..."; else - usage = "Left click to zoom-in, right-click to zoom-out, ESC to quit..."; - SDL_WM_SetCaption(usage, usage); + windowTitle = "Left click to zoom-in, right-click to zoom-out, ESC to quit..."; double fps_reported; if (bAutoPilot) { diff --git a/src/xaos.cc b/src/xaos.cc index 2abc767..1e74d25 100644 --- a/src/xaos.cc +++ b/src/xaos.cc @@ -234,9 +234,18 @@ void mandel( } } // Copy the memory-based buffer into the SDL one... - memcpy(buffer, bufferMem[bufIdx], MAXX*MAXY); + Uint8 *pixels = (Uint8*)surface->pixels; + Uint8 *src = bufferMem[bufIdx]; + for (int i=0; ipitch; + } // ...and blit it on the screen. - SDL_UpdateRect(surface, 0, 0, MAXX, MAXY); + SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface); + SDL_RenderCopy(renderer, texture, NULL, NULL); + SDL_RenderPresent(renderer); + SDL_DestroyTexture(texture); } AUTO_DISPATCH