Exemplo n.º 1
0
static void
AllDisplay(atlantisstruct * ap)
{
	int         i;

        clear_tank(ap);

	for (i = 0; i < ap->num_sharks; i++) {
		glPushMatrix();
		FishTransform(&(ap->sharks[i]));
		DrawShark(&(ap->sharks[i]), ap->wire);
		glPopMatrix();
	}

	glPushMatrix();
	FishTransform(&(ap->dolph));
	DrawDolphin(&(ap->dolph), ap->wire);
	glPopMatrix();

	glPushMatrix();
	FishTransform(&(ap->momWhale));
	DrawWhale(&(ap->momWhale), ap->wire);
	glPopMatrix();

	glPushMatrix();
	FishTransform(&(ap->babyWhale));
	glScalef(0.45, 0.45, 0.3);
	DrawWhale(&(ap->babyWhale), ap->wire);
	glPopMatrix();
}
Exemplo n.º 2
0
static void
Display( void )
{
    float ambient[] = {0.1, 0.1, 0.1, 1.0};
    float diffuse[] = {1.0, 1.0, 1.0, 1.0};
    float position[] = {0.0, 1.0, 0.0, 0.0};
    float mat_shininess[] = {90.0};
    float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
    float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
    float mat_ambient[] = {0.0, 0.1, 0.2, 1.0};
    float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
    float lmodel_localviewer[] = {0.0};

    int i;

#if 0
    /* stupid WireGL */
    glViewport (0, 0, 450*3, 170*3);
#endif

    glFrontFace(GL_CCW);


    glDepthFunc(GL_LEQUAL);

    glEnable(GL_DEPTH_TEST);

    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);

    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);

    glLightfv(GL_LIGHT0, GL_POSITION, position);

    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);

    glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);

    glEnable(GL_LIGHTING);

    glEnable(GL_LIGHT0);

    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);

    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);

    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);

    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);

    glClearColor(0.0, 0.5, 0.9, 0.0);

    glMatrixMode(GL_PROJECTION);

    glLoadIdentity();

    gluPerspective(40.0, 2.0, 10000.0, 400000.0);

    glMatrixMode(GL_MODELVIEW);

    glLoadIdentity();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    for (i = 0; i < NumSharks; i++) {
        glPushMatrix();
        FishTransform(&sharks[i]);
        DrawShark(&sharks[i]);
        glPopMatrix();
    }

    glPushMatrix();
    FishTransform(&dolph);
    DrawDolphin(&dolph);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&momWhale);
    DrawWhale(&momWhale);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&babyWhale);
    glScalef(0.45, 0.45, 0.3);
    DrawWhale(&babyWhale);
    glPopMatrix();

    if ( screenshot )
	save_frame( );
    screenshot = 0;

    glutSwapBuffers( );

    print_performance( );
}
Exemplo n.º 3
0
void
Display( void )
{
    float ambient[] = {0.1, 0.1, 0.1, 1.0};
    float diffuse[] = {1.0, 1.0, 1.0, 1.0};
    float position[] = {0.0, 1.0, 0.0, 0.0};
    float mat_shininess[] = {90.0};
    float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
    float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
    float mat_ambient[] = {0.0, 0.1, 0.2, 1.0};
    float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
    float lmodel_localviewer[] = {0.0};

    int i;

    glFrontFace(GL_CCW);

    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, position);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
    glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
    glClearColor(0.0, 0.5, 0.9, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();


    //gluPerspective(40.0, 2.0, 10000.0, 400000.0);

    GLfloat fov = 40.0;
    GLfloat aspect = 2.0;
    GLfloat near = 10000.0;
    GLfloat far = 400000.0;
    GLfloat range = near*tan(M_PI * (fov/2) / 180.0);

#if 0
	// standard view
    glFrustum(-range*aspect,range*aspect,-range,range,near,far);
#else
	// split view
    GLfloat Xstep = 2.0*range*aspect / (float)dimX;
	 GLfloat Ystep = 2.0*range / (float)dimY;
	 
    glFrustum(-range*aspect + Xidx*Xstep, -range*aspect + (Xidx+1)*Xstep,
	 		-range + Yidx*Ystep, -range + (Yidx+1)*Ystep, near, far);
#endif

    glMatrixMode(GL_MODELVIEW);

	glLoadIdentity();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  	for (i = 0; i < NUM_SHARKS; i++)
	{
		glPushMatrix();
		FishTransform(&sharks[i]);
		DrawShark(&sharks[i]);
		glPopMatrix();
	}

    glPushMatrix();
    FishTransform(&dolph);
    DrawDolphin(&dolph);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&momWhale);
    DrawWhale(&momWhale);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&babyWhale);
    glScalef(0.45, 0.45, 0.3);
    DrawWhale(&babyWhale);
    glPopMatrix();
    glFinish();


	if (winWidth > 0)	{
		glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, rgbBuffer);	
		MPI_Barrier(MPI_COMM_WORLD);
		sageInf.swapBuffer();
		rgbBuffer = (GLubyte *)sageInf.getBuffer();
		
		sageMessage msg;
		if (sageInf.checkMsg(msg, false) > 0) {
			 switch (msg.getCode()) {
				 case APP_QUIT : {
			 		sageInf.shutdown();
					int err;
					MPI_Abort(MPI_COMM_WORLD, err);
					// finalize
					MPI_Finalize();
					exit(0);
					break;
				}
			 }	
		}
	}

	glutSwapBuffers( );
}
Exemplo n.º 4
0
void
Display(void)
{
    int i;
    static double th[4] = {0.0, 0.0, 0.0, 0.0};
	static double t1 = 0.0, t2 = 0.0, t;
	char num_str[128];
    
    t1 = t2;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    for (i = 0; i < NUM_SHARKS; i++) {
        glPushMatrix();
        FishTransform(&sharks[i]);
        DrawShark(&sharks[i]);
        glPopMatrix();
    }

    glPushMatrix();
    FishTransform(&dolph);
    DrawDolphin(&dolph);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&momWhale);
    DrawWhale(&momWhale);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&babyWhale);
    glScalef(0.45, 0.45, 0.3);
    DrawWhale(&babyWhale);
    glPopMatrix();
    
    if(Timing)
    {
		t2 = mtime();
		t = t2 - t1;
		if(t > 0.0001) t = 1.0 / t;
		
		glDisable(GL_LIGHTING);
		//glDisable(GL_DEPTH_TEST);
		
		glColor3f(1.0, 0.0, 0.0);
		
		glMatrixMode (GL_PROJECTION);
		glPushMatrix();
		glLoadIdentity();
		glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
		
		glRasterPos2f(5.0, 5.0);
		
		switch(StrMode)
		{
			case GL_VENDOR:
				sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_VENDOR));
			break;
			case GL_RENDERER:
				sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_RENDERER));
			break;
			case GL_VERSION:
				sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_VERSION));
			break;
			case GL_EXTENSIONS:
				sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_EXTENSIONS));
			break;
		}
		
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
		
		glEnable(GL_LIGHTING);
		//glEnable(GL_DEPTH_TEST);
	}
	
    count++;

    glutSwapBuffers();
}