Skip to content

Commit 92d7143

Browse files
committed
libvisual: Resurrect examples
configure.ac additions are inspired by commit ae41ec9.
1 parent fb284c3 commit 92d7143

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

libvisual/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Process this file with automake to generate a Makefile.in
22

3-
SUBDIRS = libvisual po
3+
SUBDIRS = libvisual po examples
44

55
PKG_CONFIG_FILE = libvisual-$(LIBVISUAL_VERSION_SUFFIX).pc
66

libvisual/configure.ac

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,28 @@ AC_SUBST(VISUAL_LIBS)
374374
dnl ******************************
375375
dnl Arguments to specify certain features.
376376
dnl ******************************
377+
AC_ARG_ENABLE([examples],
378+
AC_HELP_STRING([--disable-examples],
379+
[Do not build example programs @<:@default=enabled@:>@]),
380+
[examples=$enableval],
381+
[examples=yes])
382+
AC_MSG_CHECKING([wheter to build example programs])
383+
if test x$examples = xyes ; then
384+
AC_MSG_RESULT([yes])
385+
# Find SDL to build the examples.
386+
AC_PATH_TOOL(SDL_CONFIG, [sdl-config])
387+
if test x$SDL_CONFIG = x ; then
388+
AC_MSG_ERROR([*** sdl-config not found.
389+
If you have installed from binaries, probably you have not
390+
installed SDL development package.
391+
See http://www.libsdl.org])
392+
fi
393+
# On success, this will set and substitute SDL_CFLAGS and SDL_LIBS
394+
AM_PATH_SDL(1.2.0,,AC_MSG_ERROR([*** SDL >= 1.2.0 not installed - please install first]))
395+
AC_SUBST([EXAMPLES], ['simplesdl morphsdl'])
396+
else
397+
AC_MSG_RESULT([no])
398+
fi
377399

378400
dnl ******************************
379401
dnl Debugging stuff
@@ -823,6 +845,7 @@ po/Makefile.in
823845
Makefile
824846
libvisual.pc
825847
libvisual/Makefile
848+
examples/Makefile
826849
])
827850
#
828851
# For now this are not included in the package

libvisual/examples/Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/examples -I$(top_builddir)
66

77
AM_CFLAGS = $(SDL_CFLAGS) $(VISUAL_CFLAGS)
88

9-
bin_PROGRAMS = $(EXAMPLES)
9+
noinst_PROGRAMS = @EXAMPLES@
1010

1111
EXTRA_PROGRAMS = simplesdl morphsdl
1212

13-
simplesdl_LDADD = $(SDL_LIBS) $(VISUAL_LIBS)
14-
morphsdl_LDADD = $(SDL_LIBS) $(VISUAL_LIBS)
13+
simplesdl_LDADD = $(SDL_LIBS) ../libvisual/libvisual-@[email protected]
14+
morphsdl_LDADD = $(SDL_LIBS) ../libvisual/libvisual-@[email protected]
1515

1616
simplesdl_SOURCES = simplesdl.c
1717

libvisual/examples/morphsdl.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int main (int argc, char *argv[])
209209
int morph_to = 0;
210210

211211
/* Used to list all the plugins */
212-
char *name = NULL;
212+
const char *name = NULL;
213213

214214
SDL_Event event;
215215

@@ -230,7 +230,7 @@ else
230230
have_opengl = 1;
231231
/* Show a list of plugins */
232232
if (argc < 4) {
233-
printf ("usage: %s plug1 plug2 morph (targetdepth)\n", argv[0]);
233+
printf ("usage: %s actor1 actor2 morph [targetdepth]\n", argv[0]);
234234

235235
printf ("\nValid actors:\n");
236236
do {
@@ -413,10 +413,7 @@ else
413413
(int)frames, (int)(end - begin),
414414
(end - begin) == 0 ? (int)frames : (int)(frames / (end - begin)));
415415

416-
/* Destroy the bin, this will also destroy everything within the bin, if you
417-
* only want to free the bin, use visual_bin_free */
418-
visual_bin_destroy (bin);
419-
visual_video_free (video);
416+
visual_video_free_buffer (video);
420417

421418
visual_quit ();
422419

libvisual/examples/simplesdl.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ void sdl_size_request (int width, int height)
153153

154154
if (gl_plug == 0) {
155155
free (scrbuf);
156-
scrbuf = malloc (video->size);
157-
memset (scrbuf, 0, video->size);
156+
scrbuf = malloc (visual_video_get_size (video));
157+
memset (scrbuf, 0, visual_video_get_size (video));
158158

159159
visual_video_set_buffer (video, scrbuf);
160160
}
@@ -205,7 +205,7 @@ void sdl_draw_buf ()
205205
{
206206
unsigned char *str = (unsigned char *) screen->pixels;
207207

208-
memcpy (str, scrbuf, video->size);
208+
memcpy (str, scrbuf, visual_video_get_size (video));
209209

210210
SDL_UpdateRect (screen, 0, 0, screen->w, screen->h);
211211
}
@@ -324,8 +324,8 @@ int main (int argc, char *argv[])
324324
bpp = visual_video_bpp_from_depth (depth);
325325

326326
/* Now we know the size, allocate the buffer */
327-
scrbuf = malloc (video->size);
328-
memset (scrbuf, 0, video->size);
327+
scrbuf = malloc (visual_video_get_size (video));
328+
memset (scrbuf, 0, visual_video_get_size (video));
329329

330330
/* Link the buffer to the video context */
331331
visual_video_set_buffer (video, scrbuf);
@@ -433,10 +433,7 @@ int main (int argc, char *argv[])
433433
(int)frames, (int)(end - begin),
434434
(end - begin) == 0 ? (int)frames : (int)(frames / (end - begin)));
435435

436-
/* Destroy the bin, this will also destroy everything within the bin, if you
437-
* only want to free the bin, use visual_bin_free */
438-
visual_bin_destroy (bin);
439-
visual_video_free (video);
436+
visual_video_free_buffer (video);
440437

441438
visual_quit ();
442439

0 commit comments

Comments
 (0)