I have ubuntu machine, and a command line application written in OS X which renders something offscreen using FBOs. This is part of the code.
this->systemProvider->setupContext(); //be careful with this one. to add thingies to identify if a context is set up or not
this->systemProvider->useContext();
glewExperimental = GL_TRUE;
glewInit();
GLuint framebuffer, renderbuffer, depthRenderBuffer;
GLuint imageWidth = _viewPortWidth,
imageHeight = _viewPortHeight;
//Set up a FBO with one renderbuffer attachment
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, imageWidth, imageHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer);
//Now bind a depth buffer to the FBO
glGenRenderbuffers(1, &depthRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, _viewPortWidth, _viewPortHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer);
The "system provider" is a C++ wrapper around OS X's NSOpenGLContext, which is used just to create a rendering context and making it current, without associating it with a window. All the rendering happens in the FBOs.
I am trying to use the same approach for Linux (Ubuntu) using GLX, but I am having a hard time doing it, since I see that GLX requires a pixel buffer.
I am trying to follow this tutorial:
http://renderingpipeline.com/2012/05/windowless-opengl/
At the end it uses a pixel buffer to make the context current, which I hear is deprecated and we should abandon it in favour of Frame Buffer Objects, is that right (I may be wrong about this).
Does anyone have a better approach, or idea?