I found out whats wrong with my OpenGL Shift-it. There is a Division by zero exception in the gl library, especially on tiny vertextes (like the one on tip of a sphere) or on tiny slices of clipped boxes.
The question was, why it does work in C, but not work in freepascal. because I tried to make a sphere using gluSphere() in C, and it worked perfectly, but in my program it always crashed.
On the Hunt of the source of Exception, I first had to find out which kind of FPU exception/Trap it is. So I wrote my own traphandler and checked the parameters when enter the traphandler, sadly the fpu content was already cleared and the buffer where the content of the FPU registers should be noted was not assigned.
So I took an other way.. and set the FPU exception one by one to masked and checked when the crash disappeared.
I expected bad things with the masked expections on other parts of the calculation. It surprigingly worked VERY nicely. That way I found out, that Division by Zero exception flag mask this crash.
This made me curious and I checked how the setting of standard C programs are in AROS. I made a simple C program which reads out the FPU Control register (which controls the exceptions) and I got a $37F.. this reallly made me laughing loud (my wife must thinking, that I became mad.) becasue that simply mean, all FPU exceptions are masked… means ignored. I also checked my C-OpenGL program, the same. In my Freepascal programs I always find $1372: which means „Invalid Operation“, „Division By Zero“ and „Overflow“ are not masked.
I found out that also at Delphi, they deactivate all FPU exceptions by default if OpenGL is used (in the opengl unit initialization section). Now I’m thinking: one way would be to deactivate FPU exceptions for all FPC programs at AROS (becasue I have no way to catch them), or simply deactivate it for programs using OpenGL (as Delphi is doing).
A nice sidemark: This error only happen for software rendering, if you use hardware rendering it disappears completely. I didn’t know that I can use hardware rendering in linux-hosted mode, a user at aros-exec told me I should try the mesa.library in sys:storage/libs which has hardware support for linux-hosted installations. This indeed is very nice and then the game makes really fun.
The next step for the game would be to include sounds, the password system and some GUI for configuration, but all this things I postponed now. The game is already rather nice, the coding was really fun. And a proof that you really can make nice games/programs for AROS with FPC 😉