Skip to content
Snippets Groups Projects
Select Git revision
  • ffdc7c08d4a4597191e2f2c190d4d2208ad750a3
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

gl2ppm.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    gl2ppm.cpp 1001 B
    
    #include "Gmsh.h"
    #include "GmshUI.h"
    
    void create_ppm(FILE *outfile, int width, int height){
      unsigned char *red, *green, *blue;
      register int x, y;
      unsigned char   r, g, b;
    
      red = (unsigned char *)malloc(height*width*sizeof(unsigned char));
      green = (unsigned char *)malloc(height*width*sizeof(unsigned char));
      blue = (unsigned char *)malloc(height*width*sizeof(unsigned char));
    
      glReadPixels(0,0,width,height,GL_RED,GL_UNSIGNED_BYTE,red);
      glReadPixels(0,0,width,height,GL_GREEN,GL_UNSIGNED_BYTE,green);
      glReadPixels(0,0,width,height,GL_BLUE,GL_UNSIGNED_BYTE,blue);
    
      fprintf(outfile, "P6\n");
      fprintf(outfile, "%d %d\n", width, height);
      fprintf(outfile, "%d\n", 255);
    
      for ( y = height-1; y >= 0; y-- ){
        for ( x = 0; x < width; x++ ){
          r = red[y*width+x];
          g = green[y*width+x];
          b = blue[y*width+x];
          fwrite(&r, 1, 1, outfile);
          fwrite(&g, 1, 1, outfile);
          fwrite(&b, 1, 1, outfile);
        }
      }
    
      Free(red);
      Free(green);
      Free(blue);
    }