Example #1
0
        public virtual void BeginDraw(Image image)
        {
            //begin draw and we need set the render target before we draw anything

            //reset device and set render target
            mDevice.Reset();
            mDevice.SetRenderTarget(image.GpuRenderTarget);

            //set blend state
            mDevice.SetBlendState(mBlendState);

            //set input layout ,vertex shader and primitive type
            mDevice.SetInputLayout(mInputLayout);
            mDevice.SetPixelShader(mPixelShader);
            mDevice.SetVertexShader(mVertexShader);
            mDevice.SetPrimitiveType(GpuPrimitiveType.TriangleList);

            //set view port
            mDevice.SetViewPort(new Rectanglef(0, 0, image.Size.Width, image.Size.Height));

            mDevice.SetSamplerState(mSamplerState, mSamplerStateSlot, GpuShaderType.All);

            //set the project matrix, need set null when we end draw
            mProject = Matrix4x4.CreateOrthographicOffCenter(
                0, image.Size.Width,
                0, image.Size.Height, 0, 1);
        }
Example #2
0
        public void BeginDraw(Image image, RenderMode mode)
        {
            //begin draw and we need set the render target before we draw anything
            Mode = mode;

            //reset device and set render target
            mDevice.Reset();
            mDevice.SetRenderTarget(image);

            //set blend and raster state and input layout
            mDevice.SetBlendState(mBlendState);
            mDevice.SetInputLayout(mInputLayout);
            mDevice.SetRasterizerState(mRasterizerState);

            //set vertex shader, pixel shader
            switch (Mode)
            {
            case RenderMode.Fill:
                mDevice.SetPixelShader(mFillBezierPixelShader);
                mDevice.SetVertexShader(mFillBezierVertexShader);
                break;

            case RenderMode.Draw:
                mDevice.SetPixelShader(mDrawBezierPixelShader);
                mDevice.SetVertexShader(mDrawBezierVertexShader);
                break;

            default: throw new Exception("Mode Not Supported.");
            }

            //set primitive type
            mDevice.SetPrimitiveType(GpuPrimitiveType.TriangleList);

            //set view port
            mDevice.SetViewPort(new Rectangle <float>(0, 0, image.Size.Width, image.Size.Height));

            //set the project matrix, need set null when we end draw
            mProjection = Matrix4x4.CreateOrthographicOffCenter(
                0, image.Size.Width,
                0, image.Size.Height, 0, 1);

            //set the canvas size
            mCanvasSize = image.Size;
        }
Example #3
0
        public void BeginDraw()
        {
            //reset graphics pipeline and set render target
            mDevice.Reset();
            mDevice.SetRenderTarget(mSwapChain.RenderTarget);
            mDevice.ClearRenderTarget(mSwapChain.RenderTarget, new Colorf(1, 1, 1, 1));

            //set graphics pipeline
            mDevice.SetBlendState(mBlendState);

            mDevice.SetInputLayout(mInputLayout);
            mDevice.SetVertexBuffer(mVertexBuffer);
            mDevice.SetIndexBuffer(mIndexBuffer);
            mDevice.SetPrimitiveType(GpuPrimitiveType.TriangleList);

            mDevice.SetVertexShader(mVertexShader);
            mDevice.SetPixelShader(mDrawPixelShader);

            mDevice.SetViewPort(new Rectanglef(0, 0, mSwapChain.Size.Width, mSwapChain.Size.Height));
        }