Example #1
0
        public IShader LoadVS(string path, Type constantsType = null)
        {
            using (var cr = ShaderBytecode.CompileFromFile(path, "main", "vs_5_0", DEBUG_FLAG)) {
                if (cr.Bytecode == null)
                {
                    throw new Exception(cr.Message);
                }

                var gpuShader = new D3D11.VertexShader(Graphics.Device, cr);

                var inputElements = new D3D11.InputElement[] {
                    new D3D11.InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                    new D3D11.InputElement("TEXCOORD", 0, Format.R32G32_Float, 16, 0)
                };

                var inputSignature = ShaderSignature.GetInputSignature(cr);
                var inputLayout    = new D3D11.InputLayout(Graphics.Device, inputSignature, inputElements);

                var shader = new SharpDXShader(Graphics, gpuShader, inputLayout, constantsType);

                m_Shaders.Add(shader);

                return(shader);
            }
        }
Example #2
0
        private void InitShaders()
        {
            m_ShaderMgr = new SharpDXShaderMgr(this);

            m_DefaultPixelShader  = (SharpDXShader)ShaderMgr.LoadPS("Content/Shaders/Default.ps.hlsl");
            m_DefaultVertexShader = (SharpDXShader)ShaderMgr.LoadVS("Content/Shaders/Default.vs.hlsl");

            PixelShader  = m_DefaultPixelShader;
            VertexShader = m_DefaultVertexShader;
        }
Example #3
0
        public IShader LoadPS(string path, Type constantsType = null)
        {
            using (var cr = ShaderBytecode.CompileFromFile(path, "main", "ps_5_0", DEBUG_FLAG)) {
                if (cr.Bytecode == null)
                {
                    throw new Exception(cr.Message);
                }

                var gpuShader = new D3D11.PixelShader(Graphics.Device, cr);

                var shader = new SharpDXShader(Graphics, gpuShader, null, constantsType);

                m_Shaders.Add(shader);

                return(shader);
            }
        }