wglMakeCurrent() fails silently

Hi,

below is a simple test, in general i want to switch between a pixelbuffer and the main screen.
Everything is initializing fine. The switch to hPBufferDC/RC is always working but when i try to
switch back to hMainDC/RC, both wglMakeCurrent() and wglMakeContextCurrentARB(), fail but
do not return ‘FALSE’.
GetLastError() returns error 126 ERROR_MOD_NOT_FOUND.
Worst thing is that i had it already working and i dont know if i messed things up in a late
night session or if it has to do with my switch from NV to ATI (x800 XL).

  

hMainDC = wglGetCurrentDC();
hMainRC = wglGetCurrentContext();

checkError();
wglMakeContextCurrentARB(hPBufferDC, hPBufferDC, hPBufferRC);
checkError();
wglMakeContextCurrentARB(hMainDC, hMainDC, hMainRC);
checkError();
wglMakeContextCurrentARB(hPBufferDC, hPBufferDC, hPBufferRC);
checkError();
wglMakeContextCurrentARB(hMainDC, hMainDC, hMainRC);
checkError();

  

Thanks for reading! Any Idea?

(Yes, i know about FBO’s. They are nice and easy to use.
But i need help on this special one :wink: )

Originally posted by binary:
both wglMakeCurrent() and wglMakeContextCurrentARB(), fail but
do not return ‘FALSE’.
GetLastError() returns error 126 ERROR_MOD_NOT_FOUND.

It is incorrect to call GetLastError() if the wglMakeCurrent() does not return FALSE. It is not guaranteed that the last error code will be set to ERROR_SUCCESS if the function succeeds. The error code you are getting might be set by some function internally used in implementation of wglMakeCurrent() whose failure was already handled by wglMakeCurrent().

Fails the operation because of this check or does the scene really not render?

Phew,

the bug was simpler than i thought, so simple that i cant tell. :wink:

I used GetLastError() to track down the bug.
In future i will stick to use it when an error occured TO CHECK what the error was.

Thank you!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.