offscreen rendering without a window

Hi! my question is if there is a way which allows me to create an opengl rendering context without the need of creating a window. It’s posible using FBO?

No, at minimum you can create a hidden window of whatever size. But a window is a-must-have.

thanks!

Actually, since OpenGL 3.0, you can:

http://www.opengl.org/registry/specs/ARB/glx_create_context.txt

“If both <draw> and <read> are None, […]; if the OpenGL version is 3.0 or greater, the context is made current without a default framebuffer. The meaning of this is defined in chapter 4 of the OpenGL 3.0 Specification. If <ctx> is NULL and <draw> and <read> are not None, BadMatch is generated.”

Basically, you just have to call that:

glXMakeContextCurrent(display,None,None,context);

and then you create an FBO that you attached to the DRAW_BUFFER_BINDING and another one (or the same one) to the
READ_BUFFER_BINDING and you are good to go.

Note that it seems to not be supported yet on Windows:

  1. Should there be a way to make a context current without binding
    it to a window system drawable at the same time?
RESOLVED: Yes, but only in OpenGL 3.0 and later. This results in a
context with an invalid default framebuffer, the meaning of which is
defined in the OpenGL 3.0 specification.
NOTE: Apparently on Windows, opengl32.dll makes use of the drawable
argument to identify the namespace of the driver, so we may not be
able to work around it.

Hi, I have tried different combinations, but basically am still getting BadMatch for the glXMakeContextCurrent() call. My question is if I have to use the call glXCreateContextAttribsARB() to get the context? Did anybody ever succeeded in rendering in a window-less setup?

You may have already checked this, but from the man page:

BadMatch is generated if draw and read are not compatible.

BadMatch is generated if:

  • draw and read cannot fit into frame buffer memory simultaneously.
  • draw or read is a GLXPixmap and ctx is a direct-rendering context.
  • draw or read is a GLXPixmap and ctx was previously bound to a GLXWindow or GLXPbuffer.
  • draw or read is a GLXWindow or GLXPbuffer and ctx was previously bound to a GLXPixmap.

And the Linux man page for glXMakeCurrent says:

BadMatch is generated if drawable was not created with the same X screen and visual as ctx. It is also generated if drawable is None and ctx is not NULL.

Haven’t actually tried the new API, but IIRC back from my X11 days, BadMatch frequently meant you didn’t have a colormap attached to the window (see this thread). Not quite your case because you’re trying to do this without a window. In general, look for things that aren’t set up compatibly.

Thanks. But in my case, the draw/read are both None. I am using GLX 1.4 and GL 3.0 and ARB_create_context is supported. Based on http://www.opengl.org/registry/specs/ARB/glx_create_context.txt, window-less context is supposed to be supported.