예제 #1
0
파일: TP4.cpp 프로젝트: rchicoria/CG_TP4
void display(void){
	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Apagar ]
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	if(colorAmbient[0]==0.5)
	    glClearColor(GRAY);
	else
	    glClearColor(NIGHT);
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Look at do observador ]
	GLfloat obsL [] = {raio*cos(angulo-PI/2)+obsP[0], 0 ,raio*sin(angulo-PI/2)+obsP[2]};
	GLfloat lookLant[] = {raio*cos(angLant-PI/2), hLant ,raio*sin(angLant-PI/2)};
	    
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Janela Visualizacao ]
	glViewport (0,0,200, 200);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Projeccao]
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
    glOrtho (-xC,xC,-yC,yC,-zC,zC);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Modelo+View(camera/observador) ]
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(0, 0.5, 0, 0,0,0, 0, 0, -1);
	
	showLight(lookLant);
	    //--------------------- Informacao
	glColor3f(0,0,0);
	int ctrlAmbiente=0;
	if(colorAmbient[0]==0.5)
	    ctrlAmbiente=1;
	else
	    ctrlAmbiente=0;
	sprintf(texto, "%d - Noite", ctrlAmbiente);
	desenhaTexto(texto,0.5,0,0.5);
	sprintf(texto, "%d - Tecto", ctrlLocal);
	desenhaTexto(texto,0.5,0,0.6);
	sprintf(texto, "%d - Foco", ctrlLant);
	desenhaTexto(texto,0.5,0,0.7);
	sprintf(texto, "%d - ColorM", ctrlMateriais);
	desenhaTexto(texto,0.5,0,0.8);
	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Objectos ]
	drawScene(MAP);
	glViewport (200,200,wScreen-200, hScreen-200);
	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Projeccao]
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
    gluPerspective(104, wScreen/hScreen, 0.01, zC*2);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Modelo+View(camera/observador) ]
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(obsP[0], obsP[1], obsP[2], obsL[0], obsL[1], obsL[2], 0, 1, 0);
	
	showLight(lookLant);
	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[ Objectos ]
	drawScene(PERSPECTIVE);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Actualizacao
	glutSwapBuffers();
}
예제 #2
0
파일: main.cpp 프로젝트: JoaoS/CG
void display(void)
{
	if (noite)
		glClearColor(GRAY1);
	else
		glClearColor(GRAY2);
	
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    if(end_game == 0)
	{
        //================================================================= Viewport1
        glViewport (0, hScreen/4, wScreen/4, hScreen/4);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho (-xC,xC, -xC,xC, -zC,zC);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();	
        gluLookAt( 0, 10,0, 0,0,0, 0, 0, -1);
	   //--------------------- Informacao
        sprintf(texto,"Nivel : %d",level+1);
        desenhaTexto(texto,-8,1,0,18);
        if(clock_active ==1)
        {    
            t2 = clock() - t1;
            sprintf(texto,"Tempo : %.2f",((float)t2)/CLOCKS_PER_SEC);
            desenhaTexto(texto,-8,1,4,12);
        }
        if(noite)
            strcpy(texto, "Noite : Activo\n");
        else
            strcpy(texto, "Noite : Inactivo\n");
        desenhaTexto(texto,-8,1,8,12);
        if(ligaLuz)
            strcpy(texto, "Luz tecto : Activo\n");
        else
            strcpy(texto, "Luz tecto : Inactivo\n");
        desenhaTexto(texto,-8,1,12,12);
        if(ligaFoco)
            strcpy(texto, "Luz foco : Activo\n");
        else
            strcpy(texto, "Luz foco : Inactivo\n");
        desenhaTexto(texto,-8,1,16,12);

	   //================================================================= Viewport2
	   glEnable(GL_LIGHTING);  
	   glViewport (wScreen/4, hScreen/4, 0.75*wScreen, 0.75*hScreen);
	   glMatrixMode(GL_PROJECTION);
	   glLoadIdentity();
	   gluPerspective(99.0, wScreen/hScreen, 0.1, 100.0);
	   glMatrixMode(GL_MODELVIEW);
	   glLoadIdentity();
	   gluLookAt(obsPini[0], obsPini[1], obsPini[2], obsPfin[0], obsPfin[1], obsPfin[2], 0, 1, 0);
	   /* desenha objectos */
	   iluminacao();
	   drawScene();
       glutSwapBuffers();
    }
    else
    {   
        glViewport (0, 0, wScreen, hScreen);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho (-xC,xC, -xC,xC, -zC,zC);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();   
        gluLookAt( 0, 10,0, 0,0,0, 0, 0, -1);
        strcpy(texto,"FIM");
        desenhaTexto(texto,0,0,-8,24);
        sprintf(texto,"Tempo Nivel 1 : %.2f",((float)level_time[0])/CLOCKS_PER_SEC);
        desenhaTexto(texto,-8,0,-4,24);
        sprintf(texto,"Tempo Nivel 2 : %.2f",((float)level_time[1])/CLOCKS_PER_SEC);
        desenhaTexto(texto,-8,0,0,24);
        sprintf(texto,"Tempo Nivel 3 : %.2f",((float)level_time[2])/CLOCKS_PER_SEC);
        desenhaTexto(texto,-8,0,4,24);
        strcpy(texto,"Pressione ESC para sair");
        desenhaTexto(texto,-4,0,8,24);
        glutSwapBuffers();
    }
}