#include #include #define RGB 3 #define RGBA 4 MVid movie; MVid track; unsigned char *ibuffer; GLubyte *buffer; DMparams* mov_params; DMparams* img_params; /* prototypes */ void addMovieFrame(); void endMovie (); void createMovie (); /* This will render frames to "new-movie.mv" See below for format details. view with "mediaplayer" convert to another format with "mediaconvert" in configuration, need to add supplemental libraries: setenv SUPP_LIBS "$SUPP_LIBS -ldmedia -lmoviefile" */ void createMovie() { /* Create movie, then create an image track to place into the movie. After createMovie, we can add frames to the image track. */ buffer = (GLubyte *) malloc(win->width*win->height*RGBA); if ( dmParamsCreate( &mov_params ) != DM_SUCCESS ) { /* handle error */ } if ( mvSetMovieDefaults( mov_params, MV_FORMAT_SGI_3) != DM_SUCCESS ) { /* handle error */ } if ( mvCreateFile( "new-movie.mv", mov_params, NULL, &movie ) != DM_SUCCESS ) { /* handle error */ } if ( dmParamsCreate (&img_params) != DM_SUCCESS ) { /* handle error */ } /* Movie type: SGI version 3, 30 fps, MVC1 compression, about which the man pages say the following: MVC1: This is a good general-purpose compression scheme. It is a color cell compression technique that works well for video, but can cause fuzzy edges in high-contrast animation. Not exactly ideal, but it's all I can get working correctly at this point with the SGI Digital Media Library. Think we need a license to export Quicktime High Compression or Cinepak, Indeo AVI */ mvSetImageDefaults (img_params, win->width, win->height, MV_FORMAT_SGI_3); dmParamsSetEnum(img_params, DM_IMAGE_PACKING, DM_IMAGE_PACKING_XBGR ); dmParamsSetFloat(img_params, DM_IMAGE_RATE, 30.0); dmParamsSetString(img_params, DM_IMAGE_COMPRESSION, DM_IMAGE_MVC1); mvAddTrack(movie, DM_IMAGE, img_params, NULL, &track); } void endMovie () { mvClose( movie ); } void addMovieFrame () { /* read window contents (the window is RGBA) */ glFinish(); glReadPixels(0, 0, win->width, win->height, GL_ABGR_EXT, GL_UNSIGNED_BYTE, buffer); /* Add a frame to the current globally visible track */ mvAppendFrames(track, 1, dmImageFrameSize (img_params), buffer); mvWrite (movie); } void main (argc, **argv) { createMovie (); while (1) { /* ... code which renders a frame */ addMovieFrame (); } endMovie (); }