Changed sound code to use SDL
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@44 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
7cb109935a
commit
1f39b147ef
@ -160,7 +160,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
//glEnable(GL_LINE_SMOOTH);
|
||||
glLineWidth(line_size);
|
||||
glBegin(GL_LINES);
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
CP = cp
|
||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
|
||||
ADDITIONAL_GUI_LIBS = -lGLU -lGL -lasound
|
||||
ADDITIONAL_CFLAGS = -DLINUX
|
||||
ADDITIONAL_OBJCFLAGS = -DLINUX -DHAVE_SOUND -Wno-import
|
||||
ADDITIONAL_GUI_LIBS = -lGLU -lGL -lasound -lSDL -lpthread -lSDL_mixer
|
||||
ADDITIONAL_CFLAGS = -DLINUX -I/home/dtaylor/include/SDL -D_REENTRANT
|
||||
ADDITIONAL_OBJCFLAGS = -DLINUX -DHAVE_SOUND -Wno-import -I/home/dtaylor/include/SDL -D_REENTRANT
|
||||
APP_NAME = oolite
|
||||
oolite_LIB_DIRS += -L/usr/X11R6/lib/
|
||||
|
||||
oolite_C_FILES = vector.c legacy_random.c
|
||||
oolite_OBJC_FILES = Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntity_Additions.m PlayerEntity_contracts.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntity_AI.m ShipEntity.m SkyEntity.m StationEntity.m TextureStore.m Universe.m OOSound.m
|
||||
oolite_OBJC_FILES = Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntity_Additions.m PlayerEntity_contracts.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntity_AI.m ShipEntity.m SkyEntity.m StationEntity.m TextureStore.m Universe.m OOSound.m OOMusic.m
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/application.make
|
||||
include GNUmakefile.postamble
|
||||
|
@ -342,6 +342,22 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
|
||||
- (void) applicationDidFinishLaunching: (NSNotification*) notification
|
||||
{
|
||||
#ifdef GNUSTEP
|
||||
NSLog(@"initialising SDL");
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0)
|
||||
{
|
||||
NSLog(@"Unable to init SDL: %s\n", SDL_GetError());
|
||||
}
|
||||
else if (Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048) < 0)
|
||||
{
|
||||
NSLog(@"Mix_OpenAudio: %s\n", Mix_GetError());
|
||||
}
|
||||
|
||||
Mix_AllocateChannels(16);
|
||||
//Mix_ChannelFinished(channelDone);
|
||||
//Mix_HookMusicFinished(musicFinished);
|
||||
#endif
|
||||
|
||||
//
|
||||
// ensure the gameView is drawn to, so OpenGL is initialised and so textures can initialse.
|
||||
//
|
||||
@ -405,7 +421,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
// dajt: force the OpenGL context to be initialised again as X windows
|
||||
// should have caught up by now
|
||||
// TODO: get rid of hardcoded window size
|
||||
[gameView initialiseGLWithSize: NSMakeSize(640, 480)];
|
||||
[gameView initialiseGLWithSize: NSMakeSize(DISPLAY_MIN_WIDTH, DISPLAY_MIN_HEIGHT)];
|
||||
#endif
|
||||
|
||||
[universe setGameView:gameView];
|
||||
|
11
OOMusic.h
Normal file
11
OOMusic.h
Normal file
@ -0,0 +1,11 @@
|
||||
// OOMusic.h: Selects the appropriate music class source file
|
||||
// depending on the operating system defined.
|
||||
//
|
||||
// Add new OS imports here. The -DOS_NAME flag in the GNUmakefile
|
||||
// will select which one gets compiled.
|
||||
//
|
||||
// David Taylor, 2005-05-04
|
||||
|
||||
#ifdef LINUX
|
||||
#import "SDLMusic.h"
|
||||
#endif
|
11
OOMusic.m
Normal file
11
OOMusic.m
Normal file
@ -0,0 +1,11 @@
|
||||
// OOMusic.m: Selects the appropriate music class source file
|
||||
// depending on the operating system defined.
|
||||
//
|
||||
// Add new OS imports here. The -DOS_NAME flag in the GNUmakefile
|
||||
// will select which one gets compiled.
|
||||
//
|
||||
// David Taylor, 2005-05-04
|
||||
|
||||
#ifdef LINUX
|
||||
#import "SDLMusic.m"
|
||||
#endif
|
@ -41,6 +41,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
#ifndef GNUSTEP
|
||||
#import <QuickTime/Movies.h>
|
||||
#else
|
||||
#include "OOMusic.h"
|
||||
#endif
|
||||
|
||||
#import "ShipEntity.h"
|
||||
@ -274,10 +276,14 @@ Your fair use and other rights are in no way affected by the above.
|
||||
BOOL ecm_in_operation;
|
||||
double ecm_start_time;
|
||||
|
||||
#ifndef GNUSTEP
|
||||
#ifndef GNUSTEP
|
||||
NSMovie* themeMusic;
|
||||
NSMovie* missionMusic;
|
||||
NSMovie* dockingMusic;
|
||||
#else
|
||||
OOMusic* themeMusic;
|
||||
OOMusic* missionMusic;
|
||||
OOMusic* dockingMusic;
|
||||
#endif
|
||||
|
||||
NSSound* beepSound;
|
||||
|
@ -924,11 +924,9 @@ static BOOL galactic_witchjump;
|
||||
if (afterburner1Sound) [afterburner1Sound release];
|
||||
if (afterburner2Sound) [afterburner2Sound release];
|
||||
//
|
||||
#ifndef GNUSTEP
|
||||
if (themeMusic) [themeMusic release];
|
||||
if (missionMusic) [missionMusic release];
|
||||
if (dockingMusic) [dockingMusic release];
|
||||
#endif
|
||||
//
|
||||
// allocate sounds
|
||||
//
|
||||
@ -956,11 +954,9 @@ static BOOL galactic_witchjump;
|
||||
// [afterburner2Sound setDelegate:self];
|
||||
|
||||
//
|
||||
#ifndef GNUSTEP
|
||||
themeMusic = [[ResourceManager movieFromFilesNamed:@"OoliteTheme.mp3" inFolder:@"Music"] retain];
|
||||
missionMusic = [[ResourceManager movieFromFilesNamed:@"OoliteTheme.mp3" inFolder:@"Music"] retain];
|
||||
dockingMusic = [[ResourceManager movieFromFilesNamed:@"BlueDanube.mp3" inFolder:@"Music"] retain];
|
||||
#endif
|
||||
themeMusic = [[ResourceManager movieFromFilesNamed:@"OoliteTheme.mp3" inFolder:@"Music"] retain];
|
||||
missionMusic = [[ResourceManager movieFromFilesNamed:@"OoliteTheme.mp3" inFolder:@"Music"] retain];
|
||||
dockingMusic = [[ResourceManager movieFromFilesNamed:@"BlueDanube.mp3" inFolder:@"Music"] retain];
|
||||
//
|
||||
collision_radius = 50.0;
|
||||
//
|
||||
@ -1210,11 +1206,9 @@ static BOOL galactic_witchjump;
|
||||
if (warningSound) [warningSound release];
|
||||
if (afterburner1Sound) [afterburner1Sound release];
|
||||
if (afterburner2Sound) [afterburner2Sound release];
|
||||
#ifndef GNUSTEP
|
||||
if (themeMusic) [themeMusic release];
|
||||
if (missionMusic) [missionMusic release];
|
||||
if (dockingMusic) [dockingMusic release];
|
||||
#endif
|
||||
if (missionBackgroundImage) [missionBackgroundImage release];
|
||||
|
||||
if (player_name) [player_name release];
|
||||
@ -2695,6 +2689,10 @@ static BOOL cloak_pressed;
|
||||
if (IsMovieDone ([dockingMusic QTMovie]))
|
||||
GoToBeginningOfMovie ([dockingMusic QTMovie]);
|
||||
StartMovie ([dockingMusic QTMovie]);
|
||||
#else
|
||||
[dockingMusic stop];
|
||||
[dockingMusic goToBeginning];
|
||||
[dockingMusic play];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -2749,6 +2747,10 @@ static BOOL cloak_pressed;
|
||||
if (IsMovieDone ([dockingMusic QTMovie]))
|
||||
GoToBeginningOfMovie ([dockingMusic QTMovie]);
|
||||
StartMovie ([dockingMusic QTMovie]);
|
||||
#else
|
||||
[dockingMusic stop];
|
||||
[dockingMusic goToBeginning];
|
||||
[dockingMusic play];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -4223,6 +4225,8 @@ static BOOL toggling_music;
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
StopMovie ([dockingMusic QTMovie]);
|
||||
#else
|
||||
[dockingMusic stop];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -4239,12 +4243,19 @@ static BOOL toggling_music;
|
||||
if (IsMovieDone ([dockingMusic QTMovie]))
|
||||
GoToBeginningOfMovie ([dockingMusic QTMovie]);
|
||||
StartMovie ([dockingMusic QTMovie]);
|
||||
#else
|
||||
[dockingMusic stop];
|
||||
[dockingMusic goToBeginning];
|
||||
[dockingMusic play];
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
StopMovie ([dockingMusic QTMovie]);
|
||||
#else
|
||||
[dockingMusic stop];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -4256,7 +4267,7 @@ static BOOL toggling_music;
|
||||
}
|
||||
//
|
||||
// keep music playing
|
||||
if ((docking_music_on)&&(!ootunes_on))
|
||||
if (autopilot_engaged && (docking_music_on)&&(!ootunes_on))
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
if (IsMovieDone ([dockingMusic QTMovie]))
|
||||
@ -4264,6 +4275,12 @@ static BOOL toggling_music;
|
||||
GoToBeginningOfMovie ([dockingMusic QTMovie]);
|
||||
StartMovie ([dockingMusic QTMovie]);
|
||||
}
|
||||
#else
|
||||
if ([dockingMusic isPlaying] == NO)
|
||||
{
|
||||
[dockingMusic goToBeginning];
|
||||
[dockingMusic play];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -4306,13 +4323,16 @@ static BOOL toggling_music;
|
||||
{
|
||||
if (([gameView isDown:121])||([gameView isDown:89])) // 'yY'
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
if (themeMusic)
|
||||
{
|
||||
StopMovie ([themeMusic QTMovie]);
|
||||
#ifndef GNUSTEP
|
||||
StopMovie ([themeMusic QTMovie]);
|
||||
GoToBeginningOfMovie ([themeMusic QTMovie]);
|
||||
#else
|
||||
[themeMusic stop];
|
||||
[themeMusic goToBeginning];
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
disc_operation_in_progress = YES;
|
||||
if ([[universe gameController] inFullScreenMode])
|
||||
@ -4350,13 +4370,18 @@ static BOOL toggling_music;
|
||||
[gui setBackgroundImage:nil];
|
||||
[self setGuiToStatusScreen];
|
||||
[universe setDisplayText:YES];
|
||||
#ifndef GNUSTEP
|
||||
|
||||
if (themeMusic)
|
||||
{
|
||||
StopMovie ([themeMusic QTMovie]);
|
||||
#ifndef GNUSTEP
|
||||
StopMovie ([themeMusic QTMovie]);
|
||||
GoToBeginningOfMovie ([themeMusic QTMovie]);
|
||||
}
|
||||
#else
|
||||
[themeMusic stop];
|
||||
[themeMusic goToBeginning];
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4478,6 +4503,8 @@ static BOOL toggling_music;
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
StopMovie ([dockingMusic QTMovie]);
|
||||
#else
|
||||
[dockingMusic stop];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -5087,6 +5114,14 @@ static BOOL toggling_music;
|
||||
[universe setViewDirection:VIEW_AFT];
|
||||
[self becomeLargeExplosion:4.0];
|
||||
[self moveForward:100.0];
|
||||
|
||||
// todo some check for ootunes
|
||||
if (dockingMusic)
|
||||
{
|
||||
if ([dockingMusic isPlaying])
|
||||
[dockingMusic stop];
|
||||
}
|
||||
|
||||
#ifdef HAVE_SOUND
|
||||
[destructionSound play];
|
||||
#endif
|
||||
@ -5221,6 +5256,8 @@ static BOOL toggling_music;
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
StopMovie ([dockingMusic QTMovie]);
|
||||
#else
|
||||
[dockingMusic stop];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -6599,13 +6636,18 @@ static int last_outfitting_index;
|
||||
if (gui)
|
||||
gui_screen = GUI_SCREEN_INTRO1;
|
||||
|
||||
#ifndef GNUSTEP
|
||||
|
||||
if (themeMusic)
|
||||
{
|
||||
GoToBeginningOfMovie ([themeMusic QTMovie]);
|
||||
#ifndef GNUSTEP
|
||||
GoToBeginningOfMovie ([themeMusic QTMovie]);
|
||||
StartMovie ([themeMusic QTMovie]);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
[themeMusic stop];
|
||||
[themeMusic goToBeginning];
|
||||
[themeMusic play];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setGuiToIntro2Screen
|
||||
|
@ -43,6 +43,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
#ifdef GNUSTEP
|
||||
#import "Comparison.h"
|
||||
#import "OOSound.h"
|
||||
#import "OOMusic.h"
|
||||
#endif
|
||||
|
||||
|
||||
@ -435,7 +436,42 @@ NSMutableDictionary* movie_cache;
|
||||
#ifdef GNUSTEP
|
||||
+ (id) movieFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername
|
||||
{
|
||||
return nil;
|
||||
OOMusic *result = nil;
|
||||
NSMutableArray *fpaths = [ResourceManager paths];
|
||||
int i, r;
|
||||
r = 0;
|
||||
if (!filename)
|
||||
return nil;
|
||||
|
||||
NSString* movie_key = [NSString stringWithFormat:@"%@:%@", foldername, filename];
|
||||
if (!movie_cache)
|
||||
movie_cache = [[NSMutableDictionary alloc] initWithCapacity:32];
|
||||
if ([movie_cache objectForKey:movie_key])
|
||||
return (id)[movie_cache objectForKey:movie_key]; // return the cached movie
|
||||
|
||||
for (i = 0; i < [fpaths count]; i++)
|
||||
{
|
||||
NSString *filepath = [(NSString *)[fpaths objectAtIndex:i] stringByAppendingPathComponent:filename];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
||||
result = [[OOMusic alloc] initWithContentsOfFile:filepath];
|
||||
if (foldername)
|
||||
{
|
||||
filepath = [[(NSString *)[fpaths objectAtIndex:i] stringByAppendingPathComponent:foldername] stringByAppendingPathComponent:filename];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
||||
{
|
||||
//NSLog(@"DEBUG ResourceManager found %@ at %@",filename,filepath);
|
||||
if (result)
|
||||
[result release];
|
||||
result = [[OOMusic alloc] initWithContentsOfFile:filepath];
|
||||
}
|
||||
}
|
||||
}
|
||||
//NSLog(@"---> ResourceManager found %d file(s) with name '%@' (in folder '%@')", r, filename, foldername);
|
||||
|
||||
if (result)
|
||||
[movie_cache setObject:result forKey:movie_key];
|
||||
|
||||
return [result autorelease];
|
||||
}
|
||||
#else
|
||||
+ (NSMovie *) movieFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername
|
||||
|
@ -59,7 +59,7 @@
|
||||
<key>key_map_home</key>
|
||||
<integer>302</integer>
|
||||
<key>key_comms_log</key>
|
||||
<integer>96</integer>
|
||||
<integer>126</integer>
|
||||
<key>key_next_compass_mode</key>
|
||||
<integer>92</integer>
|
||||
</dict>
|
||||
|
@ -2695,7 +2695,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
GLfloat cx_col0[4] = { 0.0, 1.0, 0.0, 0.25};
|
||||
GLfloat cx_col1[4] = { 0.0, 1.0, 0.0, 0.50};
|
||||
GLfloat cx_col2[4] = { 0.0, 1.0, 0.0, 0.75};
|
||||
glEnable(GL_LINE_SMOOTH); // alpha blending
|
||||
//glEnable(GL_LINE_SMOOTH); // alpha blending
|
||||
glLineWidth(2.0);
|
||||
|
||||
switch (weapon)
|
||||
|
@ -14,4 +14,7 @@
|
||||
#include <GL/glext.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
#endif /* OOLITE_LINUX */
|
||||
|
Loading…
x
Reference in New Issue
Block a user