本文整理匯總了C#中SiliconStudio.Xenko.Rendering.RenderContext.PushTagAndRestore方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderContext.PushTagAndRestore方法的具體用法?C# RenderContext.PushTagAndRestore怎麽用?C# RenderContext.PushTagAndRestore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SiliconStudio.Xenko.Rendering.RenderContext
的用法示例。
在下文中一共展示了RenderContext.PushTagAndRestore方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Draw
/// <summary>
/// Draws this scene instance with the specified context and <see cref="RenderFrame"/>.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="toFrame">To frame.</param>
/// <param name="compositorOverride">The compositor overload. Set this value to by-pass the default compositor of a scene.</param>
/// <exception cref="System.ArgumentNullException">
/// context
/// or
/// toFrame
/// </exception>
public void Draw(RenderContext context, RenderFrame toFrame, ISceneGraphicsCompositor compositorOverride = null)
{
if (context == null) throw new ArgumentNullException("context");
if (toFrame == null) throw new ArgumentNullException("toFrame");
// If no scene, then we can return immediately
if (Scene == null)
{
return;
}
var graphicsDevice = context.GraphicsDevice;
bool hasGraphicsBegin = false;
// Update global time
var gameTime = context.Time;
context.GraphicsDevice.Parameters.Set(GlobalKeys.Time, (float)gameTime.Total.TotalSeconds);
context.GraphicsDevice.Parameters.Set(GlobalKeys.TimeStep, (float)gameTime.Elapsed.TotalSeconds);
try
{
graphicsDevice.Begin();
hasGraphicsBegin = true;
// Always clear the state of the GraphicsDevice to make sure a scene doesn't start with a wrong setup
graphicsDevice.ClearState();
// Draw the main scene using the current compositor (or the provided override)
var graphicsCompositor = compositorOverride ?? Scene.Settings.GraphicsCompositor;
if (graphicsCompositor != null)
{
// Push context (pop after using)
using (context.PushTagAndRestore(RenderFrame.Current, toFrame))
using (context.PushTagAndRestore(SceneGraphicsLayer.Master, toFrame))
using (context.PushTagAndRestore(Current, this))
using (context.PushTagAndRestore(CameraRendererMode.RendererTypesKey, RendererTypes))
{
graphicsCompositor.Draw(context);
}
}
}
catch (Exception ex)
{
Log.Error("An exception occurred while rendering", ex);
}
finally
{
if (hasGraphicsBegin)
{
graphicsDevice.End();
}
}
}
示例2: DrawCore
protected override void DrawCore(RenderContext context, RenderFrame output)
{
// Early exit if some properties are null
if (Mode == null)
{
return;
}
// Gets the current camera state from the slot
var camera = context.GetCameraFromSlot(Camera);
// Draw this camera.
using (context.PushTagAndRestore(Current, this))
using (context.PushTagAndRestore(CameraComponentRenderer.Current, camera))
{
// Run all pre-renderers
foreach (var renderer in PreRenderers)
{
renderer.Draw(context);
}
// Draw the scene based on its drawing mode (e.g. implementation forward or deferred... etc.)
Mode.Draw(context);
// Run all post-renderers
foreach (var renderer in PostRenderers)
{
renderer.Draw(context);
}
}
}
示例3: Collect
public override void Collect(RenderContext context)
{
base.Collect(context);
// Early exit if some properties are null
if (Mode == null)
{
return;
}
// Gets the current camera state from the slot
var camera = context.GetCameraFromSlot(Camera);
//TODO camera can be null but we still push it as null... review me please.
//TODO this is needed or if we have no camera we don't render anything e.g. UI only
// Draw this camera.
using (context.PushTagAndRestore(Current, this))
using (context.PushTagAndRestore(CameraComponentRendererExtensions.Current, camera))
{
Mode.Collect(context);
}
}