Example #1
0
void key(unsigned char key, int x, int y) {

    bool need_redisplay = true;

    switch (key) {
        case 27: /* Escape key */
            //continue_in_main_loop = false; // (**)
            glutLeaveMainLoop(); //Freeglut's sentence for stopping glut's main loop (*)
            break;
        case 'a':
            escena.step();
            break;
        case 's':
            automatico = !automatico;
            break;
        case '+':
            zoom(1.2);
            break;
        case '-':
            // Zoom out 0.9
            zoom(0.8);
            break;
        default:
            need_redisplay = false;
            break;
    }//switch

    if (need_redisplay)
        glutPostRedisplay();
}
Example #2
0
void tick(int value) {
    //cout << "TICK: " << value << endl;
    if (automatico) {
        escena.step();
        glutPostRedisplay();
    }
    glutTimerFunc(ms, tick, value + 1);
}
Example #3
0
//---------timer---------
void timer(int n)
{
	if (_modo_timer)
	{
		_escena.step();
		glutPostRedisplay();
	}

	glutTimerFunc(_delay, timer, 0);
}
Example #4
0
//----------key----------
void key(unsigned char key, int x, int y) {
 
  bool need_redisplay = true;

  switch (key) {
  case 27:  /* Escape key */
    //continue_in_main_loop = false; // (**)
	glutLeaveMainLoop (); //Freeglut's sentence for stopping glut's main loop (*)
    break;

  case 13:  /* ENTER key */
	_escena.step(); //Freeglut's sentence for stopping glut's main loop (*)
    break;

  case 'w' :
	_escena.trasladarVertical( (_escena.get_yTop() - _escena.get_yBot())/10);
    break ;

  case 's' :
    _escena.trasladarVertical( -(_escena.get_yTop() - _escena.get_yBot())/10);
    break ;
  case 'a' :
    _escena.trasladarHorizontal(-(_escena.get_xRight() - _escena.get_xLeft())/10 );
    break ;

  case 'd' :
    _escena.trasladarHorizontal((_escena.get_xRight() - _escena.get_xLeft())/10 );
    break ;

  case '-' :
	_escena.quitaPelota();
    break ;

  case '+' :
	_escena.nuevaPelota();
    break ;

  case '/' :
	_escena.zoomProgresivo(0.5, 1.5);
    break ;

  case '*' :
	_escena.zoomProgresivo(2.0, 1.5);
    break ;

  case 'z' :
	cout << "Introduzca el numero de columnas a embaldosar: " ;
	cin >> nCols;
    break ;

  case 't' :
	if(_modo_timer)
		_modo_timer = false;
	else
		_modo_timer = true;
    break ;

  case 'n' :
	  if(_escena._pintar_normales)
		_escena._pintar_normales = false;
	else
		_escena._pintar_normales = true;
    break ;

  case 'm' :
	  if(_escena._pintar_mascaras)
		_escena._pintar_mascaras = false;
	else
		_escena._pintar_mascaras = true;
    break ;

	case 'b' :
	  if(_escena._usar_mascaras)
		_escena._usar_mascaras = false;
	else
		_escena._usar_mascaras = true;
    break ;

  default:
    need_redisplay = false;
    break;

  }//switch

  if (need_redisplay)
    glutPostRedisplay();
}