PDA

View Full Version : Pbuffers, wglMakeCurrent, Run Time Error



drahei_c
06-26-2003, 05:19 AM
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

ehart
06-26-2003, 05:42 AM
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

roffe
06-26-2003, 03:43 PM
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://www.opengl.org/discussion_boards/ubb/smile.gif
http://developer.nvidia.com/view.asp?IO=ogl_rtt

drahei_c
06-27-2003, 04:45 AM
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

drahei_c
06-27-2003, 04:46 AM
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

heath
06-28-2003, 08:04 AM
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).]