0

I have a program that has an OpenGL window to draw various things in it. At the same time, I am doing offscreen rendering to get image masks.

Each one of them has a separate OpenGL context that they draw to. The offscreen rendering is called regularly, say every second.

What happens is that the offscreen context does not "switch back" the default context to the GUI context, so I end up drawing things to the GUI from offscreen.

What's a way of telling OpenGL "use this other context from this moment on" ?

hakura
  • 399
  • 3
  • 15
  • Why don't use just use Framebuffer Objects for offscreen rendering. That liberates your from managing a PBuffer. Also (unlike PBuffers) the contents of a FBO are not subject to possible invalidation (with PBuffers you've to check for invalidation events and redraw PBuffer contents if that happens). – datenwolf Oct 19 '13 at 13:39
  • But I'd still need to switch contexes with FBO right? – hakura Oct 19 '13 at 16:30
  • No you don't. FBOs are part of the context they're created in. You need just one single context when using FBOs. That's one of the beautiful things about them. See https://github.com/datenwolf/codesamples/blob/master/samples/OpenGL/minimalfbo/minimalfbo.c for a minimal FBO sample. – datenwolf Oct 19 '13 at 17:07

1 Answers1

1

With GLX, you can use glXMakeCurrent, which has the signature:

Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx);
icktoofay
  • 126,289
  • 21
  • 250
  • 231