0

I want to take screenshot from OpenGL window and save it to image file of any type. DevIL method described here gives correct PNG. Replace ilSaveImage with ilSave and you can save image in different formats. SOIL method here gives flipped vertically image. Replacing code below

 vector< unsigned char > buf( w * h * 3 );

 glPixelStorei( GL_PACK_ALIGNMENT, 1 );
 glReadPixels( 0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, &buf[0] );

 int err = SOIL_save_image ("img.bmp", SOIL_SAVE_TYPE_BMP, w, h, 3, &buf[0]);

with only one line creates the correct image.

 int err = SOIL_save_screenshot("img.bmp",SOIL_SAVE_TYPE_BMP, 0, 0, w, h);

Q1: Is any more convenient alternatives using other libraries?

Q2: Which one is the best way? Comparison is appreciated e.g. performance\compatibility.

Community
  • 1
  • 1
mioe
  • 11
  • 3
  • What's the problem with using SOIL when it produces a correct result? Do you note an fps drop or something when taking a screenshot? Since SOIL is not maintained anymore (not a bad thing necessarily) you could try stb_image (the library SOIL is based on), which is a just a c header and a good portable solution. – trmag Apr 02 '15 at 13:55
  • @trmag: No problems at all. SOIL is a tiny library that provides TGA, BMP and DDS support. DevIL is much heavier, TGA, BMP and DDS supported as well but additionally you can save output to JPG, RAW, TIF and some other. No differences in perfomance between the two approaches found (building isolines for output takes a lot more time). I just want to know most common or let's say modern way for such routine. – mioe Apr 02 '15 at 19:21

0 Answers0