Using OpenGL from Win2k Service

Hello.

I have written a System Service (aka “Windows NT Service”) which creates an opengl window and draws various stuff. this works fine, BUT:

while the service is running, and even if the drawing-window was disposed properly, NO other application can be started, that uses OpenGL (i.e. fails with an error-msg).

actually, as soon as my service has called “wglCreateContext”, all other applications calling “wglCreateContext” will fail with error 1114 (DLL initialization failed).
My Service runs as “SYSTEM” user, so i tryed to impersonate a non-system user (which looked like it worked) but that didn’t fix the problem.
I also exported all OpenGL stuff into a DLL, but other applications still fail to call “wglCreateContext” even after i unloaded the DLL again.

any idea would be helpfull!

My System: Windows 2000, OpenGL 1.3.1, nVidia Geforce 2MX, VisualC++

Perhaps the execution environment for Windows Services is different from that of a regular application. This should be documented on MSDN.

One thing you could try would be to manually load opengl32.dll and get the functions you need out of that, rather than linking statically to it. That way, you have a little more control, and perhaps you work around whatever the problem is. Or perhaps not.

maybe you should check out, how your application works with other systems. especially with different 3D-HW/drivers.

Yuck.
Rewrote everything to dynamically load opengl32.dll. that did not solve the problem.
i even duplicated opengl32.dll to myopengl32.dll and loaded this, but this did not work either.

using different hardware is not possible because it has to run on excactly this (and only this) machine. after all the machine was updated to a geforce4 and ogl 1.4.0 which didnt solve the problem either.

other ideas anyone?

Can you just spwan a child process? Or will that, too, not be allowed to talk to the display device? Can you start a regular interactive process with no window on start-up, and signal it to create a window and start rendering when the service wants it to?

Oddly enough I noticed this problem in older drivers with apps based on Nehe’s base code. But that was normal apps and Win98 - and the problem doesn’t exhibit itself under Win2k with 40.71 drivers.

And given you mentioned 1.4 I doubt there is much use in recommending updated drivers.

Well, this is probably the most drastic measure suggested, but perhaps you should split your program into a client/server model. The service/server runs as system in the background, and provides hooks for your client “OpenGL view” application to do it’s thing. I think this is how UIs for services are implemented, anyway, but for a different reason.

-Won

@jwatte:
the problem is, that my service does nice job. draws my gfx and everything fine. but you cannot start any other ogl app while my service is running.
creating an independent render-thread didnt solve the problem.

@rgpc:
The same gfx code in a regular applications does not cause those problems. the code is actually (init parts) from NeHe, but i did not found any better way to init ogl under windows (hmm, im a win noob though g)

@won:
yeah. this was my last idea. but i think i will make it that way. hmm, looks like i haven’t any other possibilities anyway ;o)

Another strange thing (hm actually very strange) i discovered:

The usual problem:

  1. start my service
  2. start my opengl app (fails…!)

Now:

  1. start my opengl app (success)
  2. start my service (success!)
  3. start another opengl app (success!!?!)

maybe somebody is able to explain that to me… :o)