Example #1
0
//----------mouse----------
void mouse(int button, int state, int x, int y)
{
	//se transforma en funciĆ³n del nCols
	x = (x%(WIDTH/nCols))*nCols;
	y = (y%(HEIGHT/nCols))*nCols;

	bool need_redisplay = true;

	switch(button) {
	case GLUT_LEFT_BUTTON:
		printf(" LEFT ");
		if (state == GLUT_DOWN) {
			printf("DOWN\n");
			printf("PV (%d, %d) - AVE (%f, %f)\n", x, y, _escena.PVtoAVE_X(x), _escena.PVtoAVE_Y(y));
		}
		else if (state == GLUT_UP) {
			printf("UP\n");
			printf("PV (%d, %d) - AVE (%f, %f)\n", x, y, _escena.PVtoAVE_X(x), _escena.PVtoAVE_Y(y));
		}
		break;

	case GLUT_RIGHT_BUTTON:
		printf(" RIGHT ");
		if (state == GLUT_DOWN) {
			printf("DOWN\n");
			printf("PV (%d, %d) - AVE (%f, %f)\n", x, y, _escena.PVtoAVE_X(x), _escena.PVtoAVE_Y(y));
		}
		else  if (state == GLUT_UP) {
			printf("UP\n");
			printf("PV (%d, %d) - AVE (%f, %f)\n", x, y, _escena.PVtoAVE_X(x), _escena.PVtoAVE_Y(y));
		}
		break;

    default:
		need_redisplay = false;
		break;

  }//switch

  if (need_redisplay)
	glutPostRedisplay();

  fflush(stdout);              // Force output to stdout

}