Beispiel #1
0
void main(int argc, char **argv)
{
    glutInit(&argc, argv);

/* need both double buffering and z buffer */

	/*AdvancedGraphGenerator adv(L"http://wvm054.dei.isep.ipp.pt/SocialLiteWS/SocialiteWS.svc/userdata?id=1&token=debug");
	adv.GetRemoteUserData();
	adv.GetGeneratedGraph();*/

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(640, 480);
    glutCreateWindow("OpenGL");
    glutReshapeFunc(myReshape);
    glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);
	glutSpecialFunc(Special);
	glutMouseFunc(mouse);
	glutTimerFunc(estado.delayMovimento, Timer, 0);

	myInit();

	imprime_ajuda();

    glutMainLoop();
}
void Key(unsigned char key, int x, int y)
{
	switch (key) {
		case 27:
			exit(1);
			break;
    case 'h' :
    case 'H' :
                imprime_ajuda();
            break;
    case 'l':
    case 'L':
        estado.localViewer=!estado.localViewer;
        break;
    case 'w':
    case 'W':
          glutSetWindow(estado.navigateSubwindow);
          glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
          glDisable(GL_TEXTURE_2D);
          glutSetWindow(estado.topSubwindow);
          glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
          glDisable(GL_TEXTURE_2D);
        break;
    case 's':
    case 'S':
          glutSetWindow(estado.navigateSubwindow);
          glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
          glDisable(GL_TEXTURE_2D);
          glutSetWindow(estado.topSubwindow);
          glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
          glDisable(GL_TEXTURE_2D);
        break;
	}

}
int main(int argc, char **argv)
{
  char str[]=" makefile MAKEFILE Makefile ";
  estado.doubleBuffer=1;

  glutInit(&argc, argv);
  glutInitWindowPosition(0, 0);
  glutInitWindowSize(640, 480);
  glutInitDisplayMode(((estado.doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE) | GLUT_RGB | GLUT_DEPTH);
  if (glutCreateWindow("Exemplo") == GL_FALSE)
    exit(1);

  Init();

  imprime_ajuda();

// Registar callbacks do GLUT
  
  // callbacks de janelas/desenho
  glutReshapeFunc(Reshape);
  glutDisplayFunc(Draw);

  // Callbacks de teclado
  glutKeyboardFunc(Key);
  glutKeyboardUpFunc(KeyUp);
  glutSpecialFunc(SpecialKey);
  glutSpecialUpFunc(SpecialKeyUp);

  // callbacks timer/idle
  glutTimerFunc(estado.delayMovimento, Timer, 0);
  
  // COMECAR...
  glutMainLoop();
  return 0;
}
Beispiel #4
0
void Key(unsigned char key, int x, int y)
{
	switch (key) {
	case 27:
		exit(1);
		// ... accoes sobre outras teclas ... 

	case 'h' :
	case 'H' :
		imprime_ajuda();
		break;
	case 'i' :
	case 'I' :
		inicia_jogo();
		break;
	case 'Q' : 
	case 'q' : estado.teclas.q=GL_TRUE;
		break; 
	case 'A' : 
	case 'a' : estado.teclas.a=GL_TRUE;
		break;
	//case 'P' : 
	//case 'p' : estado.teclas.p=GL_TRUE;
	//	break;
	//case 'L' : 
	//case 'l' : estado.teclas.l=GL_TRUE;
	//	break;
	case 'D' : 
	case 'd' : estado.debug=!estado.debug;
		if(estado.menuActivo || modelo.parado)
			glutPostRedisplay();
		printf("DEBUG is %s\n",(estado.debug)?"ON":"OFF");
		break;

	}

	if(estado.debug)
		printf("Carregou na tecla %c\n",key);

}
Beispiel #5
0
void main(int argc, char **argv)
{
	estado.doubleBuffer=GL_TRUE;

	glutInit(&argc, argv);
	glutInitWindowPosition(0, 0);
	glutInitWindowSize(LARGURA_CAMPO, ALTURA_CAMPO);
	glutInitDisplayMode(((estado.doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE) | GLUT_RGB);
	if (glutCreateWindow("Ping-Pong") == GL_FALSE)
		exit(1);

	Init();

	imprime_ajuda();

	// Registar callbacks do GLUT

	// callbacks de janelas/desenho
	glutReshapeFunc(Reshape);
	glutDisplayFunc(Draw);

	// Callbacks de teclado
	glutKeyboardFunc(Key);
	glutKeyboardUpFunc(KeyUp);
	glutSpecialFunc(SpecialKey);
	glutSpecialUpFunc(SpecialKeyUp);

	// callbacks timer/idle
	glutTimerFunc(estado.delayMovimento, Timer, 0);
	glutTimerFunc(estado.delayTeclas, TimerTeclas, 0);

	//Menus
	cria_menu();
	glutMenuStatusFunc(MenuStatus);

	// COMECAR...
	glutMainLoop();
}
Beispiel #6
0
int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitWindowPosition(10, 10);
	glutInitWindowSize(800+GAP*3, 400+GAP*2);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	if ((estado.mainWindow=glutCreateWindow("Labirinto")) == GL_FALSE)
		exit(1);

	imprime_ajuda();

	// Registar callbacks do GLUT da janela principal
	init();
	glutReshapeFunc(reshapeMainWindow);
	glutDisplayFunc(displayMainWindow);

	glutTimerFunc(estado.timer,Timer,0);
	glutKeyboardFunc(Key);
	glutKeyboardUpFunc(KeyUp);
	glutSpecialFunc(SpecialKey);
	glutSpecialUpFunc(SpecialKeyUp);

	// criar a sub window topSubwindow
	estado.topSubwindow=glutCreateSubWindow(estado.mainWindow, GAP, GAP, 400, 400);
	init();
	setLight();
	setMaterial();
	createTextures(modelo.texID[JANELA_TOP]);
	createDisplayLists(JANELA_TOP);

	mdlviewer_init("gordon.mdl", gordon.stdModel[JANELA_TOP] );

	for(int i=0;i<3;i++)
		mdlviewer_init("headcrab.mdl", headCrabs[i].stdModel[JANELA_TOP] );

	glutReshapeFunc(redisplayTopSubwindow);
	glutDisplayFunc(displayTopSubwindow);

	glutTimerFunc(estado.timer,Timer,0);
	glutKeyboardFunc(Key);
	glutSpecialFunc(SpecialKey);
	glutSpecialUpFunc(SpecialKeyUp);


	// criar a sub window navigateSubwindow
	estado.navigateSubwindow=glutCreateSubWindow(estado.mainWindow, 400+GAP, GAP, 400, 800);
	init();
	setLight();
	setMaterial();

	createTextures(modelo.texID[JANELA_NAVIGATE]);
	createDisplayLists(JANELA_NAVIGATE);
	mdlviewer_init("gordon.mdl", gordon.stdModel[JANELA_NAVIGATE] );

	for(int i=0;i<3;i++)
		mdlviewer_init("headcrab.mdl", headCrabs[i].stdModel[JANELA_NAVIGATE] );

	glutReshapeFunc(reshapeNavigateSubwindow);
	glutDisplayFunc(displayNavigateSubwindow);
	glutMouseFunc(mouseNavigateSubwindow);

	glutTimerFunc(estado.timer,Timer,0);
	glutKeyboardFunc(Key);
	glutSpecialFunc(SpecialKey);
	glutSpecialUpFunc(SpecialKeyUp);


	glutMainLoop();
	return 0;

}
Beispiel #7
0
void keyboard(unsigned char key, int x, int y)
{
	int retCode;
    switch (key)
    {
		case 27 :
				exit(0);
			break;
		case 'h':
		case 'H':
				imprime_ajuda();
			break;
		case 'l':
		case 'L':
				if(estado.lightViewer)
					estado.lightViewer=0;
				else
					estado.lightViewer=1;
				glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, estado.lightViewer);
				glutPostRedisplay();
			break;
		case 'k':
		case 'K':
				estado.light=!estado.light;
				glutPostRedisplay();
			break;
		case 'w':
		case 'W':
				glDisable(GL_LIGHTING);
				glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
				glutPostRedisplay();
			break;
		case 'p':
		case 'P':
				glDisable(GL_LIGHTING);
				glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
				glutPostRedisplay();
			break;
		case 's':
		case 'S':
				glEnable(GL_LIGHTING);
				glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
				glutPostRedisplay();
			break;
		case 'c':
		case 'C':
				if(glIsEnabled(GL_CULL_FACE))
					glDisable(GL_CULL_FACE);
				else
					glEnable(GL_CULL_FACE);
				glutPostRedisplay();
			break;    
		case 'n':
		case 'N':
				estado.apresentaNormais=!estado.apresentaNormais;
				glutPostRedisplay();
			break;    		
		case 'i':
		case 'I':
				initEstado();
				initModelo();
				glutPostRedisplay();
				break;
		case 'q':
		case 'Q':
			cout << key << endl;
			estado.camera.eyeVer[2] += 1;
			glutPostRedisplay();
			break;
		case 'a':
		case 'A':
			cout << key << endl;
			estado.camera.eyeVer[2] -= 1;
			glutPostRedisplay();
			break;
		case '1':
			retCode = system("Mini_Jogos\\Jogo_do_Galo\\TestJogoGalo.exe");
			if (retCode == 1)
			{
				MessageBox(NULL, _T("Ganhou o jogo do galo!"),
					_T("Resultado"), MB_OK | MB_ICONMASK);
			}
			else 
			{
				MessageBox(NULL, _T("Perdeu!"),
					_T("Resultado"), MB_OK | MB_ICONERROR);
			}
			break;
		case '2':
			retCode = system("Mini_Jogos\\Jogo_da_Forca\\Forca.exe");
			if (retCode == 1)
			{
				MessageBox(NULL, _T("Ganhou o jogo da forca!"),
					_T("Resultado"), MB_OK | MB_ICONMASK);
			}
			else
			{
				MessageBox(NULL, _T("Perdeu!"),
					_T("Resultado"), MB_OK | MB_ICONERROR);
			}
			break;
		case '3':
			retCode = system("Mini_Jogos\\Jogo_do_Labirinto\\Labirinto.exe");
			if (retCode == 1)
			{
				MessageBox(NULL, _T("Ganhou o jogo do labirinto!"),
					_T("Resultado"), MB_OK | MB_ICONMASK);
			}
			else
			{
				MessageBox(NULL, _T("Perdeu!"),
					_T("Resultado"), MB_OK | MB_ICONERROR);
			}
			break;
	}
}
void Key(unsigned char key, int x, int y)
{
  switch (key) {

    case 27:
      exit(1);
    // ... accoes sobre outras teclas ... 

    case 'h' :
    case 'H' :
                imprime_ajuda();
            break;
    case 'i' :
    case 'I' :
                inicia_modelo();
            break;
    case 'o' :
    case 'O' :
                estado.ortho=!estado.ortho;
                Reshape(glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));
            break;
    case 'Q' : 
    case 'q' : estado.teclas.q=GL_TRUE;
           break; 
    case 'A' : 
    case 'a' : estado.teclas.a=GL_TRUE;
           break;
    case 'Z' : 
    case 'z' : estado.teclas.z=GL_TRUE;
           break;
    case 'X' : 
    case 'x' : estado.teclas.x=GL_TRUE;
           break;
    case 'D' : 
    case 'd' : estado.debug=!estado.debug;
               if(estado.menuActivo || modelo.parado)
                 glutPostRedisplay();
               printf("DEBUG is %s\n",(estado.debug)?"ON":"OFF");
           break;
    case 'f' : 
    case 'F' : 
               glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
           break;
    case 'p' : 
    case 'P' : 
               glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
           break;
    case 'l' : 
    case 'L' : 
               glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
           break;

   /* case 's' : 
    case 'S' : 
               modelo.parado=!modelo.parado;
           break;*/


  }

  if(estado.debug)
    printf("Carregou na tecla %c\n",key);

}