本文整理汇总了C#中RenderHelper.GetViewPort方法的典型用法代码示例。如果您正苦于以下问题:C# RenderHelper.GetViewPort方法的具体用法?C# RenderHelper.GetViewPort怎么用?C# RenderHelper.GetViewPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderHelper
的用法示例。
在下文中一共展示了RenderHelper.GetViewPort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
protected override void Draw(GameTime gameTime, RenderHelper render)
{
if (drawBackground)
{
int w = render.GetViewPort().Width;
int h = render.GetViewPort().Height;
render.RenderTextureComplete(backT, Color.White, new Rectangle(0, 0, w, h), Matrix.Identity);
}
}
示例2: Draw
protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime, RenderHelper render)
{
render.Clear(Color.Black);
int w = render.GetViewPort().Width;
int h = render.GetViewPort().Height;
render.RenderTextComplete(texts[state], new Vector2(w / 2, h / 2), Color.DarkRed, Matrix.Identity, arenScript);
if (interval < maxInterval)
{
interval++;
}
else
{
ChangeState();
interval = 0;
}
}
示例3: Render
/// <summary>
/// Renders a list of models to the shadow map, and returns a surface
/// containing the shadow occlusion factor
/// </summary>
/// <param name="gameTime">The game time.</param>
/// <param name="render">The render.</param>
/// <param name="ginfo">The ginfo.</param>
/// <param name="light">The light for which the shadow is being calculated</param>
/// <param name="mainCamera">The camera viewing the scene containing the light</param>
/// <param name="world">The world.</param>
/// <param name="deferredGBuffer">The deferred G buffer.</param>
/// <returns>
/// The shadow occlusion texture
/// </returns>
internal RenderTarget2D Render(GameTime gameTime, RenderHelper render,GraphicInfo ginfo, DirectionalLightPE light,
ICamera mainCamera, IWorld world, IDeferredGBuffer deferredGBuffer)
{
vp = render.GetViewPort();
// Set our targets
render.PushRenderTarget(shadowMap);
render.Clear(Color.White,ClearOptions.Target, 1.0f, 0);
render.Clear(Color.Black, ClearOptions.DepthBuffer, 1.0f, 0);
// Get corners of the main camera's bounding frustum
Matrix cameraTransform, viewMatrix;
viewMatrix = mainCamera.View;
cameraTransform = Matrix.Invert(viewMatrix);
mainCamera.BoundingFrustum.GetCorners(frustumCornersWS);
Vector3.Transform(frustumCornersWS, ref viewMatrix, frustumCornersVS);
for (int i = 0; i < 4; i++)
farFrustumCornersVS[i] = frustumCornersVS[i + 4];
// Calculate the cascade splits. We calculate these so that each successive
// split is larger than the previous, giving the closest split the most amount
// of shadow detail.
float N = NumSplits;
float near = mainCamera.NearPlane, far = mainCamera.FarPlane;
splitDepths[0] = near;
splitDepths[NumSplits] = far;
for (int i = 1; i < splitDepths.Length - 1; i++)
splitDepths[i] = splitConstant * near * (float)Math.Pow(far / near, i / N) + (1.0f - splitConstant) * ((near + (i / N)) * (far - near));
// Render our scene geometry to each split of the cascade
for (int i = 0; i < NumSplits; i++)
{
float minZ = splitDepths[i];
float maxZ = splitDepths[i + 1];
CalculateFrustum(light, mainCamera, minZ, maxZ, out lightProjectionMatrices[i], out lightViewMatrices[i],out lightViewProjectionMatrices[i]);
RenderShadowMap(gameTime,render, i,world);
}
render.PopRenderTargetAsSingleRenderTarget2D();
render.SetViewPort(ginfo.Viewport);
RenderShadowOcclusion(render,mainCamera,light,deferredGBuffer);
return shadowOcclusion;
}