View Full Version : VC6.0: PBuffer don't run without Debug-Info

11-22-2004, 10:58 AM

i'am not sure if this question is out of Topic or not.
I (have to) work with MS Visual C++ 6.0 on a GL Programm with PBuffer. I've a curios Problem.

If I compile in Debug mode everythig is fine. If i change to Release Mode the Programm starts and terminates without any message.

If I add in the Debug-Info drop-Down the last entry (dont know how it's named in english), the Programm runs fine again!!! How can this be? :confused:

Have anybody a Poblem like this? Any Ideas?

Thanks for advice


11-22-2004, 11:59 AM

Did you try to display OpenGL's error messages?

GLenum glErr;
int retCode = 0;

glErr = glGetError();
while (glErr != GL_NO_ERROR) {
std::cerr << gluErrorString(glErr) << std::endl;

retCode = 1;
glErr = glGetError();
}You should look for errors while you are creating the pixel buffer.

Also, before setting the pixel buffer as the current rendering target, do you check if it is still valid?

int flag = 0;
wglQueryPbufferARB( m_pBuffer, WGL_PBUFFER_LOST_ARB, &amp;flag );I hope it helps!

11-23-2004, 01:20 AM
I've got pbuffers run several times without any problems under VC6, under any compile setting, there must be a problem with your code I guess..
Would you mind giving further details on how you're actually using pbuffers?


11-23-2004, 01:58 AM
Mopst likely you're relying on an uninitialised variable being zero. When running in debug mode, allocated memory tends to be cleared to zero, which obviously doesn't happen in release. But it is really impossible for us to debug your code for you. Put lots of assert(!glGetError()) among your gl calls and step through the code in a debugger.

11-23-2004, 02:38 AM
harsman is most likely correct, though just relying on assert( !glGetError() ) might miss what is actually causing the problem. It is most likely an uninitialised variable, but it might not be something you use in GL (it might be a string or a pointer or anything really). In Project settings, set the warning level to Level 4 and the compiler might tell you where this is happening.

11-23-2004, 03:52 AM

I tried a lot. I checked on OpenGL Errors, but there
aren't any. I checked if PBuffers are valid too, but the Programm crashed on first Time Initialisation.

I found that it crushed in a call to wglChoosePixelFormatARB.

These are the parameters to wglChoosePixelFormat. The entries are the same in Debug and Release mode

iAttribs[1] = 1;
iAttribs[2] = WGL_PIXEL_TYPE_ARB;
iAttribs[3] = WGL_TYPE_RGBA_ARB;
iAttribs[5] = 1;
iAttribs[7] = 1;
iAttribs[8] = WGL_RED_BITS_ARB;
iAttribs[9] = 2;
iAttribs[10] = WGL_GREEN_BITS_ARB;
iAttribs[11] = 2;
iAttribs[12] = WGL_BLUE_BITS_ARB;
iAttribs[13] = 2;
iAttribs[14] = WGL_ALPHA_BITS_ARB;
iAttribs[15] = 2;
iAttribs[16] = WGL_COLOR_BITS_ARB;
iAttribs[17] = 8;
iAttribs[19] = GL_TRUE;
iAttribs[20-31] = 0;

fAttribs[0-31] = 0.0f;

m_hGLDC = wglGetCurrentDC();
int pixelFormat = 0;
unsigned int count = 0;

wglChoosePixelFormatARB(m_hGLDC, iAttribs, fAttribs, 32, &pixelFormat, &count);

I tried to compile with Warning Level 4 in Release mode, bute there are a lot of Warnings from Windows Header. There are also a lot Warnings from glprocs.h, which i use to Access the Extensions. I've got this from the GLSDK.

The glprocs Warnings are like this:
glprocs.c(522) : warning C4054: 'type cast' : From functionpointer 'int (__stdcall *)()' to 'void *'

Thanks for any advice again


11-23-2004, 04:29 AM

I don't get the part

iAttribs[20-31] = 0;

fAttribs[0-31] = 0.0f;
What are those indices in the array? iAttribs[20] = 0 would have been enough. And for fAttribs, simply pass NULL to wglChoosePixelFormatARB instead.

Also, did you check for the validity of the DC which was returned?


11-23-2004, 05:11 AM
> iAttribs[20-31] = 0;
which means in fact
iAttribs[-11] = 0;

> fAttribs[0-31] = 0.0f;
which means in fact
fAttribs[-31] = 0.0f;

You're writting in some bad memory place.

I would suggest you you use Paul Neetle's memory manager. It will probably help you find flaws in your code:

EDIT: replaced url with a link to the last version

11-24-2004, 10:10 AM

Eh sorry about my shortcut with
iAttrib[20-31] = 0
That means:
iAttrib[20] = 0; iAttrib[21]=0 and so on! I wouldn't
write that down.
The only reason, that these Fields are set are Modularity of the code, because I can set some
of the fields I need.

I will check the DC again. I think that I validate it. If I found my mistake I will post it.

Thanks for help!


11-28-2004, 01:27 AM
Hello everybody

I found the Problem. I use exeption Handling to
catch invalid Context of Variables. if a Variable
is invalid I throw an error and catch it at
the End of the Function.

I'am not sure why, but if I do that the Programm
runs only in Debug mode.

I remove the try .. catch block and write
the Messages with cerr directly.

Now everything works fine. Thanks a lot for your help again