Pbuffers, wglMakeCurrent, Run Time Error

Hi there!

I am working with the Windows XP Professional OS and the Borland C++ Builder 6. I have a ASUS GeForce 4 card installed with the newest driver (I suppose).

I want to use pbuffers and render to texture directly. But I don´t get that far because my problem is:
After I have initialized a pbuffer as usual wglChoosePixelFormarARB() -> wglCreatePbufferARB() ->
wglGetPbufferDCARB() ->
wglCreateContext()
and all these commands with the appropriate args execute fine without any problems or errors (well, that’s what GetLastError() tells me) I try to bind the pbuffer with wglMakeCurrent().

The code compiles but when I run the code an error message box pops up saying an EZeroDivide exception has occured:floating point division by zero. It must have something to do with the folowing assembly code: fstp dword ptr [edx-0x40].

I really don’t understand this because all the variables and arguments used are non-zero and wglMakeCurrent() for the regular on-screen buffers works satisfying.

I already tried and tried, changing pixelformats, arguments etc. but nothing helped. I need help desperately…Thanx!

CD

My memory is a little foggy here, but I believe the problem you are having is that the C runtime library is setting the control bits on the floating point unit to interupt on fp exceptions. You probably don’t want this behavior when doing 3D graphics.

I don’t know the right method to change it with that compiler, but MSVC had a function _controlfp that allows you to set stuff like this. Look for floating point status word or control word in the compiler help files.

-Evan

Originally posted by drahei_c:
EZeroDivide exception has occured:floating point division by zero.

NVIDIA has an example of pbuffer/rtt with src. Run it and check for similiar problems. If ok, copy and paste appropriate lines of code until the error goes away
http://developer.nvidia.com/view.asp?IO=ogl_rtt

You were right ehart!

It is also possible to mask out floating point exceptions using Borland C++ by including float.h and using
_control87(MCW_EM,MCW_EM) in the main routine.

Thanx a lot 4 this big help!

CD

You were right ehart!

It is also possible to mask out floating point exceptions using Borland C++ by including float.h and using
_control87(MCW_EM,MCW_EM) in the main routine.

Thanx a lot 4 this big help!

CD

Don’t be so happy drahei_c. I Don’t think that the solution is to mask the divide by zero FPE. I would prefer the old fashioned technique of finding out where I am dividing by zero, or what I’m doing to cause someone else to do this and just fix the problem, shoving it under the covers is NOT the answer.

Hope This helps.

Oh I fogot to mention, if your’re working in windows and using VStudio (I know you mentioned Borland), the debugger has the ability to break on specifi exceptions. go to that dialog box break always on the divzero exception and let your app run. The stack trace you get might be quite enlightening.

Heath

[This message has been edited by heath (edited 06-28-2003).]

[This message has been edited by heath (edited 06-28-2003).]

[This message has been edited by heath (edited 06-28-2003).]