Pure Offscreen Rendering

I want to use JOGL 2.x for a console/terminal based image manipulation program without any GUI/window. Unfortunately, I don’t find a way to create and opengl context easily.

I know there are pbuffers, but AFAIK these are platform dependent and not very flexible in the format (floating point formats only?). That is why I use a framebuffer object with a texture2D as color component. That works fine, but it seems I still need a window or pbuffer to create the GLContext. Currently, I use a 1x1 sized pbuffer to get an ‘offscreen’ opeengl context like this:


GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
caps.setDoubleBuffered(false);

GLCapabilitiesChooser capsChooser = new DefaultGLCapabilitiesChooser();
GLPbuffer pBuffer = GLDrawableFactory.getFactory(GLProfile.getDefault()).createGLPbuffer(caps, capsChooser, 1, 1, null);

GLContext context = pBuffer.getContext();
context.makeCurrent();

GL gl = context.getGL();

// my offscreen rendering code goes here

context.destroy();

Is this necessary or can I create an opengl context without a pbuffer (and window)?

A pbuffer is probably what you want, most platforms support them and they have plenty of available formats. The 1x1 pbuffer is something I do when multiple contexts need to be shared. For your case, though, since you’re depending on pbuffer support you might as well use pbuffers. More GPUs will support them than FBOs.

thanks for answering!

I hoped pure FBO rendering would be possible (like on the iPhone/Pod/Pad). Guess I stick stick to my 1x1 pbuffer, because I don’t like passing the PBuffer class into the ‘real’ code :slight_smile: