Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mac OS X + SDL compilation: workarounding two FPC SDL units problems #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion gears.pp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function FindRoot( Part: GearPtr ): GearPtr;
implementation

{ "sysutils" has to come before "dos" }
uses sysutils,dos,texutil;
uses sysutils,dos,texutil,math;

Function LastSAtt( LList: SAttPtr ): SAttPtr;
{ Find the last SAtt in this particular list. }
Expand Down Expand Up @@ -1274,6 +1274,23 @@ function FindRoot( Part: GearPtr ): GearPtr;


initialization
{ Workaround bug in the FPC units SDL_ttf and SDL_image
(see FPC sources, in packages/sdl/src/ ).
They miss these $linklib declarations for Mac OS X,
and the linker cannot find the appropriate symbols (IMG_Load, various TTF_xxx). }
{$if defined(SDLMODE) and defined(DARWIN)}
{$linklib SDL_image}
{$linklib SDL_ttf}
{$endif}

{ Looks like SDL on Mac OS X (at least the one installed by HomeBrew) uses OpenGL.
As such, it requires the same SetExceptionMask as OpenGL,
otherwise it may crash with "invalid floating point operation".
Do it here, as early as posssible, before anything can use SDL. }
{$if defined(SDLMODE) and defined(DARWIN) and (defined(cpui386) or defined(cpux86_64))}
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,exOverflow, exUnderflow, exPrecision]);
{$endif}

{ Make sure we have the required data directories. }
if paramcount() > 0 then begin
Config_Directory := IncludeTrailingPathDelimiter( paramstr(1) );
Expand Down