Beispiel #1
0
static void
menu(int value)
{
    switch (value) {
    case 1:
        writetiff((char *)"gears.tif", (char *)"OpenGL-rendered gears", 0, 0, W, H, COMPRESSION_LZW);
        break;
    case 2:
        writetiff((char *)"gears.tif", (char *)"OpenGL-rendered gears", 0, 0, W, H, COMPRESSION_NONE);
        break;
    case 3:
        writetiff((char *)"gears.tif", (char *)"OpenGL-rendered gears", 0, 0, W, H, COMPRESSION_PACKBITS);
        break;
    }
}
Beispiel #2
0
//------------------------------------------------------------------------------
void display(void)
{
    glClear (GL_COLOR_BUFFER_BIT);
    glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);

    GLfloat LightAmbient[] =  { 0.4f, 0.4f, 0.4f, 1.0f};
    GLfloat LightDiffuse[] =  { 0.3f, 0.3f, 0.3f, 1.0f};
    GLfloat LightSpecular[] = { 0.4f, 0.4f, 0.4f, 1.0f};
    GLfloat LightPosition[] = { 5.0f, 5.0f, 5.0f, 1.0f};

    //glClearColor(0.0,0.0,0.0,0.0);
    glClearColor( 0.25, 0.25, 0.25, 0.0 );
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
    glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
    glEnable(GL_LIGHT0);
    glShadeModel(GL_SMOOTH);

    draw_spline( CUBIC_SPLINE_CATMULLROM );
    draw_spline( CUBIC_SPLINE_B );
    if( DRAW_ACTOR )
        draw_actor();

    glutSwapBuffers();

    if( GENERATE_MOVIE ) {
        std::string ssplinebasis;
        switch( SPLINE_BASIS ) {
        case CATMULL_ROM:
            ssplinebasis = "crom";
            break;
        case B_SPLINE:
        default:
            ssplinebasis = "bspl";
            break;
        }

        std::string srotfun;
        switch( ROTFUN ) {
        case ROTFUN_EULERANGLES:
            srotfun = "euler";
            break;
        case ROTFUN_QUATERNION:
        default:
            srotfun = "quat";
            break;
        }


        sprintf( filename, "%s_%s_%s_%.04d.tif",filetitle.c_str(), ssplinebasis.c_str(), srotfun.c_str(), frame_id );
        printf( "%s\n", filename );
        writetiff( filename, "movie", 0, 0, Width, Height, COMPRESSION_NONE );
    }

}
Beispiel #3
0
int main(int argc, char **argv) {
	unsigned short width, height;
	unsigned char wfactor;

	calc_window window;

	// Set defaults
	window.width = XRES;
	window.height = YRES;
	window.xmax = XMAX;
	window.xmin = XMIN;
	window.ymax = YMAX;
	window.ymin = YMIN;
	window.tstep = TSTEP;
	window.steps = TSTEP*STEPSS;
	window.tmax = TMAX;
	window.offset = 0;
	
	parse_opts(argc, argv, &window);

	printf("Producing image of %dx%d...\n\n", window.width, window.height);
	printf("View window:\n");
	printf("  x = [%f, %f]\n", window.xmin, window.xmax);
	printf("  y = [%f, %f]\n\n", window.ymin, window.ymax);

	char imagedata[window.width*window.height];

        if (window.xmin == -window.xmax) {
                wfactor = 2;
		printf("Image symmetric, only calculating half.\n");
		window.xmin = 0.;
		window.width = window.width/wfactor;
        } else {
                wfactor = 1;
        }
	
	double buffer[window.width*window.height];

	printf("Allocating memory... ");
	calc_params*** data;
	
	data = allocate_data(window.width, window.height);
	
	printf("done.\n");
		
	char basename[255];
	char tiffile[255];
	char bmpfile[255];
	char command[255];

	double t=0.;

	char endless;
	if (window.tmax < 0) {
		endless = 1;
		printf("\nStarted calculating until the end of time\n");
	} else {
		endless = 0;
		printf("\nStarted calculating until time is %f\n", window.tmax);
	}

	while (endless || t<window.tmax) {
		t = window.tstep*(window.offset+1);
		
		printf("\nFrame: %d Range: %f-%f\n", window.offset+1, window.tstep*window.offset, t);
		calc_image(buffer, data, &window);

		doubletochar(window.width * window.height, buffer, imagedata);
		
		if (wfactor == 2) duplicate_data(window.width*wfactor, window.height, imagedata);

		snprintf(basename, 255, "imgs/%.5d", window.offset);
		snprintf(tiffile, 255, "%s.tif", basename);
		snprintf(bmpfile, 255, "%s.bmp", basename);

		writetiff(tiffile, window.width*wfactor, window.height, imagedata);

#ifdef FINISH
		// This requires ImageMagick
		printf("Converting and scaling...\n");
		snprintf(command, 255, "convert -contrast -depth 24 -type truecolor -resize 50%% %s %s", tiffile, bmpfile);
		execute(command);

                snprintf(command, 255, "rm %s", tiffile);
		execute(command);
#endif
		window.offset++;
	}

	printf("\n%d frames written.\n", window.offset);
	printf("Done enough, dozing off for bed...\n");
							
			
	return EXIT_SUCCESS;
}