init from DLL

I am trying to initialize my OGL stuff from within the InitInstance function of a DLL I’ve created. Is this allowed?

Here’s my situation:
I am using FBOs. What happens is the call to glGenFramebuffers succeeds, but then glBindFramebuffers hangs indefinitely - it never returns, CPU is inactive.

When I execute the same code in an exported function of the DLL, everything is ok, but I’d much prefer to do it in InitInstance. I know the correct contexts are current when these calls are made.

I load the DLL dynamically into a console app, create a window or display, then use that window’s handle for my OGL init. All works if I init from within that console app.

I’m not really new to OGL, but this is something I’ve never tried before, and can’t find anything written about this scenario, or specifically about initializing FBOs from a DLL.

Would really appreciate any advice!

I am trying to initialize my OGL stuff from within the InitInstance function of a DLL I’ve created. Is this allowed?

I don’t know, but there’s every chance that it’s really not a good idea. You’ll have to create a window, and I doubt that Microsoft suggests doing that in DLL initialization.

DLL initialization should be fast. It should do basic stuff necessary to make the DLL’s code function (like initializing static variables and such). It’s probably not a good idea to be performing heavy-weight operations like window creation, connecting to internet sockets, or OpenGL context generation.

I did some light Googling (“InitInstance DLL”) and I found that calling LoadLibrary (and therefore calling anything that eventually calls LoadLibrary) from DllMain (which is what calls InitInstance) is a Bad Thing. And I’m fairly sure that OpenGL context creation uses LoadLibrary at some point to load the ICD OpenGL .dll file.

Thanks for the response. I had a feeling that this was not really a great idea, but couldn’t find anything definitive. I was stumped about why so many calls succeeded, like the window creation, but then binding the framebuffer that had just been created would fail. And not even fail, but hang forever. Maybe I should just take that as a sign to initialize OGL elsewhere. It does seem to work when I don’t use the FBO, but I’m sure it’s still not a good practice.
Thanks again!

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