Reputation: 1187
I have several "plugins" - DLLs, which all have a GUI, now OpenGL based. It all works fine, but when I open many of them, a problem occurs (below)... It occur on my main development machine with quite old but still reasonable ATI Radeon HD 4600 (with newest drivers, still marked legacy though), but not on a quite modern laptop with neither the integrated Intel HD nor the NVidia's one.
2 things can happen, seems random:
A) wglCreateContext returns NULL, but GetLastError says everything is fine! In this case I have the backup plan with emulation using CPU. Slow, but works...
unfortunately...
B) "aticfx64.dll" crashes with access violation reading 0xffffffffffffffff. Apparently it's the ATI driver, but either way there is no way get away from this...
Any ideas? I mean it's not exactly typical to have so many windows open, but still it should be able to handle it, right? My main concern is if there is some limit or way to deal with this. I'm just a little afraid this could happen with say 2 windows... that would just be bad.
Upvotes: 1
Views: 882
Reputation: 1
Don't forget to call wglDeleteContext when you are not using any more a HGLRC, else you will have memory leaks and at the end, an access violation (on ati at least).
(I had this strange error until I found the issue)
Upvotes: 0
Reputation: 1
I'd suggest checking memory usage. If it happens only on multiple windows opened, you may expose a driver bug where it doesn't check whether allocation succeeds (allocation may fail when your memory is fragmented or you have limited memory). When wglCreateContext returns NULL, try to allocate a bigger chunk of memory - if it fails this might be the case.
Another issue could be using more shared contexts than driver allows. In theory spec (http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt) says that "An arbitrary number of contexts can share data in this fashion." but using arbitrarily huge number of shared contexts is a dusty corner of spec and may not be well tested. This could be the case if you use more than 32 shared contexts (shared contexts could be stored internally on DWORD as a bitmask). You can check this pretty easily by trying to create 33 shared contexts and checking whether any of them returns NULL.
Upvotes: 0