Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    Custom scene renderers

    To create a custom renderer, directly implement the ISceneRenderer or use a delegate through the DelegateSceneRenderer.

    Implement an ISceneRenderer

    The SceneRendererBase provides a default implementation of ISceneRenderer. It automatically binds the output defines on the renderer to the GraphicsDevice before calling the DrawCore method.

    [DataContract("MyCustomRenderer")]
    [Display("My Custom Renderer")]
    public sealed class MyCustomRenderer : SceneRendererBase
    {
        // Implements the DrawCore method
        protected override void DrawCore(RenderContext context, RenderDrawContext drawContext)
        {
            // Access to the graphics device
            var graphicsDevice = drawContext.GraphicsDevice;
            var commandList = drawContext.CommandList;
            // Clears the current render target
            commandList.Clear(commandList.RenderTargets[0], Color.CornflowerBlue);
            // [...] 
        }
    }
    

    Use a delegate

    To develop a renderer and attach it to a method directly, use DelegateSceneRenderer:

    var sceneRenderer = new DelegateSceneRenderer(
        (drawContext) =>
        {
            // Access to the graphics device
            var graphicsDevice = drawContext.GraphicsDevice;
            var commandList = drawContext.CommandList;
            // Clears the current render target
            commandList.Clear(commandList.RenderTargets[0], Color.CornflowerBlue);
            // [...] 
       });
    

    See also

    • Scene renderers
    • Debug renderers
    • Improve this Doc
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation