private void Draw() { // begin the offscreen render pass var offscreenPassAction = PassAction.Clear(Rgba32F.Black); _offscreenRenderPass.Begin(ref offscreenPassAction); // describe the bindings for rendering a non-textured cube into the render target var offscreenResourceBindings = default(ResourceBindings); offscreenResourceBindings.VertexBuffer() = _vertexBuffer; offscreenResourceBindings.IndexBuffer = _indexBuffer; // apply the render pipeline and bindings for the offscreen render pass _offscreenRenderPass.ApplyPipeline(_offscreenPipeline); _offscreenRenderPass.ApplyBindings(ref offscreenResourceBindings); // apply the mvp matrix to the offscreen vertex shader _offscreenRenderPass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _modelViewProjectionMatrix); // draw the non-textured cube into the target of the offscreen render pass _offscreenRenderPass.DrawElements(36); // end the offscreen render pass _offscreenRenderPass.End(); // begin a frame buffer render pass Rgba32F clearColor = 0x0040FFFF; var frameBufferPass = BeginDefaultPass(clearColor); // describe the bindings for using the offscreen render target as the sampled texture var frameBufferResourceBindings = default(ResourceBindings); frameBufferResourceBindings.VertexBuffer() = _vertexBuffer; frameBufferResourceBindings.IndexBuffer = _indexBuffer; frameBufferResourceBindings.FragmentStageImage() = _renderTarget; // apply the render pipeline and bindings for the frame buffer render pass frameBufferPass.ApplyPipeline(_frameBufferPipeline); frameBufferPass.ApplyBindings(ref frameBufferResourceBindings); // apply the mvp matrix to the frame buffer vertex shader frameBufferPass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _modelViewProjectionMatrix); // draw the textured cube into the target of the frame buffer render pass frameBufferPass.DrawElements(36); // end the frame buffer render pass frameBufferPass.End(); }
/// <summary> /// Begins and returns the frame buffer <see cref="Pass" /> with the specified width, height, and /// <see cref="PassAction.Clear" /> as the action. /// </summary> /// <param name="clearColor">The color to clear the color attachments.</param> /// <returns>The frame buffer <see cref="Pass" />.</returns> public static Pass BeginDefaultPass(Rgba32F clearColor) { var passAction = PassAction.Clear(clearColor); return(BeginDefaultPass(ref passAction)); }