idTech4.Renderer.idRenderSystem.RenderViewToViewPort C# (CSharp) Method

RenderViewToViewPort() public method

Converts from SCREEN_WIDTH / SCREEN_HEIGHT coordinates to current cropped pixel coordinates
public RenderViewToViewPort ( idRenderView renderView ) : idScreenRect
renderView idRenderView
return idScreenRect
		public idScreenRect RenderViewToViewPort(idRenderView renderView)
		{
			idRectangle renderCrop = _renderCrops[_currentRenderCrop];

			float widthRatio = (float) renderCrop.Width / idE.VirtualScreenWidth;
			float heightRatio = (float) renderCrop.Height / idE.VirtualScreenHeight;

			idScreenRect viewPort = new idScreenRect();
			viewPort.X1 = (short) (renderCrop.X + renderView.X * widthRatio);
			viewPort.X2 = (short) ((renderCrop.X + idMath.Floor(renderView.X + renderView.Width) * widthRatio + 0.5f) - 1);
			viewPort.Y1 = (short) ((renderCrop.Y + renderCrop.Height) - idMath.Floor((renderView.Y + renderView.Height) * heightRatio + 0.5f));
			viewPort.Y2 = (short) ((renderCrop.Y + renderCrop.Height) - idMath.Floor(renderView.Y * heightRatio + 0.5f) - 1);

			return viewPort;
		}
		#endregion