OpenGL rendering without DISPLAY


I am using OpenGL almost 10 years for scientific data visualization of many (millions) of triangles and it is operated in our C home made sources via

glBegin(…); glVertex3fv(…); glEnd();

All development is going on Linux, right now we are using Ubuntu.

Now I meet an interesting problem that I wish to ask you to help.

I would like to draw my object without opening X Window, and save the result in the PPM/JPG data. I used glReadPixels(…) to grab pictures, but it works only if I have X Window.

My program will work as http server and produce nice scientific pictures after http request, so, I need to do everything without opening X Window.

Please, advice em how to do it (if it is ever possible). A simple example of OpenGL initialization and dumping would be very appreciated.

Thank you


Maybe this will help:

Dear Martinsm,

thank you very much for your kind help. It works! Just normal mesa works ok, I cannot link glut functions from the demo/osmesa.c example, but I do not need them really.



Or, make a invisble GL window and then make a FBO for rendering.