offscreen rendering from any thread

Hi!

I’m porting a glue library (a simple 2d gfx library) to jogl. One thing which I need to implement is offscreen rendering. And since it’s a library used by other applications, I cannot put restraints on thread usage, so it should work from any thread (eg: application creates image, gets graphics context, renders to graphic context).

What should I use? I’m pretty new to open gl in general, but I’ve been googling a lot. So far I tried:

  • pbuffers - not supported by every platform (for example on my laptop with intel chip)
  • framebuffer objects - I still need an existing GL instance to be able to render to it.
  • rendering to AUX buffers - they are limited in number, limited in screen size, can render to it only during normal paint,etc
    And I had the threading issue with all of the solution. What should I try instead?

Thanks in advance!
/Pal Szasz

You do not want to use the AUX buffers, they are generally unavailable, or very slow and are now deprecated in the latest releases of OpenGL. Framebuffers are nice when you need to mix offscreen and onscreen rendering, but they fall down when only offscreen rendering is needed. Pbuffers are your best bet as far as support goes, it’s unfortunate that they’re unsupported by your intel chips, but I believe that fbos are even less available.

As far as threading goes, it’s not difficult to set up jogl so that a context is used on only 1 thread; it doesn’t have to be the AWT thread.

Thanks! I do have a mix of offscreen and onscreen rendering. I render a few textures offscreen, then render them onscreen. You said it’s pretty easy to use jogl with another thread. Do you have any example/pseudocode for that?