Requirements for rendering offscreen

In my setup, I do not wish to use SDL for any display window. I will have an image buffer with a bitmap.
SDL will be used to render on top of it, and then my app will take the rendered buffer for further processing.
So SDL is being used in a pipeline.
I have this prior thread for reference - Offscreen rendering

It can be done, but how ?
I assume a build step is to build glew with

| GLEW_OSMESA | Build in off-screen Mesa mode. |

Then what ? An example will be fantastic.