rendered paste bodyvoid write_ppm(int ScreenHeight, int ScreenWidth)
{
//glPixelStorei(GL_PACK_ALIGNMENT, 1);
FILE *fp;
fp = fopen("out.ppm","w");
int height = ScreenHeight;
int width = ScreenWidth;
int max_ccv = 255;
GLubyte* scrImage = new GLubyte[600*600*3];
glReadPixels(0,0,ScreenWidth, ScreenHeight, GL_RGB, GL_UNSIGNED_BYTE, scrImage);
fprintf(fp, "P3 %d %d %d\n", width, height, max_ccv);
for (int j = ScreenWidth-1; j >= 0; j--)
for (int i=0; i < ScreenHeight; i++)
fprintf(fp, "%d\n%d\n%d\n", scrImage[3*j*width+3*i+0], scrImage[3*j*width+3*i+1], scrImage[3*j*width+3*i+2]);
fclose(fp);
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}