aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/lib/JEDI-SDL/OpenGL
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-20 00:54:21 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-20 00:54:21 +0000
commit1a16f5c72896d243cac33147e8ca28079b882ecf (patch)
treed973ef180bfd57d029a8771d9f465f76ff602890 /Game/Code/lib/JEDI-SDL/OpenGL
parentbeccaf9c93dcbab557d4b2fe6845a424f4f47e32 (diff)
downloadusdx-1a16f5c72896d243cac33147e8ca28079b882ecf.tar.gz
usdx-1a16f5c72896d243cac33147e8ca28079b882ecf.tar.xz
usdx-1a16f5c72896d243cac33147e8ca28079b882ecf.zip
- Delphi (in contrast to C/C++) handles floating-point multiplications with NaN or divisions by 0.0 as floating-point exceptions (FPE). This is a problem with some libraries which expect that e.g. "NaN * 3.0" is NaN or "4.0 / 0" is INFINITY.
- The (strange) default behavior can be changed by setting the control word of the FPU. This is done by assigning $133F to this register via Set8087CW() in delphi. In FPC it was not available for a long time but now it is. OpenGL12.pas contained an own version of Set8087CW() which was totally wrong because the important asm-directives (fclex and fldcw) were missing so it was not of any use. Hence it was removed from the unit so it does not hide the correct FPC version anymore. - This should fix some EDivByZero exceptions in floating-point expressions (as with projectM). git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@962 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch70
-rw-r--r--Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas4
-rw-r--r--Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas28
3 files changed, 83 insertions, 19 deletions
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch b/Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch
new file mode 100644
index 00000000..aeebeee5
--- /dev/null
+++ b/Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch
@@ -0,0 +1,70 @@
+Index: OpenGL/Pas/gl.pas
+===================================================================
+--- OpenGL/Pas/gl.pas (revision 961)
++++ OpenGL/Pas/gl.pas (working copy)
+@@ -2287,9 +2287,9 @@
+ end;
+
+ initialization
+- {$ifdef x86}
++ {$IF Defined(CPU386) or Defined(CPUI386) or Defined(CPUX86_64)}
+ Set8087CW($133F);
+- {$endif x86}
++ {$IFEND}
+
+ LoadOpenGL( GLLibName );
+
+Index: OpenGL/Pas/opengl12.pas
+===================================================================
+--- OpenGL/Pas/opengl12.pas (revision 961)
++++ OpenGL/Pas/opengl12.pas (working copy)
+@@ -7125,16 +7125,15 @@
+
+ //----------------------------------------------------------------------------------------------------------------------
+
+-{$ifndef VER140}
++// RaiseLastOSError did not exist in Delphi 5
++{$ifdef VER130}
+
+ procedure RaiseLastOSError;
+ begin
+- {$ifndef FPC}
+ RaiseLastWin32Error;
+- {$endif}
+ end;
+
+-{$endif VER140}
++{$endif}
+
+ //----------------------------------------------------------------------------------------------------------------------
+
+@@ -9948,21 +9947,16 @@
+ end;
+
+ //----------------------------------------------------------------------------------------------------------------------
+-{$ifdef FPC}
+-const Default8087CW: Word = $1332;
+
+-{$ASMMODE INTEL}
+-procedure Set8087CW(NewCW: Word); Assembler;
+-asm
+- MOV Default8087CW, AX
+-end;
+-{$endif}
+-
+-//----------------------------------------------------------------------------------------------------------------------
+-
+ initialization
+- ContextList := TThreadList.Create;
+- Set8087CW($133F);
++ ContextList := TThreadList.Create;
++ {$IF Defined(CPU386) or Defined(CPUI386) or Defined(CPUX86_64)}
++ // FPC has its own implementation of Set8087CW now. The wrongly
++ // coded (the important asm-directives were missing so it was not of any use!!!)
++ // implementation was removed from this unit so it does not hide the correct FPC version anymore.
++ // This should fix some EDivByZero exceptions in floating-point expressions.
++ Set8087CW($133F);
++ {$IFEND}
+ finalization
+ CloseOpenGL;
+ ContextList.Free;
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas
index d2bdcf8b..5c5ec0da 100644
--- a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas
+++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas
@@ -2287,9 +2287,9 @@ begin
end;
initialization
- {$ifdef x86}
+ {$IF Defined(CPU386) or Defined(CPUI386) or Defined(CPUX86_64)}
Set8087CW($133F);
- {$endif x86}
+ {$IFEND}
LoadOpenGL( GLLibName );
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas
index f75b6888..dd27bfbc 100644
--- a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas
+++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas
@@ -7125,16 +7125,15 @@ end;
//----------------------------------------------------------------------------------------------------------------------
-{$ifndef VER140}
+// RaiseLastOSError did not exist in Delphi 5
+{$ifdef VER130}
procedure RaiseLastOSError;
begin
- {$ifndef FPC}
RaiseLastWin32Error;
- {$endif}
end;
-{$endif VER140}
+{$endif}
//----------------------------------------------------------------------------------------------------------------------
@@ -9948,21 +9947,16 @@ begin
end;
//----------------------------------------------------------------------------------------------------------------------
-{$ifdef FPC}
-const Default8087CW: Word = $1332;
-
-{$ASMMODE INTEL}
-procedure Set8087CW(NewCW: Word); Assembler;
-asm
- MOV Default8087CW, AX
-end;
-{$endif}
-
-//----------------------------------------------------------------------------------------------------------------------
initialization
- ContextList := TThreadList.Create;
- Set8087CW($133F);
+ ContextList := TThreadList.Create;
+ {$IF Defined(CPU386) or Defined(CPUI386) or Defined(CPUX86_64)}
+ // FPC has its own implementation of Set8087CW now. The wrongly
+ // coded (the important asm-directives were missing so it was not of any use!!!)
+ // implementation was removed from this unit so it does not hide the correct FPC version anymore.
+ // This should fix some EDivByZero exceptions in floating-point expressions.
+ Set8087CW($133F);
+ {$IFEND}
finalization
CloseOpenGL;
ContextList.Free;