Esempio n. 1
0
void dumpPNG(const std::string &filename)
{
  #ifdef PNGOUT
    YImage image;
    image.resize(g_display_controller.getWindowWidth(), g_display_controller.getWindowHeight());

    glPixelStorei(GL_PACK_ALIGNMENT, 4);
    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
    glPixelStorei(GL_PACK_SKIP_ROWS, 0);
    glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
    glReadBuffer(GL_BACK);

    glFinish();
    glReadPixels(0, 0, g_display_controller.getWindowWidth(), g_display_controller.getWindowHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.data());
    image.flip();

    image.save(filename.c_str());
  #endif
}
Esempio n. 2
0
// TODO: Preallocate space for for the image, use a faster method to read the buffer
void dumpPNG( const std::string& filename )
{
    YImage image;
    image.resize(g_simulation_ensemble->getWindowWidth(), g_simulation_ensemble->getWindowHeight());
    
    glPixelStorei(GL_PACK_ALIGNMENT, 4);
    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
    glPixelStorei(GL_PACK_SKIP_ROWS, 0);
    glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
    glReadBuffer(GL_BACK);
    
    glFinish();
    glReadPixels(0, 0, g_simulation_ensemble->getWindowWidth(), g_simulation_ensemble->getWindowHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.data());
    image.flip();
    
    if( !image.save(filename.c_str()) )
    {
        std::cerr << outputmod::startred << "TDSmoke ERROR: " << outputmod::endred << "Failed to save png image " << filename << ". Exiting." << std::endl;
        exit(1);
    }
}
Esempio n. 3
0
IGL_INLINE boost::thread igl::render_to_png_async(
  const std::string png_file,
  const int width,
  const int height,
  const bool alpha,
  const bool fast)
{
  // Part that should serial
  YImage * img = new YImage();
  img->resize(width,height);
  glReadPixels(
    0,
    0,
    width,
    height,
    GL_RGBA,
    GL_UNSIGNED_BYTE,
    img->data());
  // Part that should be asynchronous  
  return boost::thread(render_to_png_async_helper,img,png_file,alpha,fast);
}