Jump to content
  • Advertisement
Sign in to follow this  
ecco_the_dolphin

wglMakeCurrent fails

This topic is 1943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The problem is that sometimes (very-very-very rare) wglMakeCurrent(...) fails. GetLastError returns 2004 (ERROR_TRANSFORM_NOT_SUPPORTED - I dont know what this means). In the case if wglMakeCurrent fails during frame render pass, I just do nothing. The funny thing is that during next frame wglMakeCurrent succeeds and application runs fine. Could someone explain to me what the hell is going on? By the way, i use NVIDIA drivers 190.62; operating system is Windows XP.

Share this post


Link to post
Share on other sites
Advertisement
Yes, I call it every frame. I do this because there are several windows in my app, and I use one OpenGL context for all of them, so I need wglMakeCurrent(...) for every window I want to draw in.

Share this post


Link to post
Share on other sites
Is the application single-threaded?
(Update to the latest drivers too, from nvidia.com, they are at 195.x now. Shouldn't matter ofcourse but you never know, always test on latest drivers, bugs get fixed all the time).

Share this post


Link to post
Share on other sites
No, application is actually multithreaded (actually it is multithreaded ActiveX component). I use two OpenGL contexts: first is used for drawing into windows and second context is used by the second thread for rendering to texture (using FBO, by the way, I render not to an active texture. I mean that I actually have 2 textures, one is used by the first context and another by the second) which is used by the first context.

[Edited by - ecco_the_dolphin on December 4, 2009 5:42:26 PM]

Share this post


Link to post
Share on other sites
Sounds strange.. just a few ideas to check out:
Have you properly set the contexts up for sharing, through wglShareLists?
Is everything synced properly, so that you only try to use a context on one thread at once?
Read the remarks in the documentation for wglMakeCurrent.
Do you always use the same HDC to set the contexts?
I don't see what that error message means.. it says The requested transformation operation is not supported... but that doesn't really make much sense. Perhaps setting a matrix that isn't invertible or something? (If that is the type of transformation it's referring to at all). Or perhaps that error just happens to be the last one set because of a previous failure.

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
Do you always use the same HDC to set the contexts?
I don't see what that error message means.. it says The requested transformation operation is not supported... but that doesn't really make much sense. Perhaps setting a matrix that isn't invertible or something? (If that is the type of transformation it's referring to at all). Or perhaps that error just happens to be the last one set because of a previous failure.


Everything is synced properly, but I dont use the same HDC to set contexts, however I use HDCs with the equal pixel formats. Moreover in Debug build i have glGetError() call after almost every OpenGL function, so everything seems fine. I dont understand how wglMakeCurrent can fail and can succeed during next frame. I mean, application can run for a week, then for one frame wglMakeCurrent fails, and then application runs as usual. I use first context ONLY by the primary thread and second context ONLY by the second thread (except of initialization procedure). I dont render to an active texture, I synchronize texture names via SendMessageCall.

Share this post


Link to post
Share on other sites
And before doing SendMessage to change texture names, i call glFinish() and wglMakeCurrent(0,0) by the second thread and also detach texture from FBO. Moreover whem I draw frame by the primary thread I call glBindTexture(GL_TEXUTRE_2D,0) at the end of a frame to make shure that texture is not current for the primary thread.

Share this post


Link to post
Share on other sites
Does it fail only on the primary thread, only on the texture rendering thread, or on both?
Can you solve it for example by a while(failed) { Sleep(10); wglMakeCurrent(...); }?
I'm mostly guessing, and I don't know how your application or ActiveX works behind the scenes, but perhaps for some reason something is changing in the background at regular (or irregular) intervals, like DC changes or something. If you call wglMakeCurrent at exactly a time in the duration of such a change, perhaps it is not able to set a current context right then.

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
Does it fail only on the primary thread, only on the texture rendering thread, or on both?


It happens only on primary thread, e.g on thread that renders to ActiveX controls. I have found the following words in remarks section at wglMakeCurrent. : "GDI transformation and clipping in hdc are not supported by the rendering context." Could these be related to ERROR_TRANSFORM_NOT_SUPPORTED code? If that so, then your quess could be true. Thanks for you reply, may be I should ask microsoft about this code...However, i get my HDC only once during window creation, I set pixel format and dont release this HDC untill window is destroyed. Is it true, that if application will get ANOTHER HDC of my window, and change its settings, these changes will affect my own HDC?

Quote:
Original post by Erik Rufelt
Can you solve it for example by a while(failed) { Sleep(10); wglMakeCurrent(...); }?


I will try that, but if your quess is true, it will not help, because if application behind the scenes changes my hdc settings and than changes it back, then it happens in application message loop. During Sleep aplication does not respond to window messages.

[Edited by - ecco_the_dolphin on December 5, 2009 9:36:56 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!