save an opengl canvas (wxPython)

Mike C. Fletcher mcfletch at
Tue Dec 14 20:35:05 CET 2004

There's sample code in PyOpenGL and OpenGLContext for saving canvases to 
PNG or JPEG formats using PIL.  Saving to Postscript requires 
considerably more work (if you're implying saving as triangles, lines 
and the like).  There is a GPL library which lets you do this, and I 
have an old SWIG wrapper for it sitting around somewhere (I think, 
haven't touched it in years), but even then, it's fairly poor quality 
compared to capturing a bitmap image.

Anyway, the function for reading a buffer is glReadPixels:
see the end of that man page for pointers to Python sample code.

Good luck,

Zunbeltz Izaola wrote:

>I've a drawing made in an OpenGL canvas. I want to save it to a file
>(preferibly PostScript format). Somebody knows how to do it?
  Mike C. Fletcher
  Designer, VR Plumber, Coder

More information about the Python-list mailing list