Offscreen rendering

Hi to all!
For my project I need to implement a offscreen rendering method, I’ve some OpenGL code and I want to rendering the result to an image without create and open a window.
I’ve tried Mesa3D Off-screen rendering, it’s works correctly, but without hardware acceleration, so the result is bad…
There are other solutions for this problem?

You have to create a window to get an OpenGL accelerated context. For offscreen rednering, just make the window invisible and use the framebuffer object extension.

Just create a dummy glut window & run your rendering method. One example I’ve found in the forums is here :

You can also look at pBuffers. I think it is exactly what you need.

You have one extension for windows here

And it is available with glx on Linux.

An information, to do this, I need to create a window (for example with GLUT) or isn’t necessary?

If I understand correctly and you are on linux, you don’t need to create a window. Please refer to the GLX documentation.

In reality I need a cross platform code, and at this moment I’m working on Windows. If the only (and simple) solution, is a hide GLUT window + FBO, I use this…

If you want cross-platform, a hidden GLUT window with FBO would work fine

Perfect, I take this solution! If I’ve problems, I post here.
Thanks to all!

pbuffers are exactly designed for offscreen rendering, it enables you to create a rendering context like a window but without drawing on the screen.

The problem is that on windows, you have to use thee WGL_EXT_pbuffer extension and on linux, you have to use glx to create a pbuffer.

The hidden glut window is the easiest way to do it since it is not platform specific unlike pbuffers

Yes, but pbuffers are also de-facto deprecated, after FBO has appeared. Also, FBO is much easier to use.

There was some discussion at the Siggraph BOF about allocating a context without a window in gl 3.0 as well. If you are being progressive about it, there will be an interface there in a few months. If not, I probably agree with Zengar, FBO is a lot easier to use than pbuffers. The only issue is if you need to share your results with other contexts.

Yes that’s correct. Now pbuffers would be useful just for creating a independant rendering context for a little program which don’t have access to window management, I think about plugins for example… until the interface Keith is talking about is released.

I’ve tried, but there is a problem with the FBO.
Only using the glGenRenderbuffersEXT() function, the application crash. For the extensions, I use glew library.

Did you check if GL_EXT_frame_buffer_object extension is supported by your hardware?

Yes, it’s supported, this is the response: (from glewinfo)

GL_EXT_framebuffer_object:                                     OK 
  glBindFramebufferEXT:                                        OK
  glBindRenderbufferEXT:                                       OK
  glCheckFramebufferStatusEXT:                                 OK
  glDeleteFramebuffersEXT:                                     OK
  glDeleteRenderbuffersEXT:                                    OK
  glFramebufferRenderbufferEXT:                                OK
  glFramebufferTexture1DEXT:                                   OK
  glFramebufferTexture2DEXT:                                   OK
  glFramebufferTexture3DEXT:                                   OK
  glGenFramebuffersEXT:                                        OK
  glGenRenderbuffersEXT:                                       OK
  glGenerateMipmapEXT:                                         OK
  glGetFramebufferAttachmentParameterivEXT:                    OK
  glGetRenderbufferParameterivEXT:                             OK
  glIsFramebufferEXT:                                          OK
  glIsRenderbufferEXT:                                         OK
  glRenderbufferStorageEXT:                                    OK

You did rember to call glewInit() after creating your context, right? If you didn’t, you’re trying to call an uninitialized function pointer.

:o :o :o mmmm… no… :o :o :o
Ok, it’s runs!

:smiley: We all do this error once!

There was some discussion at the Siggraph BOF about allocating a context without a window in gl 3.0 as well.

You can’t. Well, not really.

See, the Microsoft Win32 library requires that context creation take a HDC, which requires a HWND of some kind. It’s an issue that’s discussed in the ARB_context_create extension.

After creating the context, you can make it current without a HDC (if it is a 3.0 or greater context); that is the clue to the context that you don’t want a default framebuffer.