diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-05-17 14:40:31 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-05-17 14:40:31 +0000 |
commit | 17a94886c9cd2752789ed166f5627c5f2a1ca44b (patch) | |
tree | 4e8ac8c0ada2db47c3df55eb31d63f769c146a16 | |
parent | dee6a92fcdda1ad0194abe08bf1f46f83167e9d8 (diff) |
Initial audio framework
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@21 84d2e878-0bd5-11dd-ad15-13eda11d74c5
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | data/Makefile.am | 3 | ||||
-rw-r--r-- | data/sound/hum.wav | bin | 0 -> 296236 bytes | |||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/audio.c | 34 | ||||
-rw-r--r-- | src/audio.h | 25 | ||||
-rw-r--r-- | src/game.c | 9 | ||||
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/types.h | 6 |
9 files changed, 81 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index c463e58..812ebbd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,3 @@ -EXTRA_DIST = configure src/game.h src/model.h src/physics.h src/render.h src/texture.h src/types.h src/utils.h data/* +EXTRA_DIST = configure src/game.h src/model.h src/physics.h src/render.h src/texture.h src/types.h src/utils.h src/audio.h data/* SUBDIRS = src data diff --git a/data/Makefile.am b/data/Makefile.am index 36eb084..efd821c 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -11,3 +11,6 @@ textures_DATA = textures/floor1.png textures/tiledwall.png roomsdir = $(datadir)/thrust3d/rooms rooms_DATA = rooms/00-00-00 rooms/00-00-01 rooms/00-00-02 rooms/00-00-03 rooms/00-00-04 rooms/00-01-04 rooms/00-02-04 +sounddir = $(datadir)/thrust3d/sound +sound_DATA = sound/hum.wav + diff --git a/data/sound/hum.wav b/data/sound/hum.wav Binary files differnew file mode 100644 index 0000000..8ba8d92 --- /dev/null +++ b/data/sound/hum.wav diff --git a/src/Makefile.am b/src/Makefile.am index c6299b5..d3ccec8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ bin_PROGRAMS = thrust3d -thrust3d_SOURCES = main.c model.c render.c physics.c game.c texture.c utils.c +thrust3d_SOURCES = main.c model.c render.c physics.c game.c texture.c utils.c audio.c thrust3d_LDADD = @LIBS@ AM_CFLAGS = -Wall -g AM_CPPFLAGS = -DDATADIR=\""$(datadir)"/thrust3d\" diff --git a/src/audio.c b/src/audio.c new file mode 100644 index 0000000..1e807b5 --- /dev/null +++ b/src/audio.c @@ -0,0 +1,34 @@ +/* + * audio.c + * + * Sound stuff + * + * (c) 2008 Thomas White <taw27@cam.ac.uk> + * + * thrust3d - a silly game + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "types.h" + +/* OpenGL initial setup */ +AudioContext *audio_setup() { + + AudioContext *ctx; + + ctx = malloc(sizeof(AudioContext)); + if ( ctx == NULL ) return NULL; + + + return ctx; + +} + +void audio_shutdown(AudioContext *ctx) { + free(ctx); +} + diff --git a/src/audio.h b/src/audio.h new file mode 100644 index 0000000..dcce8ac --- /dev/null +++ b/src/audio.h @@ -0,0 +1,25 @@ +/* + * audio.h + * + * Sound stuff + * + * (c) 2008 Thomas White <taw27@cam.ac.uk> + * + * thrust3d - a silly game + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifndef AUDIO_H +#define AUDIO_H + +#include "types.h" + +extern AudioContext *audio_setup(void); +extern void audio_shutdown(AudioContext *ctx); + +#endif /* AUDIO_H */ + @@ -20,6 +20,7 @@ #include "game.h" #include "render.h" #include "utils.h" +#include "audio.h" #define MAX_OBJECTS 100 @@ -253,6 +254,14 @@ Game *game_new(int width, int height) { return NULL; } + /* Audio setup */ + g->audio = audio_setup(); + if ( g->audio == NULL ) { + fprintf(stderr, "Couldn't initialise audio\n"); + free(g); + return NULL; + } + /* Load models */ g->models = model_init(); if ( g->models == NULL ) { @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) { } /* SDL initial setup */ - if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) { + if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't initialise SDL: %s\n", SDL_GetError()); return 1; } @@ -187,6 +187,7 @@ int main(int argc, char *argv[]) { } render_shutdown(game->render); + SDL_CloseAudio(); SDL_Quit(); printf("\n"); diff --git a/src/types.h b/src/types.h index 3177028..bb4111f 100644 --- a/src/types.h +++ b/src/types.h @@ -116,6 +116,11 @@ typedef struct { } RenderContext; typedef struct { + + +} AudioContext; + +typedef struct { int rx; int ry; int rz; @@ -161,6 +166,7 @@ typedef struct { ModelContext *models; RenderContext *render; + AudioContext *audio; int cur_room_x; int cur_room_y; |