diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-04-22 16:18:08 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-04-22 16:18:08 +0000 |
commit | 0bf82c1d17814e6190033e79984801846be27b6c (patch) | |
tree | a93469706a90b61d1b5f60e65c2777be5971e46f | |
parent | fe13131bbecd0d9da445a06ecfd6fc0733675dae (diff) | |
download | usdx-0bf82c1d17814e6190033e79984801846be27b6c.tar.gz usdx-0bf82c1d17814e6190033e79984801846be27b6c.tar.xz usdx-0bf82c1d17814e6190033e79984801846be27b6c.zip |
- new switches.inc layout
- support for projectM 1.1
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1033 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r-- | Game/Code/Classes/UConfig.pas | 6 | ||||
-rw-r--r-- | Game/Code/Classes/UVisualizer.pas | 799 | ||||
-rw-r--r-- | Game/Code/UltraStar.dpr | 11 | ||||
-rw-r--r-- | Game/Code/switches.inc | 242 |
4 files changed, 516 insertions, 542 deletions
diff --git a/Game/Code/Classes/UConfig.pas b/Game/Code/Classes/UConfig.pas index ae9ac150..5501acd0 100644 --- a/Game/Code/Classes/UConfig.pas +++ b/Game/Code/Classes/UConfig.pas @@ -150,12 +150,6 @@ const FPC_PATCH = 0; {$ENDIF} - {$IFDEF LAZARUS} - LAZARUS_VERSION = (LAZARUS_VERSION_MAJOR * VERSION_MAJOR) + - (LAZARUS_VERSION_MINOR * VERSION_MINOR) + - (LAZARUS_VERSION_RELEASE * VERSION_RELEASE); - {$ENDIF} - {$IFDEF HaveFFMpeg} LIBAVCODEC_VERSION = (LIBAVCODEC_VERSION_MAJOR * VERSION_MAJOR) + diff --git a/Game/Code/Classes/UVisualizer.pas b/Game/Code/Classes/UVisualizer.pas index 211f1b01..0b5e690b 100644 --- a/Game/Code/Classes/UVisualizer.pas +++ b/Game/Code/Classes/UVisualizer.pas @@ -1,394 +1,405 @@ -{############################################################################
-# Visualizer support for UltraStar deluxe #
-# #
-# Created by hennymcc #
-# Slight modifications by Jay Binks #
-# based on UVideo.pas #
-#############################################################################}
-
-unit UVisualizer;
-
-interface
-
-{$IFDEF FPC}
- {$MODE DELPHI}
-{$ENDIF}
-
-{$I switches.inc}
-
-uses
- SDL,
- UGraphicClasses,
- textgl,
- math,
- OpenGL12,
- SysUtils,
- UIni,
- {$ifdef DebugDisplay}
- {$ifdef win32}
- dialogs,
- {$endif}
- {$endif}
- projectM,
- UMusic;
-
-implementation
-
-uses
- UGraphic,
- UMain,
- ULog;
-
-var
- singleton_VideoProjectM : IVideoPlayback;
-
-const
- gx = 32;
- gy = 24;
- fps = 30;
- texsize = 512;
-
-var
- ProjectMPath : string;
- presetsDir : string;
- fontsDir : string;
-
- // FIXME: dirty fix needed because the init method is not
- // called yet.
- inited: boolean;
-
-type
- TVideoPlayback_ProjectM = class( TInterfacedObject, IVideoPlayback, IVideoVisualization )
- private
- pm : TProjectM;
-
- VisualizerStarted ,
- VisualizerPaused : Boolean;
-
- VisualTex : glUint;
- PCMData : TPCMData;
-
- RndPCMcount : integer;
-
- projMatrix: array[0..3, 0..3] of GLdouble;
- texMatrix: array[0..3, 0..3] of GLdouble;
-
- procedure VisualizerStart;
- procedure VisualizerStop;
-
- procedure VisualizerTogglePause;
-
- function GetRandomPCMData(var data: TPCMData): Cardinal;
-
- procedure SaveOpenGLState();
- procedure RestoreOpenGLState();
-
- public
- constructor Create();
- procedure Init();
- function GetName: String;
-
- function Open(const aFileName : string): boolean; // true if succeed
- procedure Close;
-
- procedure Play;
- procedure Pause;
- procedure Stop;
-
- procedure SetPosition(Time: real);
- function GetPosition: real;
-
- procedure GetFrame(Time: Extended);
- procedure DrawGL(Screen: integer);
- end;
-
-
-constructor TVideoPlayback_ProjectM.Create();
-begin
- RndPCMcount := 0;
-end;
-
-
-procedure TVideoPlayback_ProjectM.Init();
-begin
- // FIXME: dirty fix needed because the init method is not
- // called yet.
- inited := true;
-
- ProjectMPath := VisualsPath + 'projectM' + PathDelim;
- presetsDir := ProjectMPath + 'presets';
- fontsDir := ProjectMPath + 'fonts';
-
- VisualizerStarted := False;
- VisualizerPaused := False;
-
- {$IFDEF UseTexture}
- glGenTextures(1, PglUint(@VisualTex));
- glBindTexture(GL_TEXTURE_2D, VisualTex);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- {$ENDIF}
-end;
-
-function TVideoPlayback_ProjectM.GetName: String;
-begin
- result := 'ProjectM';
-end;
-
-
-function TVideoPlayback_ProjectM.Open(const aFileName : string): boolean; // true if succeed
-begin
- VisualizerStart();
- result := true;
-end;
-
-procedure TVideoPlayback_ProjectM.Close;
-begin
-end;
-
-procedure TVideoPlayback_ProjectM.Play;
-begin
- VisualizerStart();
-end;
-
-procedure TVideoPlayback_ProjectM.Pause;
-begin
- VisualizerTogglePause();
-end;
-
-procedure TVideoPlayback_ProjectM.Stop;
-begin
- VisualizerStop();
-end;
-
-procedure TVideoPlayback_ProjectM.SetPosition(Time: real);
-begin
- pm.RandomPreset();
-end;
-
-function TVideoPlayback_ProjectM.GetPosition: real;
-begin
- result := 0;
-end;
-
-procedure TVideoPlayback_ProjectM.SaveOpenGLState();
-begin
- // save all OpenGL state-machine attributes
- glPushAttrib(GL_ALL_ATTRIB_BITS);
-
- // save projection-matrix
- glMatrixMode(GL_PROJECTION);
- // - WARNING: projection-matrix stack-depth is only 2!
- // -> overflow might occur if glPopMatrix() is used for this matrix
- // -> use glGet() instead of glPushMatrix()
- glPushMatrix();
- //glGetDoublev(GL_PROJECTION_MATRIX, @projMatrix);
-
- // save texture-matrix
- glMatrixMode(GL_TEXTURE);
- // - WARNING: texture-matrix stack-depth is only 2!
- // -> overflow might occur if glPopMatrix() is used for this matrix
- // -> use glGet() instead of glPushMatrix() if problems appear
- glPushMatrix();
- //glGetDoublev(GL_TEXTURE_MATRIX, @texMatrix);
-
- // save modelview-matrix
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
-end;
-
-procedure TVideoPlayback_ProjectM.RestoreOpenGLState();
-begin
- // restore projection-matrix
- glMatrixMode(GL_PROJECTION);
- // - WARNING: projection-matrix stack-depth is only 2!
- // -> overflow _occurs_ if glPopMatrix() is used for this matrix
- // -> use glLoadMatrix() instead of glPopMatrix()
- glPopMatrix();
- //glLoadMatrixd(@projMatrix);
-
- // restore texture-matrix
- // -> overflow might occur if glPopMatrix() is used for this matrix
- glMatrixMode(GL_TEXTURE);
- glPopMatrix();
- //glLoadMatrixd(@texMatrix);
-
- // restore modelview-matrix
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-
- // restore all OpenGL state-machine attributes
- glPopAttrib();
-end;
-
-procedure TVideoPlayback_ProjectM.VisualizerStart;
-var
- initResult: Cardinal;
-begin
- // FIXME: dirty fix needed because the init method is not
- // called yet.
- if (not inited) then
- Init();
-
- VisualizerStarted := True;
-
- pm := TProjectM.Create(gx, gy, fps, texsize, ScreenW, ScreenH,
- presetsDir, fontsDir);
- //initResult := projectM_initRenderToTexture(pm);
-
- SaveOpenGLState();
- pm.ResetGL(ScreenW, ScreenH);
- RestoreOpenGLState();
-end;
-
-procedure TVideoPlayback_ProjectM.VisualizerStop;
-begin
- if VisualizerStarted then begin
- VisualizerStarted := False;
- pm.Free();
- end;
-end;
-
-procedure TVideoPlayback_ProjectM.VisualizerTogglePause;
-begin
- VisualizerPaused := not VisualizerPaused;
-end;
-
-procedure TVideoPlayback_ProjectM.GetFrame(Time: Extended);
-var
- nSamples: cardinal;
- stackDepth: Integer;
-begin
- if not VisualizerStarted then Exit;
- if VisualizerPaused then Exit;
-
- // get audio data
- nSamples := AudioPlayback.GetPCMData(PcmData);
-
- if nSamples = 0 then
- nSamples := GetRandomPCMData(PcmData);
-
- pm.AddPCM16Data(PSmallint(@PcmData), nSamples);
-
- // store OpenGL state (might be messed up otherwise)
- SaveOpenGLState();
- pm.ResetGL(ScreenW, ScreenH);
-
- //glGetIntegerv(GL_PROJECTION_STACK_DEPTH, @stackDepth);
- //writeln('StackDepth0: ' + inttostr(stackDepth));
-
- // let projectM render a frame
- try
- pm.RenderFrame();
- except
- // this may happen with some presets ( on linux ) if there is a div by zero
- // in projectM's getBeatVals() function (file: beat_detect.cc)
- Log.LogStatus('Div by zero!', 'Visualizer');
- SetPosition( now );
- end;
-
- //glGetIntegerv(GL_PROJECTION_STACK_DEPTH, @stackDepth);
- //writeln('StackDepth1: ' + inttostr(stackDepth));
-
- {$IFDEF UseTexture}
- glBindTexture(GL_TEXTURE_2D, VisualTex);
- glFlush();
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, VisualWidth, VisualHeight, 0);
- {$ENDIF}
-
- // restore USDX OpenGL state
- RestoreOpenGLState();
-
- // discard projectM's depth buffer information (avoid overlay)
- glClear(GL_DEPTH_BUFFER_BIT);
-end;
-
-procedure TVideoPlayback_ProjectM.DrawGL(Screen: integer);
-begin
- {$IFDEF UseTexture}
- // have a nice black background to draw on (even if there were errors opening the vid)
- if Screen=1 then begin
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
- end;
- // exit if there's nothing to draw
- if not VisualizerStarted then Exit;
-
- // setup display
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- gluOrtho2D(0, 1, 0, 1);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- glEnable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glBindTexture(GL_TEXTURE_2D, VisualTex);
- glColor4f(1, 1, 1, 1);
-
- // draw projectM frame
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0); glVertex2f(0, 0);
- glTexCoord2f(1, 0); glVertex2f(1, 0);
- glTexCoord2f(1, 1); glVertex2f(1, 1);
- glTexCoord2f(0, 1); glVertex2f(0, 1);
- glEnd();
-
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
-
- // restore state
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- {$ENDIF}
-end;
-
-function TVideoPlayback_ProjectM.GetRandomPCMData(var data: TPCMData): Cardinal;
-var
- i: integer;
-begin
- // Produce some fake PCM data
- if ( RndPCMcount mod 500 = 0 ) then
- begin
- for i := 0 to 511 do begin
- data[0][i] := 0;
- data[1][i] := 0;
- end;
- end
- else begin
- for i := 0 to 511 do begin
- if ( i mod 2 = 0 ) then begin
- data[0][i] := floor(Random * power(2.,14));
- data[1][i] := floor(Random * power(2.,14));
- end
- else begin;
- data[0][i] := floor(Random * power(2.,14));
- data[1][i] := floor(Random * power(2.,14));
- end;
- if ( i mod 2 = 1 ) then begin
- data[0][i] := -data[0][i];
- data[1][i] := -data[1][i];
- end;
- end;
- end;
- Inc( RndPCMcount );
- result := 512;
-end;
-
-
-initialization
- singleton_VideoProjectM := TVideoPlayback_ProjectM.create();
- AudioManager.add( singleton_VideoProjectM );
-
-finalization
- AudioManager.Remove( singleton_VideoProjectM );
-
-
-
-end.
+{############################################################################ +# Visualizer support for UltraStar deluxe # +# # +# Created by hennymcc # +# Slight modifications by Jay Binks # +# based on UVideo.pas # +#############################################################################} + +unit UVisualizer; + +interface + +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + +{$I switches.inc} + +uses + SDL, + UGraphicClasses, + textgl, + math, + OpenGL12, + SysUtils, + UIni, + projectM, + UMusic; + +implementation + +uses + UGraphic, + UMain, + UConfig, + ULog; + +(* + * TODO: + * - fix video/visualizer switching and initialisation + * - use GL_EXT_framebuffer_object for rendering to a separate framebuffer, + * this will prevent plugins from messing up our render-context + * (-> no stack corruption anymore, no need for Save/RestoreOpenGLState()). + * - create a generic (C-compatible) interface for visualization plugins + * - create a visualization plugin manager + * - write a plugin for projectM in C/C++ (so we need no wrapper anymore) + *) + +var + singleton_VideoProjectM : IVideoPlayback; + +var + ProjectMPath : string; + + // FIXME: dirty fix needed because the init method is not + // called yet. + inited: boolean; + +{$IF PROJECTM_VERSION < 1000000} // < 1.0 +const + meshX = 32; + meshY = 24; + fps = 30; + textureSize = 512; +{$IFEND} + +type + TVideoPlayback_ProjectM = class( TInterfacedObject, IVideoPlayback, IVideoVisualization ) + private + pm : TProjectM; + + VisualizerStarted , + VisualizerPaused : Boolean; + + VisualTex : glUint; + PCMData : TPCMData; + + RndPCMcount : integer; + + projMatrix: array[0..3, 0..3] of GLdouble; + texMatrix: array[0..3, 0..3] of GLdouble; + + procedure VisualizerStart; + procedure VisualizerStop; + + procedure VisualizerTogglePause; + + function GetRandomPCMData(var data: TPCMData): Cardinal; + + procedure SaveOpenGLState(); + procedure RestoreOpenGLState(); + + public + constructor Create(); + procedure Init(); + function GetName: String; + + function Open(const aFileName : string): boolean; // true if succeed + procedure Close; + + procedure Play; + procedure Pause; + procedure Stop; + + procedure SetPosition(Time: real); + function GetPosition: real; + + procedure GetFrame(Time: Extended); + procedure DrawGL(Screen: integer); + end; + + +constructor TVideoPlayback_ProjectM.Create(); +begin + inherited; +end; + + +procedure TVideoPlayback_ProjectM.Init(); +begin + // FIXME: dirty fix needed because the init method is not + // called yet. + if (inited) then + Exit; + inited := true; + + RndPCMcount := 0; + + ProjectMPath := ProjectM_DataDir + PathDelim; + + VisualizerStarted := False; + VisualizerPaused := False; + + {$IFDEF UseTexture} + glGenTextures(1, PglUint(@VisualTex)); + glBindTexture(GL_TEXTURE_2D, VisualTex); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + {$ENDIF} +end; + +function TVideoPlayback_ProjectM.GetName: String; +begin + result := 'ProjectM'; +end; + + +function TVideoPlayback_ProjectM.Open(const aFileName : string): boolean; // true if succeed +begin + VisualizerStart(); + result := true; +end; + +procedure TVideoPlayback_ProjectM.Close; +begin +end; + +procedure TVideoPlayback_ProjectM.Play; +begin + VisualizerStart(); +end; + +procedure TVideoPlayback_ProjectM.Pause; +begin + VisualizerTogglePause(); +end; + +procedure TVideoPlayback_ProjectM.Stop; +begin + VisualizerStop(); +end; + +procedure TVideoPlayback_ProjectM.SetPosition(Time: real); +begin + if assigned(pm) then + pm.NextPreset(); +end; + +function TVideoPlayback_ProjectM.GetPosition: real; +begin + result := 0; +end; + +procedure TVideoPlayback_ProjectM.SaveOpenGLState(); +begin + // save all OpenGL state-machine attributes + glPushAttrib(GL_ALL_ATTRIB_BITS); + + // Note: we do not use glPushMatrix() for the GL_PROJECTION and GL_TEXTURE stacks. + // OpenGL specifies the depth of those stacks to be at least 2 but projectM + // already uses 2 stack-entries so overflows might be possible on older hardware. + // In contrast to this the GL_MODELVIEW stack-size is at least 32, so we can + // use glPushMatrix() for this stack. + + // save projection-matrix + glMatrixMode(GL_PROJECTION); + glGetDoublev(GL_PROJECTION_MATRIX, @projMatrix); + {$IF (PROJECTM_VERSION >= 1000000) and (PROJECTM_VERSION < 1010000)} // [1.0..1.1) + // bugfix (1.0 and 1.01): projection-matrix is popped without being pushed first + glPushMatrix(); + {$IFEND} + + // save texture-matrix + glMatrixMode(GL_TEXTURE); + glGetDoublev(GL_TEXTURE_MATRIX, @texMatrix); + + // save modelview-matrix + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + {$IF (PROJECTM_VERSION >= 1000000) and (PROJECTM_VERSION < 1010000)} // [1.0..1.1) + // bugfix (1.0 and 1.01): modelview-matrix is popped without being pushed first + glPushMatrix(); + {$IFEND} +end; + +procedure TVideoPlayback_ProjectM.RestoreOpenGLState(); +begin + // restore projection-matrix + glMatrixMode(GL_PROJECTION); + glLoadMatrixd(@projMatrix); + + // restore texture-matrix + glMatrixMode(GL_TEXTURE); + glLoadMatrixd(@texMatrix); + + // restore modelview-matrix + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + // restore all OpenGL state-machine attributes + glPopAttrib(); +end; + +procedure TVideoPlayback_ProjectM.VisualizerStart; +var + initResult: Cardinal; +begin + if VisualizerStarted then + Exit; + + // FIXME: dirty fix needed because the init method is not + // called yet. + if (not inited) then + Init(); + + //try + {$IF PROJECTM_VERSION >= 1000000} // >= 1.0 + pm := TProjectM.Create(ProjectMPath + 'config.inp'); + {$ELSE} + pm := TProjectM.Create( + meshX, meshY, fps, textureSize, ScreenW, ScreenH, + ProjectMPath + 'presets', ProjectMPath + 'fonts'); + {$IFEND} + //except + //writeln('Exception:' + floattostr(test)); + // Exit; + //end; + +writeln('huk'); + + VisualizerStarted := True; + + // skip projectM preset + pm.RandomPreset(); + // initialize OpenGL + SaveOpenGLState(); + pm.ResetGL(ScreenW, ScreenH); + RestoreOpenGLState(); +end; + +procedure TVideoPlayback_ProjectM.VisualizerStop; +begin + if VisualizerStarted then + begin + VisualizerStarted := False; + pm.Free(); + end; +end; + +procedure TVideoPlayback_ProjectM.VisualizerTogglePause; +begin + VisualizerPaused := not VisualizerPaused; +end; + +procedure TVideoPlayback_ProjectM.GetFrame(Time: Extended); +var + nSamples: cardinal; + stackDepth: Integer; +begin + if not VisualizerStarted then + Exit; + + if VisualizerPaused then + Exit; + + // get audio data + nSamples := AudioPlayback.GetPCMData(PcmData); + + if (nSamples = 0) then + nSamples := GetRandomPCMData(PcmData); + + if (nSamples > 0) then + pm.AddPCM16Data(PSmallInt(@PcmData), nSamples); + + // store OpenGL state (might be messed up otherwise) + SaveOpenGLState(); + pm.ResetGL(ScreenW, ScreenH); + + // let projectM render a frame + pm.RenderFrame(); + + {$IFDEF UseTexture} + glBindTexture(GL_TEXTURE_2D, VisualTex); + glFlush(); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, VisualWidth, VisualHeight, 0); + {$ENDIF} + + // restore USDX OpenGL state + RestoreOpenGLState(); + + // discard projectM's depth buffer information (avoid overlay) + glClear(GL_DEPTH_BUFFER_BIT); +end; + +procedure TVideoPlayback_ProjectM.DrawGL(Screen: integer); +begin + {$IFDEF UseTexture} + // have a nice black background to draw on + if (Screen = 1) then + begin + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + end; + + // exit if there's nothing to draw + if not VisualizerStarted then + Exit; + + // setup display + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + gluOrtho2D(0, 1, 0, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glBindTexture(GL_TEXTURE_2D, VisualTex); + glColor4f(1, 1, 1, 1); + + // draw projectM frame + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(0, 0); + glTexCoord2f(1, 0); glVertex2f(1, 0); + glTexCoord2f(1, 1); glVertex2f(1, 1); + glTexCoord2f(0, 1); glVertex2f(0, 1); + glEnd(); + + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + // restore state + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + {$ENDIF} +end; + +function TVideoPlayback_ProjectM.GetRandomPCMData(var data: TPCMData): Cardinal; +var + i: integer; +begin + // Produce some fake PCM data + if (RndPCMcount mod 500 = 0) then + begin + FillChar(data, SizeOf(TPCMData), 0); + end + else + begin + for i := 0 to 511 do + begin + data[i][0] := Random(High(Word)+1); + data[i][1] := Random(High(Word)+1); + end; + end; + Inc(RndPCMcount); + result := 512; +end; + + +initialization + singleton_VideoProjectM := TVideoPlayback_ProjectM.create(); + AudioManager.add( singleton_VideoProjectM ); + +finalization + AudioManager.Remove( singleton_VideoProjectM ); + + + +end. diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr index 5ba06b79..3cfe2b2d 100644 --- a/Game/Code/UltraStar.dpr +++ b/Game/Code/UltraStar.dpr @@ -69,11 +69,8 @@ uses {$ENDIF} {$ENDIF} - {$IFDEF UseProjectM_0_9} - projectM in 'lib\projectM\0.9\projectM.pas', - {$ENDIF} - {$IFDEF UseProjectM_1_0_PLUS} - projectM in 'lib\projectM\1.0\projectM.pas', + {$IFDEF UseProjectM} + projectM in 'lib\projectM\projectM.pas', {$ENDIF} SQLiteTable3 in 'lib\SQLite\SQLiteTable3.pas', @@ -157,6 +154,7 @@ uses // TODO : these all need to be renamed like UMedia_******** for consistency UMusic in 'Classes\UMusic.pas', + //UAudioPlaybackBase in 'Classes\UAudioPlaybackBase.pas', UMedia_dummy in 'Classes\UMedia_dummy.pas', // Must be first UMedia Unit, all others will override available interfaces {$IFDEF UseProjectM} UVisualizer in 'Classes\UVisualizer.pas', // MUST be before Video... so video can override... @@ -237,9 +235,6 @@ uses UPluginDefs in '..\..\Modis\SDK\UPluginDefs.pas', //New SDK, not only Modis UPartyDefs in '..\..\Modis\SDK\UPartyDefs.pas', //Headers to register Party Modes - {$IFDEF win32} - Windows, - {$ENDIF} SysUtils; begin diff --git a/Game/Code/switches.inc b/Game/Code/switches.inc index 465aef09..c803b3f7 100644 --- a/Game/Code/switches.inc +++ b/Game/Code/switches.inc @@ -1,134 +1,108 @@ -// Comment by eddie:
-// The mac port currently also uses the WIN32 define.
-// Once I get the beast compiled, linked and running
-// I will change this.
-// There are some parts where the WIN32 define could not
-// be used. I changed the WIN32 to MSWINDOWS.
-// So, for Windows-only code use the MSWINDOWS define.
-
-{$IFDEF FPC}
- {$DEFINE CONSOLE}
- {$IFDEF DARWIN}
- {$H+}
- {$R-}
- {$DEFINE WIN32}
- {$DEFINE TRANSLATE}
- {$DEFINE UTF8_FILENAMES}
- {$ENDIF}
-
- {$DEFINE DLL_CDECL}
- {$DEFINE HasInline}
- {$UNDEF UseSerialPort}
-{$ELSE}
- {$UNDEF CONSOLE} // Delphi requires a special app type... no thanks ! :)
- // {$DEFINE CONSOLE} // -- use for development only !
- {$DEFINE Delphi}
-
- // Delphi version numbers (ignore versions released before Delphi 6 as they miss the $IF directive):
- // Delphi 6 (VER140), Delphi 7 (VER150), Delphi 8 (VER160)
- // Delphi 9/2005 (VER170), Delphi 10/2006 (VER180)
-
- // the inline-procedure directive was introduced with Delphi 2005
- {$IF not (Defined(VER140) or Defined(VER150) or Defined(VER160))}
- {$DEFINE HasInline}
- {$IFEND}
-
- {$DEFINE DLL_STDCALL}
- {$UNDEF UseSerialPort}
-{$ENDIF}
-
-
-{$IF Defined(win32)}
- // include defines but no constants
- {$IFDEF DARWIN}
- {$I config-macosx.inc}
- {$ELSE}
- {$I config-win.inc}
- {$ENDIF}
-
- // audio config
- {$DEFINE WinAudioLib_BASS}
- {$IFDEF WinAudioLib_BASS}
- {$DEFINE UseBASSPlayback}
- {$DEFINE UseBASSInput}
- {$ELSE}
- {$DEFINE UseFFMpegDecoder}
- //{$DEFINE UsePortaudioPlayback}
- {$DEFINE UseSDLPlayback}
- {$DEFINE UsePortaudioInput}
- {$DEFINE UsePortmixer}
- {$ENDIF}
- {$UNDEF WinAudioLib_BASS}
-
- // video config
- {$IFDEF HaveFFMpeg}
- {$DEFINE UseFFMpegVideo}
- {$IFDEF HaveSWScale}
- {$DEFINE UseSWScale}
- {$ENDIF}
- {$ENDIF}
-
- // misc defines
-
- {$IF Defined(HaveProjectM_0_9)}
- {$DEFINE UseProjectM_0_9}
- {$ELSEIF Defined(HaveProjectM_1_0_PLUS)}
- {$DEFINE UseProjectM_1_0_PLUS}
- {$IFEND}
-
- {$IFDEF DEBUG}
- {$IFNDEF DARWIN}
- {$IFDEF CONSOLE}
- {$APPTYPE CONSOLE}
- {$ENDIF}
- {$ENDIF}
- {$ENDIF}
-
- {$IFDEF MSWINDOWS}
- {$DEFINE UseMIDIPort}
- {$ENDIF}
-{$ELSEIF Defined(Linux)}
- // include defines but no constants
- {$I config-linux.inc}
-
- // audio config
- {$IFDEF HaveFFMpeg}
- {$DEFINE UseFFMpegDecoder}
- {$IFDEF HavePortaudio}
- //{$DEFINE UsePortaudioPlayback}
- {$DEFINE UseSDLPlayback}
- {$DEFINE UsePortaudioInput}
- {$ENDIF}
- {$ENDIF}
-
- // video config
- {$IFDEF HaveFFMpeg}
- {$DEFINE UseFFMpegVideo}
- {$IFDEF HaveSWScale}
- {$DEFINE UseSWScale}
- {$ENDIF}
- {$ENDIF}
-
- // misc defines
- {$IFDEF HaveProjectM}
- // this causes trouble at the moment
- //{$DEFINE UseProjectM_0_9}
- {$ENDIF}
-{$IFEND}
-
-{$IF Defined(UseFFMpegVideo) or Defined(UseFFMpegDecoder)}
- {$DEFINE UseFFMpeg}
-{$IFEND}
-
-{$IF Defined(UseBASSInput) or Defined(UseBASSPlayback)}
- {$DEFINE UseBASS}
-{$IFEND}
-
-{$IF Defined(UsePortaudioInput) or Defined(UsePortaudioPlayback)}
- {$DEFINE UsePortaudio}
-{$IFEND}
-
-{$IF Defined(UseProjectM_0_9) or Defined(UseProjectM_1_0_PLUS)}
- {$DEFINE UseProjectM}
-{$IFEND}
-
+// Comment by eddie: +// The mac port currently also uses the WIN32 define. +// Once I get the beast compiled, linked and running +// I will change this. +// There are some parts where the WIN32 define could not +// be used. I changed the WIN32 to MSWINDOWS. +// So, for Windows-only code use the MSWINDOWS define. + +// compiler/IDE dependent config +{$IFDEF FPC} + {$DEFINE CONSOLE} + {$IFDEF DARWIN} + {$H+} // enables usage of AnsiString as String-type + {$R-} // disables range-checks + {$ENDIF} + + // if -dDEBUG is specified on the command-line, FPC uses some default + // compiler-flags specified in fpc.cfg -> use -dDEBUG_MODE instead + {$IFDEF DEBUG_MODE} + {$DEFINE DEBUG} + {$ENDIF} + + {$DEFINE DLL_CDECL} + {$DEFINE HasInline} +{$ELSE} + {$UNDEF CONSOLE} // Delphi requires a special app type... no thanks ! :) + // {$DEFINE CONSOLE} // -- use for development only ! + {$DEFINE Delphi} + + // Delphi version numbers (ignore versions released before Delphi 6 as they miss the $IF directive): + // Delphi 6 (VER140), Delphi 7 (VER150), Delphi 8 (VER160) + // Delphi 9/2005 (VER170), Delphi 10/2006 (VER180) + + // the inline-procedure directive was introduced with Delphi 2005 + {$IF not (Defined(VER140) or Defined(VER150) or Defined(VER160))} + {$DEFINE HasInline} + {$IFEND} +{$ENDIF} + + +// platform dependent config +{$IF Defined(MSWINDOWS)} + // include defines but no constants + {$I config-win.inc} + + {$IFDEF DEBUG} + {$IFDEF CONSOLE} + {$APPTYPE CONSOLE} + {$ENDIF} + {$ENDIF} + + {$DEFINE HaveBASS} + {$UNDEF UseSerialPort} + {$DEFINE UseMIDIPort} +{$ELSEIF Defined(LINUX)} + // include defines but no constants + {$I config-linux.inc} +{$ELSEIF Defined(DARWIN)} + // include defines but no constants + {$I config-macosx.inc} + + {$DEFINE HaveBASS} + {$DEFINE DLL_CDECL} + {$DEFINE WIN32} + {$DEFINE UTF8_FILENAMES} +{$IFEND} + +// audio config +{$IF Defined(HaveBASS)} + {$DEFINE UseBASSPlayback} + {$DEFINE UseBASSInput} +{$ELSEIF Defined(HavePortaudio)} + //{$DEFINE UsePortaudioPlayback} + {$DEFINE UseSDLPlayback} + {$DEFINE UsePortaudioInput} + {$IFDEF HavePortmixer} + {$DEFINE UsePortmixer} + {$ENDIF} +{$IFEND} + +// ffmpeg config +{$IFDEF HaveFFMpeg} + {$DEFINE UseFFMpegDecoder} + {$DEFINE UseFFMpegVideo} + {$IFDEF HaveSWScale} + {$DEFINE UseSWScale} + {$ENDIF} +{$ENDIF} + +// projectM config +{$IF Defined(HaveProjectM)} + {$DEFINE UseProjectM} +{$IFEND} + +// specify some useful defines + +{$IF Defined(UseFFMpegVideo) or Defined(UseFFMpegDecoder)} + {$DEFINE UseFFMpeg} +{$IFEND} + +{$IF Defined(UseBASSInput) or Defined(UseBASSPlayback)} + {$DEFINE UseBASS} +{$IFEND} + +{$IF Defined(UsePortaudioInput) or Defined(UsePortaudioPlayback)} + {$DEFINE UsePortaudio} +{$IFEND} + |