Share OpenGL context between two programs

Is there any way to launch another program and let it access the first program’s OpenGL context? I would like to let an editor launch an external application and not have to reload the scene.

Unfortunately it is not possible.
You have to send event to your OpenGL process to do what you need to do.

You can do the following:
Create a new OpenGL context in your new program in a way that it is in the same share group as the original context.

This way you cannot draw to the original application’s context but you can access the resources of it (like buffer objects and textures).

Maybe this is enough to make your use case working.

Suppose it is needed for the Leadwerks engine. Isn’t it?

No, you can’t do that. As mfort already pointed out, sharing contexts across process boundaries is not possible.

Okay, you’re right, I realized that as well, however I still have some solution. It may sound kind of hackish but in fact is not that awful as it looks like:

  1. Create the editor code inside a DLL.
  2. Create a bootstap EXE for the editor.
  3. The bootstrap sends a message to the engine process.
  4. The engine process as a respond to this message will load the editor DLL and execute it’s main function in a separate thread.
  5. This thread executing the editor code now can create a context in the same share group thus can access the resources.

Please let me know if this possibility does fit your needs.

I knew it was impossible, but figured it was worth asking, just in case.

Sorry for the off-topic question, but can you tell any inside information about what’s going on about Leadwerks engine?

I’m very interested as even though I think Leadwerks is not the most well-optimized rendering engine out there, I see a lot of opportunities in it and I really like the way how you took advantage of deferred rendering and various other rendering techniques in it.

I actually started Leadwerks 3.0 last week. It’s being written in pure C++, and intended for all platforms. I can’t wait to get into the OpenGL 4 stuff in particular.

Good news. If you have any problems or questions, especially related to OpenGL or some rendering techniques and you may think I can help, feel free to contact me. I would be pleased to help your project.

Cool, check your private messages on this forum.