Remove GLUT_EXCLUSIVE_FPUMODE --- it's not needed
Original Reporter info from Mantis: Michalis @michaliskambi
-
Reporter name: Michalis Kamburelis
Original Reporter info from Mantis: Michalis @michaliskambi
- Reporter name: Michalis Kamburelis
Description:
I propose to remove the code under {$ifdef GLUT_EXCLUSIVE_FPUMODE} from packages/opengl/src/glut.pp. That is, to revert the patch
svn diff -r8794:8795 http://svn.freepascal.org/svn/fpc
Reasoning: the GLUT_EXCLUSIVE_FPUMODE was caused by #8995 (closed). The submitter there saw glut routine causing EDivByZero, which was actually caused by OpenGL NVidia library (nvoglnt.dll). (Most probably during making OpenGL context "current" by glut, which is normal for NVidia OpenGL implementation under Windows, usually when GL_LIGHTING is enabled.)
In my opinion, it was a mistake to solve it by GLUT_EXCLUSIVE_FPUMODE. GLUT_EXCLUSIVE_FPUMODE wraps every glut call in a code that adds to exception mask [exDenormalized, exInvalidOp, exOverflow, exPrecision, exUnderflow, exZeroDivide]. But:
-
This doesn't really solve the problem, as it's the OpenGL library at fault here. So direct OpenGL calls could still cause problems. Or using any other method to initialize and make OpenGL context current (like direct glX, wgl methods.)
-
This is not needed anymore, as we have the correct solution (since fpc 2.2.0) inside the gl.pp unit itself: we do SetExceptionMask in gl.pp initialization. This was explained by my old bugreports #5914 (closed) and #7570 (closed), and in my experience works perfectly. Note that SetExceptionMask in gl.pp sets the same flags as GLUT_EXCLUSIVE_FPUMODE, but it applies to the whole following code (so protects every OpenGL call).
We of course assume that user doesn't reset SetExceptionMask afterwards. But the alternative is to wrap every OpenGL call. In any case, the solution only in the glut unit isn't useful.
- And a final note is that GLUT_EXCLUSIVE_FPUMODE also makes adding new glut functions cumbersome (I want to add freeglut extensions to glut unit). Every new function needs a wrapper. So it seems like a complication of glut unit that doesn't have any benefit.
I mentioned this on fpc-devel recently http://lists.freepascal.org/lists/fpc-devel/2010-November/023138.html , http://lists.freepascal.org/lists/fpc-devel/2010-November/023139.html . Submitting here, with reasoning, so this will not be forgotten :)
Mantis conversion info:
- Mantis ID: 18107
- Fixed in version: 2.4.4
- Fixed in revision: 16778 (#7624d5f1)
- Monitored by: » darius (Darius Blaszijk)