I have a task to implement offscreen OpenGL renderer both for Window and Linux in C++.I have such a version already written in Java using LWJGL lib.There I used PBuffer object ,which under hood creates Pbuffers based on the used OS.First I thought to re-implement the full PBuffer creation logic just as it i done in native source of LWJGL.Then I read this post on StackOverflow.com where it is suggested using the standard context creation ,let’s say using GLFW (which is cross platform) but not to create the actual window.Is it the right way to go? What are pros and cons vs using Pbuffer in such a case?
Update:
I just want to emphasize that I use FBOs to render the frames so my problem here is not how to render in offscreen mode but how to create a context without window both in Windows and Linux OSs.
I’d highly recommend not to use PBuffers anymore but to use Frame Buffer Objects (FBOs) instead. FBOs offer much better performance as using them does not require a context switch and they have several other advantages.
LWJGL supports FBOs, but GLFW is “just” for cross-platform setup of OpenGL and not for rendering. For convenient cross-platform FBO usage I’d recommend to use a library like OGLplus on top of GLFW. See here for a render-to-texture example.