home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!news.byu.edu!yvax.byu.edu!cunyvm!rohvm1!rs0thp
- Newsgroups: comp.unix.aix
- Subject: Screen Capture of GL window (gltoppm) Almost..
- Message-ID: <92227.144843RS0THP@rohvm1.rohmhaas.com>
- From: Dr. Thomas Pierce <RS0THP@rohvm1.rohmhaas.com>
- Date: Fri, 14 Aug 1992 14:48:43 EDT
- Organization: Rohm and Haas Company
- Lines: 61
-
-
- I earlier posted a request to capture the GL window generated by
- my molecular modeling codes. They use the sabine card and 24 bits
- graphics which is pretty to view, but a &^%$#( to try and save or plot.
-
- I'd like to get the window in a pnm type format and then to
- colorsposcript or IBM 24 xwd format. (Enhanced X?).
-
- I received a program (included) that does not work for me. Core dumps.
- Has anyone used this on IBM 3.2 (Fred are you out there?).
-
- Please help.
-
- #include <malloc.h>
- #include <stdio.h>
- #include <gl/gl.h>
- #include <gl/device.h>
-
- GLtoppm(char *fname)
- /* Read the active GL-window and write a ppm file */
- /* Fred Hucht 1992 */
- {
- Int16 *buf, R[256], G[256], B[256];
- Int32 dx, dy, dxdy, i;
- register Int32 ix, iy;
- FILE *tn;
-
- getsize (&dx, &dy);
- dxdy = dx*dy;
- buf = malloc(sizeof (Int16) * dxdy);
- readsource(SRC_AUTO);
- printf("Reading %d of %d Pixels.\n",rectread (0, 0, dx-1, dy-1, buf),dxdy);
- clear(); sleep(1); rectwrite (0, 0, dx-1, dy-1, buf); /* Little joke...
- Delete this line if you don't like it. */
-
- getmcolors(0,255,R,G,B); /* Load colormap. Change 255 to 2^24-1 for 24 Bit.
- */
- printf("Writing ppm-file '%s'\n",fname);
- tn = fopen(fname, "w+");
- fprintf(tn,"P6\n%d %d\n255\n",dx,dy); /* Write ppm-Header. */
- for (iy = dy-1; iy >= 0; iy--) for (ix = 0; ix < dx; ix++)
- {
- i = iy * dx + ix;
- putc( (char)R[buf[i]],tn); /* Write RGB bytes */
- putc( (char)G[buf[i]],tn);
- putc( (char)B[buf[i]],tn);
- }
- fclose(tn);
- free(buf);
- printf("Ready !!\n");
- }
-
- main(argc,argv)
- int
- argc;
-
- char
- **argv[];
- {
- GLtoppm(argv[1]);
- }
-