예제 #1
0
        protected override void Draw(AppTime time)
        {
            // begin a frame buffer render pass
            Rgba32F clearColor = 0x8080FFFF;
            var     pass       = BeginDefaultPass(clearColor);

            // apply the render pipeline for the render pass
            pass.ApplyPipeline(_pipeline);

            // apply the bindings necessary to render the triangle for the render pass
            _resourceBindings.VertexBuffer() = _vertexBuffer;
            _resourceBindings.VertexBufferOffset() = 0;
            _resourceBindings.IndexBuffer       = _indexBuffer;
            _resourceBindings.IndexBufferOffset = 0;
            pass.ApplyBindings(ref _resourceBindings);

            // draw the triangle (3 triangle indices) into the target of the render pass
            pass.DrawElements(3);

            // set and apply the bindings necessary to render the quad for the render pass
            _resourceBindings.VertexBuffer()       = _vertexBuffer;
            _resourceBindings.VertexBufferOffset() = 3 * Marshal.SizeOf <Vertex>();
            _resourceBindings.IndexBuffer          = _indexBuffer;
            _resourceBindings.IndexBufferOffset    = 3 * Marshal.SizeOf <ushort>();
            pass.ApplyBindings(ref _resourceBindings);

            // draw the quad (6 triangle indices) into the target of the render pass
            pass.DrawElements(6);

            // end the frame buffer render pass
            pass.End();
        }
예제 #2
0
        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();
        }
예제 #3
0
 public Application()
 {
     // initially set the frame buffer clear color to red
     _clearColor = Rgba32F.Red;
 }
예제 #4
0
 /// <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 Pass BeginDefaultPass(Rgba32F clearColor)
 {
     return(App.BeginDefaultPass(clearColor));
 }
예제 #5
0
파일: App.cs 프로젝트: fossabot/Sokol.NET
        /// <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));
        }
예제 #6
0
 protected override void CreateResources()
 {
     // initially set the frame buffer clear color to red
     _clearColor = Rgba32F.Red;
 }