/// <summary> /// Render the clipping region of the provided <see cref="UIElement"/>. /// </summary> /// <param name="element">The element to render.</param> /// <param name="context">The rendering context containing information how to draw the element.</param> /// <remarks>The render target, the depth stencil buffer and the depth stencil state are already correctly set when entering this function. /// If the user wants to perform some intermediate rendering, it is his responsibility to bind them back correctly before the final rendering.</remarks> public virtual void RenderClipping(UIElement element, UIRenderingContext context, UIBatch Batch) { // Default implementation: render an back-face cube Batch.DrawBackground(ref element.WorldMatrixInternal, ref element.RenderSizeInternal, ref blackColor, context.DepthBias); // increase the context depth bias for next elements. context.DepthBias += 1; }
/// <summary> /// Render the provided <see cref="UIElement"/>. /// </summary> /// <param name="element">The element to render.</param> /// <param name="context">The rendering context containing information how to draw the element.</param> /// <remarks>The render target, the depth stencil buffer and the depth stencil state are already correctly set when entering this function. /// If the user wants to perform some intermediate rendering, it is his responsibility to bind them back correctly before the final rendering.</remarks> public virtual void RenderColor(UIElement element, UIRenderingContext context, UIBatch Batch) { var backgroundColor = element.RenderOpacity * element.BackgroundColor; // pass the 3D matrix onto the element for picking element.WorldMatrix3D = context.IsFullscreen ? (Matrix?)null : context.WorldMatrix3D; // optimization: don't draw the background if transparent if (backgroundColor.A == (byte)0) { return; } // Default implementation: render an back-face cube with background color Batch.DrawBackground(ref element.WorldMatrixInternal, ref element.RenderSizeInternal, ref backgroundColor, context.DepthBias); // increase depth bias value so that next elements renders on top of it. context.DepthBias += 1; }