예제 #1
0
        /// <summary>
        /// Compile and link the pipeline component.
        /// If you specify varyings, you must set up a buffer, and a start action of Gl.BindBuffer(GL.TRANSFORM_FEEDBACK_BUFFER,bufid) AND BeingTransformFeedback.
        /// </summary>
        /// <param name="vertex">The code for this shader type, or null</param>
        /// <param name="tcs">The code for this shader type, or null</param>
        /// <param name="tes">The code for this shader type, or null</param>
        /// <param name="geo">The code for this shader type, or null</param>
        /// <param name="frag">The code for this shader type, or null</param>
        /// <param name="vertexconstvars">List of constant values to use. Set of {name,value} pairs</param>
        /// <param name="tcsconstvars">List of constant values to use. Set of {name,value} pairs</param>
        /// <param name="tesconstvars">List of constant values to use. Set of {name,value} pairs</param>
        /// <param name="geoconstvars">List of constant values to use. Set of {name,value} pairs</param>
        /// <param name="fragconstvars">List of constant values to use. Set of {name,value} pairs</param>
        /// <param name="varyings">List of varyings to report</param>
        /// <param name="varymode">How to write the varying to the buffer</param>
        /// <param name="saveable">True if want to save to binary</param>

        public void CompileLink(string vertex            = null, string tcs = null, string tes = null, string geo = null, string frag = null,
                                object[] vertexconstvars = null, object[] tcsconstvars          = null, object[] tesconstvars = null, object[] geoconstvars = null, object[] fragconstvars = null,
                                string[] varyings        = null, TransformFeedbackMode varymode = TransformFeedbackMode.InterleavedAttribs, bool saveable = false
                                )
        {
            Program = new GLProgram();

            string ret;

            if (vertex != null)
            {
                ret = Program.Compile(ShaderType.VertexShader, vertex, vertexconstvars);
                System.Diagnostics.Debug.Assert(ret == null, "Vertex Shader", ret);
            }

            if (tcs != null)
            {
                ret = Program.Compile(ShaderType.TessControlShader, tcs, tcsconstvars);
                System.Diagnostics.Debug.Assert(ret == null, "Tesselation Control Shader", ret);
            }

            if (tes != null)
            {
                ret = Program.Compile(ShaderType.TessEvaluationShader, tes, tesconstvars);
                System.Diagnostics.Debug.Assert(ret == null, "Tesselation Evaluation Shader", ret);
            }

            if (geo != null)
            {
                ret = Program.Compile(ShaderType.GeometryShader, geo, geoconstvars);
                System.Diagnostics.Debug.Assert(ret == null, "Geometry shader", ret);
            }

            if (frag != null)
            {
                ret = Program.Compile(ShaderType.FragmentShader, frag, fragconstvars);
                System.Diagnostics.Debug.Assert(ret == null, "Fragment Shader", ret);
            }


            ret = Program.Link(false, varyings, varymode, saveable);
            System.Diagnostics.Debug.Assert(ret == null, "Link", ret);

            GLStatics.Check();
        }
        /// <summary>
        /// Compile the compute program
        /// </summary>
        /// <param name="codelisting">The code</param>
        /// <param name="constvalues">List of constant values to use. Set of {name,value} pairs</param>
        /// <param name="saveable">True if want to save to binary</param>
        /// <param name="completeoutfile">If non null, output the post processed code listing to this file</param>

        public void CompileLink(string codelisting, object[] constvalues = null, bool saveable = false, string completeoutfile = null)
        {
            Program = new GLProgram();
            string ret = Program.Compile(ShaderType.ComputeShader, codelisting, constvalues, completeoutfile);

            System.Diagnostics.Debug.Assert(ret == null, "Compute Shader", ret);
            ret = Program.Link(wantbinary: saveable);
            System.Diagnostics.Debug.Assert(ret == null, "Link", ret);
            GLStatics.Check();
        }
        /// <summary>
        /// Compile and link the pipeline component.
        /// If you specify varyings, you must set up a buffer, and a start action of Gl.BindBuffer(GL.TRANSFORM_FEEDBACK_BUFFER,bufid) AND BeingTransformFeedback.
        /// </summary>
        /// <param name="shadertype">Shader type,Fragment, Vertex etc </param>
        /// <param name="codelisting">The code</param>
        /// <param name="constvalues">List of constant values to use. Set of {name,value} pairs</param>
        /// <param name="varyings">List of varyings to report</param>
        /// <param name="varymode">How to write the varying to the buffer</param>
        /// <param name="saveable">True if want to save to binary</param>
        /// <param name="auxname">For reporting purposes on error, name to give to shader </param>
        /// <param name="completeoutfile">If non null, output the post processed code listing to this file</param>
        protected void CompileLink(ShaderType shadertype, string codelisting,
                                   object[] constvalues = null, string[] varyings = null, TransformFeedbackMode varymode = TransformFeedbackMode.InterleavedAttribs,
                                   bool saveable        = false,
                                   string auxname       = "", string completeoutfile = null)
        {
            Program = new GLProgram();
            string ret = Program.Compile(shadertype, codelisting, constvalues, completeoutfile);

            System.Diagnostics.Debug.Assert(ret == null, auxname, ret);
            ret = Program.Link(separable: true, varyings, varymode, saveable);
            System.Diagnostics.Debug.Assert(ret == null, auxname, ret);
        }