gl unit needs Set8087CW under Win32
Original Reporter info from Mantis: FPCCore
-
Reporter name: FPC core team
Original Reporter info from Mantis: FPCCore
- Reporter name: FPC core team
Description:
When you're using OpenGL under Win32 you have to mask exceptions off. That's because OpenGL libraries under Win32 may produce (under valid circumstances) some exceptions that should be ignored. This is a known thing for all Delphi OpenGL bindings, unfortunately in FPC's gl unit there's a line
{$IFNDEF FPC}
Set8087CW($133F);
{$ENDIF}
which
-
incorrectly does not call Set8087CW when it's compiled with FPC (probably because FPC 1.0.x did not have Set8087CW ?).
-
unnecessarily suggests that Set8087CW is needed under all platforms, but actually it's only needed for Win32 (and maybe for 64-bit Windows, I don't know; but for sure it's not needed under anything non-M$).
The nasty thing about this bug is that it's hard to predictably reproduce this on any Win32 library, as this depends on your installed OpenGL implementation (e.g. most OpenGL implementations under Win32 usually manifest this problem when you're rendering some things with lighting turned on; expreriences under other OpenGL implementations may vary; e.g. when using Mesa3d compiled under Win32 this problem does not manifest at all, AFAIK). That's why I'm not submitting a test case, as it would be quite involved. See e.g. [http://www.opengl.org/resources/libraries/glut/glut_faq.html#Q39] for confirmation that this fix is needed.
This is an old bug of gl units under Win32, and I'm quite ashamed that I didn't submit it earlier... Hopefully this fix can make to FPC 2.0.0, despite the fact that RELEASE_2_0_0 is already tagged in cvs ? As this is almost a show-stopper for FPC under Win32 using OpenGL.
The following trivial patch solves the problem:
--- gl.pp 14 Feb 2005 17:13:21 -0000 1.6
+++ gl.pp 9 May 2005 07:01:35 -0000
@@ -2245,7 +2245,7 @@
initialization
- {$IFNDEF FPC}
+ {$IFDEF WIN32}
Set8087CW($133F);
{$ENDIF}
Additional information:
Reporter: Michalis Kamburelis
EMail: michalis at camelot dot homedns dot org
Mantis conversion info:
- Mantis ID: 5914
- OS: Win32
- Version: 1.9.9
- Fixed in version: 2.0.2