From 03d5b676fea2948543d93427aec665f2e429b6e2 Mon Sep 17 00:00:00 2001 From: jsancho Date: Sun, 5 Feb 2012 11:32:05 +0000 Subject: [PATCH] Running gacela functions inside game loop thread for avoiding GL problems with threads --- Makefile | 76 +++++++---- configure | 347 ++++++++++++++++++++++++++++++++++++++++++++++++- src/events.scm | 10 +- src/gacela.scm | 53 ++++++-- src/video.scm | 23 ++-- 5 files changed, 452 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index d7950bc..7c07ee6 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # Makefile. Generated from Makefile.in by configure. # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -13,7 +13,7 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -MAKE=make + pkgdatadir = $(datadir)/gacela @@ -38,9 +38,13 @@ subdir = . DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/config.h.in $(top_srcdir)/configure COPYING \ - config.guess config.sub depcomp install-sh ltmain.sh missing + config.guess config.rpath config.sub depcomp install-sh \ + ltmain.sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ @@ -79,6 +83,12 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(docdir)" DATA = $(dist_doc_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ @@ -124,6 +134,8 @@ am__relativize = \ DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = ${SHELL} /home/jsancho/proyectos/gacela/trunk/missing --run aclocal-1.11 AMTAR = ${SHELL} /home/jsancho/proyectos/gacela/trunk/missing --run tar @@ -133,7 +145,7 @@ AUTOHEADER = ${SHELL} /home/jsancho/proyectos/gacela/trunk/missing --run autohea AUTOMAKE = ${SHELL} /home/jsancho/proyectos/gacela/trunk/missing --run automake-1.11 AWK = mawk CC = gcc -CCDEPMODE = depmode=none +CCDEPMODE = depmode=gcc3 CFLAGS = -g -O2 CPP = gcc -E CPPFLAGS = @@ -149,6 +161,8 @@ ECHO_T = EGREP = /bin/grep -E EXEEXT = FGREP = /bin/grep -F +FTGL_LIBS = -lftgl +GL_LIBS = -lGL -lGLU GREP = /bin/grep GUILE = /usr/bin/guile GUILE_CFLAGS = -pthread -I/usr/include/guile/2.0 @@ -188,8 +202,9 @@ PACKAGE_URL = PACKAGE_VERSION = 0.5 PATH_SEPARATOR = : RANLIB = ranlib +SDL_LIBS = -lSDL -lSDL_image -lSDL_gfx -lSDL_mixer SED = /bin/sed -SET_MAKE = MAKE=make +SET_MAKE = SHELL = /bin/bash STRIP = strip VERSION = 0.5 @@ -200,7 +215,7 @@ abs_top_srcdir = /home/jsancho/proyectos/gacela/trunk ac_ct_AR = ar ac_ct_CC = gcc ac_ct_DUMPBIN = -am__include = # +am__include = include am__leading_dot = . am__quote = am__tar = ${AMTAR} chof - "$$tardir" @@ -247,11 +262,12 @@ top_builddir = . top_srcdir = . SUBDIRS = src dist_doc_DATA = README +ACLOCAL_AMFLAGS = -I m4 all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: -am--refresh: +am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ @@ -287,10 +303,8 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): config.h: stamp-h1 - @if test ! -f $@; then \ - rm -f stamp-h1; \ - $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ - else :; fi + @if test ! -f $@; then rm -f stamp-h1; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 @@ -328,9 +342,7 @@ uninstall-dist_docDATA: @$(NORMAL_UNINSTALL) @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(docdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(docdir)" && rm -f $$files + dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. @@ -539,7 +551,7 @@ dist-gzip: distdir $(am__remove_distdir) dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir @@ -547,7 +559,7 @@ dist-lzma: distdir $(am__remove_distdir) dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir @@ -597,6 +609,7 @@ distcheck: dist && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ @@ -625,8 +638,16 @@ distcheck: dist list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ @@ -660,10 +681,15 @@ install-am: all-am installcheck: installcheck-recursive install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff --git a/configure b/configure index 80babfe..281fd29 100755 --- a/configure +++ b/configure @@ -619,10 +619,10 @@ LIBOBJS FTGL_LIBS GL_LIBS SDL_LIBS -GUILE_LTLIBS -GUILE_LIBS GUILE_LDFLAGS GUILE_CFLAGS +GUILE_LTLIBS +GUILE_LIBS GUILE_TOOLS GUILE_CONFIG GUILE @@ -650,6 +650,7 @@ SED am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE +am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE @@ -744,6 +745,7 @@ enable_dependency_tracking with_gnu_ld with_sysroot enable_libtool_lock +enable_rpath ' ac_precious_vars='build_alias host_alias @@ -1381,6 +1383,7 @@ Optional Features: --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-libtool-lock avoid locking (might break parallel builds) + --disable-rpath do not hardcode runtime library paths Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1390,6 +1393,7 @@ Optional Packages: --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). + --with-gnu-ld assume the C compiler uses GNU ld default=no Some influential environment variables: CC C compiler command @@ -2817,6 +2821,7 @@ fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' + am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= @@ -3630,6 +3635,7 @@ else # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. + rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -3689,7 +3695,7 @@ else break fi ;; - msvisualcpp | msvcmsys) + msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. @@ -11730,6 +11736,7 @@ else # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. + rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -11789,7 +11796,7 @@ else break fi ;; - msvisualcpp | msvcmsys) + msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. @@ -11976,6 +11983,216 @@ fi +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5 +$as_echo_n "checking for ld used by GCC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${acl_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$acl_cv_path_LD" +if test -n "$LD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${acl_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$acl_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$acl_cv_prog_gnu_ld + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 +$as_echo_n "checking for shared library run path origin... " >&6; } +if ${acl_cv_rpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 +$as_echo "$acl_cv_rpath" >&6; } + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + # Check whether --enable-rpath was given. +if test "${enable_rpath+set}" = set; then : + enableval=$enable_rpath; : +else + enable_rpath=yes +fi + + + + + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 +$as_echo_n "checking for 64-bit host... " >&6; } +if ${gl_cv_solaris_64bit+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef _LP64 +sixtyfour bits +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "sixtyfour bits" >/dev/null 2>&1; then : + gl_cv_solaris_64bit=yes +else + gl_cv_solaris_64bit=no +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 +$as_echo "$gl_cv_solaris_64bit" >&6; } + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking libguile compile flags" >&5 $as_echo_n "checking libguile compile flags... " >&6; } GUILE_CFLAGS="`$GUILE_CONFIG compile`" @@ -11988,9 +12205,127 @@ $as_echo_n "checking libguile link flags... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_LDFLAGS" >&5 $as_echo "$GUILE_LDFLAGS" >&6; } - AC_LIB_LINKFLAGS_FROM_LIBS(GUILE_LIBS, $GUILE_LDFLAGS, ) + + + + GUILE_LIBS= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + rpathdirs= + next= + for opt in $GUILE_LDFLAGS; do + if test -n "$next"; then + dir="$next" + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n """"; then + for dir in $rpathdirs; do + GUILE_LIBS="${GUILE_LIBS}${GUILE_LIBS:+ }-R$dir" + done + else + if test -n "$acl_hardcode_libdir_separator"; then + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + GUILE_LIBS="$flag" + else + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + GUILE_LIBS="${GUILE_LIBS}${GUILE_LIBS:+ }$flag" + done + fi + fi + fi + fi + fi + + GUILE_LIBS="$GUILE_LDFLAGS $GUILE_LIBS" - AC_LIB_LINKFLAGS_FROM_LIBS(GUILE_LTLIBS, $GUILE_LDFLAGS, yes) + + + + GUILE_LTLIBS= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + rpathdirs= + next= + for opt in $GUILE_LDFLAGS; do + if test -n "$next"; then + dir="$next" + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n ""yes""; then + for dir in $rpathdirs; do + GUILE_LTLIBS="${GUILE_LTLIBS}${GUILE_LTLIBS:+ }-R$dir" + done + else + if test -n "$acl_hardcode_libdir_separator"; then + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + GUILE_LTLIBS="$flag" + else + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + GUILE_LTLIBS="${GUILE_LTLIBS}${GUILE_LTLIBS:+ }$flag" + done + fi + fi + fi + fi + fi + + GUILE_LTLIBS="$GUILE_LDFLAGS $GUILE_LTLIBS" diff --git a/src/events.scm b/src/events.scm index fb21d88..716425b 100644 --- a/src/events.scm +++ b/src/events.scm @@ -49,10 +49,13 @@ (define (process-screen-events events) (set! quit-signal #f) + (process-screen-events-recursive events)) + +(define (process-screen-events-recursive events) (cond ((not (null? events)) (let ((event (car events))) (cond ((= (assoc-ref event 'type) SDL_QUIT) (set! quit-signal #t)))) - (process-screen-events (cdr events))))) + (process-screen-events-recursive (cdr events))))) (define (quit-signal?) quit-signal) @@ -66,11 +69,14 @@ (define (process-keyboard-events events) (clear-key-state) + (process-keyboard-events-recursive events)) + +(define (process-keyboard-events-recursive events) (cond ((not (null? events)) (let ((event (car events))) (cond ((= (assoc-ref event 'type) SDL_KEYDOWN) (key-press (assoc-ref event 'key.keysym.sym))) ((= (assoc-ref event 'type) SDL_KEYUP) (key-release (assoc-ref event 'key.keysym.sym))))) - (process-keyboard-events (cdr events))))) + (process-keyboard-events-recursive (cdr events))))) (define (key? key) (hash-ref keymap (get-keycode key))) diff --git a/src/gacela.scm b/src/gacela.scm index 6f14848..e07ef2f 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -37,6 +37,7 @@ set-game-code show-mob-hash hide-mob-hash + get-active-mobs hide-all-mobs get-current-mob-id get-mob-function-name @@ -67,7 +68,10 @@ set-camera camera-look render-text - get-frame-time)) + get-frame-time + key? + key-pressed? + key-released?)) ;;; Resources Cache @@ -81,7 +85,7 @@ (hash-set! resources-cache key res)) (define-macro (use-cache-with module proc) - (let* ((pwc (string->symbol (string-concatenate (list (symbol->string proc) "-without-cache"))))) + (let ((pwc (string->symbol (string-concatenate (list (symbol->string proc) "-without-cache"))))) `(begin (define ,pwc (@ ,module ,proc)) (define (,proc . param) @@ -104,6 +108,33 @@ (define game-code #f) (define game-loop-thread #f) +(define-macro (run-in-game-loop proc) + (let ((pgl (string->symbol (string-concatenate (list (symbol->string proc) "-in-game-loop")))) + (flag-symbol (gensym)) + (value-symbol (gensym))) + `(begin + (define ,pgl ,proc) + (define (,proc . param) + (cond ((and game-loop-thread (not (eq? game-loop-thread (current-thread)))) + (let ((,flag-symbol #f)) + (define ,value-symbol) + (system-async-mark + (lambda () + (catch #t + (lambda () (set! ,value-symbol (apply ,pgl param))) + (lambda (key . args) #f)) + (set! ,flag-symbol #t)) + game-loop-thread) + (while (not ,flag-symbol)) + ,value-symbol)) + (else + (apply ,pgl param))))))) + +(run-in-game-loop load-texture) +(run-in-game-loop load-font) +(run-in-game-loop set-screen-bpp!) +(run-in-game-loop resize-screen) + (define-macro (game . code) `(let ((game-function ,(if (null? code) `(lambda () #f) @@ -112,13 +143,10 @@ (cond ((not (game-running?)) (game-loop))))) -(define-macro (run-in-game-loop . code) - `(if game-loop-thread - (system-async-mark (lambda () ,@code) game-loop-thread) - (begin ,@code))) - (define (init-gacela) - (set! game-loop-thread (call-with-new-thread (lambda () (game))))) + (set! game-loop-thread (call-with-new-thread (lambda () (game)))) + (while (not loop-flag)) + #t) (define (quit-gacela) (set! game-loop-thread #f) @@ -126,8 +154,8 @@ (define (game-loop) (refresh-active-mobs) - (set! loop-flag #t) (init-video *width-screen* *height-screen* *bpp-screen* #:title *title* #:mode *mode* #:fps *frames-per-second*) + (set! loop-flag #t) (while loop-flag (init-frame-time) ; (check-connections) @@ -167,16 +195,17 @@ (if title (set-screen-title! title)) (if bpp - (run-in-game-loop (set-screen-bpp! bpp))) + (set-screen-bpp! bpp)) (if (or width height) (begin (if (not width) (set! width (get-screen-width))) (if (not height) (set! height (get-screen-height))) - (run-in-game-loop (resize-screen width height)))) + (resize-screen width height))) (if fps (set-frames-per-second! fps)) (if mode - (if (eq? mode '3d) (set-3d-mode) (set-2d-mode)))) + (if (eq? mode '3d) (set-3d-mode) (set-2d-mode))) + (get-game-properties)) (define (get-game-properties) `((title . ,(get-screen-title)) (width . ,(get-screen-width)) (height . ,(get-screen-height)) (bpp . ,(get-screen-bpp)) (fps . ,(get-frames-per-second)) (mode . ,(if (3d-mode?) '3d '2d)))) diff --git a/src/video.scm b/src/video.scm index e183f13..18d5185 100644 --- a/src/video.scm +++ b/src/video.scm @@ -73,18 +73,17 @@ (define flags 0) (define* (init-video width height bpp #:key (mode '2d) (title "") (fps 20)) - (cond ((not screen) - (SDL_Init SDL_INIT_VIDEO) - (let ((info (SDL_GetVideoInfo))) - (SDL_GL_SetAttribute SDL_GL_DOUBLEBUFFER 1) - (set! flags (+ SDL_OPENGL SDL_GL_DOUBLEBUFFER SDL_HWPALETTE SDL_RESIZABLE - (if (= (assoc-ref info 'hw_available) 0) SDL_SWSURFACE SDL_HWSURFACE) - (if (= (assoc-ref info 'blit_hw) 0) 0 SDL_HWACCEL))) - (set! screen (SDL_SetVideoMode width height bpp flags)) - (set-screen-title! title) - (set-frames-per-second! fps) - (init-gl) - (if (eq? mode '3d) (set-3d-mode) (set-2d-mode)))))) + (SDL_Init SDL_INIT_VIDEO) + (let ((info (SDL_GetVideoInfo))) + (SDL_GL_SetAttribute SDL_GL_DOUBLEBUFFER 1) + (set! flags (+ SDL_OPENGL SDL_GL_DOUBLEBUFFER SDL_HWPALETTE SDL_RESIZABLE + (if (= (assoc-ref info 'hw_available) 0) SDL_SWSURFACE SDL_HWSURFACE) + (if (= (assoc-ref info 'blit_hw) 0) 0 SDL_HWACCEL))) + (set! screen (SDL_SetVideoMode width height bpp flags)) + (set-screen-title! title) + (set-frames-per-second! fps) + (init-gl) + (if (eq? mode '3d) (set-3d-mode) (set-2d-mode)))) (define (get-screen-height) (surface-h screen)) -- 2.39.5