- GLubyte *buffer;
- bool result;
-
- buffer = (GLubyte *) malloc(win_width*win_height*RGBA);
-
- // read window contents from color buffer with glReadPixels
- glFinish();
- glReadPixels(0, 0, win_width, win_height,
- GL_RGBA, GL_UNSIGNED_BYTE, buffer);
- result = sg_glWritePPMFile( filename, buffer, win_width, win_height,
- GL_RGBA );
- free(buffer);
-
- return result;
+ osg::ref_ptr<osg::Image> img(new osg::Image);
+ img->readPixels(0,0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE);
+ return osgDB::writeImageFile(*img, filename);