Skip to content

Commit

Permalink
Added --enable-sdl2 configure option.
Browse files Browse the repository at this point in the history
SDL2 + no TTF is currently not functionnal.
  • Loading branch information
frank-zago committed Jun 24, 2014
1 parent c8ade06 commit bfe3928
Show file tree
Hide file tree
Showing 15 changed files with 2,614 additions and 1,132 deletions.
449 changes: 261 additions & 188 deletions Makefile.in

Large diffs are not rendered by default.

1,085 changes: 793 additions & 292 deletions aclocal.m4

Large diffs are not rendered by default.

1,703 changes: 1,263 additions & 440 deletions configure

Large diffs are not rendered by default.

45 changes: 31 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,44 @@ fi # ac_cv_c_compiler_gnu
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

# Check for SDL - Will accept 1.2 and 1.3
AM_PATH_SDL("1.2.0", :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))

# Check for SDL libraries
AC_CHECK_LIB(SDL, SDL_Init,,AC_MSG_ERROR([SDL library not found.]))
AC_CHECK_LIB(SDL_mixer,main,,AC_MSG_ERROR([SDL_mixer library not found.]))
AC_CHECK_LIB(SDL_image,IMG_Load,,AC_MSG_ERROR([SDL_image library not found.]))
AC_CHECK_LIB(SDL_gfx,SDL_framerateDelay,,AC_MSG_ERROR([SDL_gfx library not found.]))

AC_ARG_ENABLE(sdl2,
AS_HELP_STRING([--enable-sdl2], [use SDL2 instead of SDL1]),
[ if test x"$enableval" = xyes; then
with_sdl2="yes"
else
with_sdl2="no"
fi ],
[ with_sdl2="no" ]
)

AC_ARG_ENABLE(ttf,
AS_HELP_STRING([--disable-ttf],[disable use of ttf fonts]),
AS_HELP_STRING([--disable-ttf], [disable use of ttf fonts]),
[ if test x"$enableval" = xyes; then
with_ttf="yes, check"
with_ttf="yes"
else
with_ttf="no"
problem_ttf=": Explicitly disabled"
fi ],
[ with_ttf="not specified, check" ]
[ with_ttf="yes" ]
)
if ! test x"$with_ttf" = xno; then
AC_CHECK_LIB(SDL_ttf,TTF_Init,,AC_MSG_ERROR([SDL_ttf library not found.]))

if test x"$with_sdl2" = xyes; then
AM_PATH_SDL2("2.0.0", :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))
AC_CHECK_LIB(SDL2, SDL_Init,,AC_MSG_ERROR([SDL2 library not found.]))
AC_CHECK_LIB(SDL2_mixer,main,,AC_MSG_ERROR([SDL2_mixer library not found.]))
AC_CHECK_LIB(SDL2_image,IMG_Load,,AC_MSG_ERROR([SDL2_image library not found.]))
AC_CHECK_LIB(SDL2_gfx,SDL_framerateDelay,,AC_MSG_ERROR([SDL2_gfx library not found.]))
if ! test x"$with_ttf" = xno; then
AC_CHECK_LIB(SDL2_ttf,TTF_Init,,AC_MSG_ERROR([SDL2_ttf library not found.]))
fi
else
AM_PATH_SDL("1.2.0", :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))
AC_CHECK_LIB(SDL, SDL_Init,,AC_MSG_ERROR([SDL library not found.]))
AC_CHECK_LIB(SDL_mixer,main,,AC_MSG_ERROR([SDL_mixer library not found.]))
AC_CHECK_LIB(SDL_image,IMG_Load,,AC_MSG_ERROR([SDL_image library not found.]))
AC_CHECK_LIB(SDL_gfx,SDL_framerateDelay,,AC_MSG_ERROR([SDL_gfx library not found.]))
if ! test x"$with_ttf" = xno; then
AC_CHECK_LIB(SDL_ttf,TTF_Init,,AC_MSG_ERROR([SDL_ttf library not found.]))
fi
fi

dnl Checks for header files.
Expand Down
413 changes: 235 additions & 178 deletions src/Makefile.in

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/SFont.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
karlb@gmx.net
*/

#ifndef HAVE_LIBSDL_TTF
#if !defined HAVE_LIBSDL_TTF && !defined HAVE_LIBSDL2_TTF

#include <assert.h>

Expand Down
4 changes: 2 additions & 2 deletions src/SFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
// To load the fonts, load the font image into YourFont->Surface
// and call InitFont( YourFont );
typedef struct {
#ifdef HAVE_LIBSDL_TTF
#if defined HAVE_LIBSDL_TTF || defined HAVE_LIBSDL2_TTF
#define MAXCHARS 128-32
#if SDL_VERSION_ATLEAST(1,3,0)
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_Texture *CharSurf[MAXCHARS];
#else
SDL_Surface *CharSurf[MAXCHARS];
Expand Down
4 changes: 2 additions & 2 deletions src/TFont.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

/* If NOT using TTF Fonts, this file does nothing,
check Sfont.c. */
#ifdef HAVE_LIBSDL_TTF
#if defined HAVE_LIBSDL_TTF || defined HAVE_LIBSDL2_TTF
#include <assert.h>

#include "xgalaga.h"

#include <sys/param.h>
#include <SDL/SDL_ttf.h>
#include <SDL_ttf.h>

static const SDL_Color S_White = {0xFF, 0xFF, 0xFF, 0};
static const SDL_Color S_Green = {0x00, 0xFF, 0x00, 0};
Expand Down
20 changes: 16 additions & 4 deletions src/config.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* src/config.h.in. Generated from configure.in by autoheader. */
/* src/config.h.in. Generated from configure.ac by autoheader. */

/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
Expand All @@ -9,6 +9,21 @@
/* Define to 1 if you have the `SDL' library (-lSDL). */
#undef HAVE_LIBSDL

/* Define to 1 if you have the `SDL2' library (-lSDL2). */
#undef HAVE_LIBSDL2

/* Define to 1 if you have the `SDL2_gfx' library (-lSDL2_gfx). */
#undef HAVE_LIBSDL2_GFX

/* Define to 1 if you have the `SDL2_image' library (-lSDL2_image). */
#undef HAVE_LIBSDL2_IMAGE

/* Define to 1 if you have the `SDL2_mixer' library (-lSDL2_mixer). */
#undef HAVE_LIBSDL2_MIXER

/* Define to 1 if you have the `SDL2_ttf' library (-lSDL2_ttf). */
#undef HAVE_LIBSDL2_TTF

/* Define to 1 if you have the `SDL_gfx' library (-lSDL_gfx). */
#undef HAVE_LIBSDL_GFX

Expand Down Expand Up @@ -54,9 +69,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O

/* Name of package */
#undef PACKAGE

Expand Down
4 changes: 2 additions & 2 deletions src/highscore.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include "xgalaga.h"

#include <SDL/SDL_endian.h>
#include <SDL_endian.h>

#define NUM_MY_SCORES 10

Expand Down Expand Up @@ -274,7 +274,7 @@ void show_scores(int top)
SFont_Font *font = i==my_thisplace ? fnt_reg_red : fnt_reg_grey;

sprintf(buf, " %2d. %-20s %7lu %5lu",
i+1, my_scores[i].name,
i+1, my_scores[i].name,
(unsigned long)my_scores[i].score,
(unsigned long)my_scores[i].level);
SFont_WriteCenter(font, top+(3+i)*dy, buf);
Expand Down
4 changes: 2 additions & 2 deletions src/images.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* 02110-1301, USA.
*/

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>

#include "xgalaga.h"

Expand Down
2 changes: 1 addition & 1 deletion src/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void S_Initialize(int fullscreen)
exit(1);
}

screen = SDL_CreateWindow("Xgalaga SDL",
screen = SDL_CreateWindow("Xgalaga SDL",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
winwidth, screen_height,
0);
Expand Down
2 changes: 1 addition & 1 deletion src/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void sound_exit(void) {}
void play_sound (int sound) {}

#else
#include <SDL/SDL_mixer.h>
#include <SDL_mixer.h>

#include "xgalaga.h"

Expand Down
3 changes: 1 addition & 2 deletions src/title.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <fcntl.h>
#include <unistd.h>

#include <SDL/SDL.h>
#include <SDL.h>

#include "xgalaga.h"

Expand Down Expand Up @@ -273,4 +273,3 @@ void init_titles(void)
pauseyspeed = 3;
read_credits();
}

6 changes: 3 additions & 3 deletions src/xgalaga.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* 02110-1301, USA.
*/

#include <SDL/SDL.h>
#include <SDL.h>
#if SDL_VERSION_ATLEAST(1,3,0)
#include <SDL/SDL_keyboard.h>
#include <SDL/SDL_video.h>
#include <SDL_keyboard.h>
#include <SDL_video.h>
#endif

#include "defs.h"
Expand Down

0 comments on commit bfe3928

Please sign in to comment.