Exemplo n.º 1
0
//----------resize----------
void resize(int newWidth, int newHeight){
	//Resize Viewport
	WIDTH= newWidth;
	HEIGHT= newHeight;
	GLdouble RatioViewPort= (float)WIDTH/(float)HEIGHT;
	glViewport ( xInit, yInit, WIDTH, HEIGHT ) ;
  
	//Resize Scene Visible Area 
	//Se actualiza el área visible de la escena
	//para que su ratio coincida con ratioViewPort
	GLdouble SVAWidth= _escena.get_xRight() - _escena.get_xLeft();
	GLdouble SVAHeight= _escena.get_yTop() - _escena.get_yBot();
	GLdouble SVARatio= SVAWidth/SVAHeight;
	if (SVARatio >= RatioViewPort) {
		// Increase SVAHeight
		GLdouble newHeight= SVAWidth/RatioViewPort;
		GLdouble yMiddle= ( _escena.get_yBot() + _escena.get_yTop() )/2.0;
		_escena.set_yTop( yMiddle + newHeight/2.0);
		_escena.set_yBot( yMiddle - newHeight/2.0);
		}
	else {
		//Increase SVAWidth
		GLdouble newWidth= SVAHeight*RatioViewPort;
		GLdouble xMiddle= ( _escena.get_xLeft() + _escena.get_xRight() )/2.0;
		_escena.set_xRight( xMiddle + newWidth/2.0);
		_escena.set_xLeft(  xMiddle - newWidth/2.0);
	}

	_escena.actualizarAVE(_escena.get_xLeft(), _escena.get_xRight(), _escena.get_yBot(), _escena.get_yTop());
}