View previous topic :: View next topic |
Author |
Message |
Andrej08
Joined: 31 Aug 2010 Posts: 51
|
Posted: Sun Jul 10, 2011 2:15 pm Post subject: Exceptions not thrown when using NaNs in OpenGL |
|
|
I'm using DMD 2.053 on XP32. I've had two global floats which were not initialized before usage.
I've enabled all floating-point exceptions, but they don't seem to be triggered for NaNs:
Code: | GLfloat rtri;
GLfloat rquad;
int DrawGLScene()
{
FloatingPointControl fpc; // from std.math
fpc.enableExceptions(FloatingPointControl.allExceptions);
// now use the uninitialized float
glRotatef(rtri, 0.0f, 1.0f, 0.0f);
} // fpc is reset after the end of this scope
|
I don't get any hardware exceptions or software exceptions thrown, OpenGL just draws a black screen. Initializing both floats to 0.0f fixes this, but I would have expected an exception being thrown.
I could even do this:
Code: | int DrawGLScene()
{
auto x = rtri / 0; // NaN / 0
} |
And nothing happens. It works as expected in a non-opengl context:
Code: | import std.math;
void main()
{
FloatingPointControl fpc;
fpc.enableExceptions(FloatingPointControl.allExceptions);
float rtri;
auto x = rtri / 0; // NaN / 0 -> exception thrown
} |
The exceptions in OpenGL only seem to be triggered if NaN's are not used and it was also an invalid operation:
Code: | int DrawGLScene()
{
rtri = 0.0;
auto x = rtri / 0; // 0.0 / 0 -> hardware exception
}
|
I am properly initializing the Runtime in my WinMain function, so I can't tell what could be causing this. This was derived from the NeHe tutorials, I'm providing the sample code here (Derelict not included):
https://github.com/AndrejMitrovic/temporary/tree/master/nanbug
The build command used was:
Code: | For %%a in (lesson4.d) do dmd -of%%~na.exe %%a win32.lib %cd%\Derelict2\lib\DerelictUtil.lib %cd%\Derelict2\lib\DerelictGL.lib %cd%\Derelict2\lib\DerelictGLU.lib -I%cd%\Derelict2\import -version=Unicode -version=WIN32_WINNT_ONLY -version=WindowsNTonly -version=Windows2000 -version=Windows2003 -version=WindowsXP -version=WindowsVista -L-Subsystem:Windows:4 && %%~na.exe |
|
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Mon Jul 11, 2011 5:19 am Post subject: |
|
|
I think this is something that should go to one of the D newsgroups if you haven't posted there already. It has nothing to do with Derelict and I don't know the first thing about floating point exceptions. If I could help, I would. But, you'll get more eyes on it in the NG. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
Andrej08
Joined: 31 Aug 2010 Posts: 51
|
Posted: Mon Jul 11, 2011 10:31 am Post subject: |
|
|
Ok, no problem I'll post there. Thought it was something common. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|