Skip to main content
GameDev.net gamedev.net
🔒 Locked

wglGetPixelFormat : GL_INVALID_OPERATION

Started by Callidus Nov 8, 2007 at 2:16 AM 5 replies 3.9k views
Original Post
Callidus
Callidus
Dear Community, I am using glIntercept to get a better understanding of what my application actually sends to the driver. It reports that the function wglGetPixelFormat generates the error GL_INVALID_OPERATION. The surprising thing is that there is no single call to this function made by my engine. Since the error occurs once per frame, I suppose it is triggered somewhere in the OS when switchting between the two buffers (I am using double buffering). However, this is merely an assumption. Has anyone encountered this problem, too and was possibly able to solve it? Any hints are welcome and I am glad to share more details that could lead to a solution. Best regards Calli
Caste
Caste
Perhaps you find some hints in this thread, they discussed that GL_INVALID_OPERATION gets triggered off when using OpenGL calls before having a rendering context.

But wglGetPixelFormat is probably called from another wgl call or from ChoosePixelFormat..

So be sure you start using OpenGL calls after having initialized your window.

Another thing that strucks me is that you get the error each frame.. wgl-Calls except for wglMakeCurrent should be used while setting up, not all the time.

Hope you can use some of the things my mind spilled out [wink]
Callidus
Callidus
Hi Caste,

thanks for your reply. I have read through the post you pointed at. However, as you mentioned, too, the strange thing is that the error occurs once per frame.

So I took a look at what functions are called per frame. This was only one function, namely the one to swap buffers:

BOOL SwapBuffers(HDC);

Commenting out this function will stop the generation of GL_INVALID_OPERATION errors. However, drawing is no longer possible, since the double buffer does not get swapped anymore. The sad thing is, that this function is an OS function and so there is not much that I can do.

By the way: I am newly running on Vista and I think this issue only appeared after the migration. Has anyone else seen this error appear on Vista?

Best regards

Calli
V-man
V-man
I don't run Vista, but SwapBuffers is not the one raising that error. Only GL functions, in other words certain functions starting with gl can generate that error.

Use a good debugger and look at the trace file
http://glintercept.nutty.org
Callidus
Callidus
Sorry, V-Man, but in my first post I already mentioned that I am using glIntercept. And commenting out the SwapBuffers command made the error disappear.

It might very well be possible that this command actually results in some gl* calls behind the scenes, however, this is out of my control.

By the way, here is the relevant part of the glIntercept call trace:

wglSwapBuffers(0x8301107d)
----->wglGetPixelFormat(0x8301107d)=9 Time= 0us=true
----->wglGetPixelFormat(0x8301107d)=9 glGetError() = GL_INVALID_OPERATION Time= 2us Time= 2us

Thanks for your help

Calli
V-man
V-man
What if you run one of those simple programs from the red book?

If they work fine, we already know it's something specific to your code and SwapBuffers is likely a red herring.

It doesn't necessarily mean your code has a bug unless you get the same problem on Win XP, with other GPUs, with other driver versions.
dchristopherfennell
dchristopherfennell
For anyone else reading about this problem, the answer appears to be related to NVIDIA cards with the beta glIntercept.
You can read more about it here: My link

The latest glIntercept fixes the problem: download

If you don't download the latest app, you can prevent this error from occurring by turning off "Threaded Optimization" under your 3D management menu in NVIDIA settings.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.