Пример #1
0
        /// <summary>
        /// Link the program.
        /// 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="separable">Set to true to allow for pipeline shaders</param>
        /// <param name="varyings">List of varyings to report. See <href>https://www.khronos.org/opengl/wiki/Transform_Feedback</href> for details on how you can send varying to various binding indexes</param>
        /// <param name="varymode">How to write the varying to the buffer</param>
        /// <param name="wantbinary">Set to true to allow GetBinary to work</param>
        /// <returns></returns>

        public string Link(bool separable = false, string[] varyings = null, TransformFeedbackMode varymode = TransformFeedbackMode.InterleavedAttribs, bool wantbinary = false)            // link, seperable or not.  Disposes of shaders. null if okay
        {
            if (shaders.Count == 0)
            {
                return("No shaders attached");
            }

            foreach (GLShader s in shaders)
            {
                GL.AttachShader(Id, s.Id);
            }

            GL.ProgramParameter(Id, ProgramParameterName.ProgramSeparable, separable ? 1:0);

            if (varyings != null)
            {
                GL.TransformFeedbackVaryings(Id, varyings.Length, varyings, varymode);      // this indicate varyings.
            }
            GL.ProgramParameter(Id, ProgramParameterName.ProgramBinaryRetrievableHint, wantbinary ? 1:0);

            GL.LinkProgram(Id);
            var info = GL.GetProgramInfoLog(Id);

            foreach (GLShader s in shaders)
            {
                GL.DetachShader(Id, s.Id);
                s.Dispose();
            }

            return(info.HasChars() ? info : null);
        }
Пример #2
0
 /// <summary>
 /// Specify values to record in transform feedback buffers.
 /// </summary>
 /// <remarks>
 /// Transform feedback varyings must be specified before linking the program. Either specify them in the constructor of the program
 /// or call <see cref="Program.Link"/> again after a call to this method.<br/>
 /// To specify the keywords introduced with advanced interleaving "gl_NextBuffer" and "gl_SkipComponents#"
 /// use the TransformOut dummy-instances <see cref="NextBuffer"/> and <see cref="SkipComponents1"/>, etc.
 /// </remarks>
 /// <param name="bufferMode">Identifies the mode used to capture the varying variables when transform feedback is active. bufferMode must be InterleavedAttribs or SeparateAttribs.</param>
 /// <param name="feedbackVaryings">An array of TransformOut objects specifying the varying variables to use for transform feedback.</param>
 public void FeedbackVaryings(TransformFeedbackMode bufferMode, params TransformOut[] feedbackVaryings)
 {
     //TODO: find out if the varyings buffer binding indices can be queried from OpenGL
     var index = 0;
     foreach (var output in feedbackVaryings)
     {
         if (bufferMode == TransformFeedbackMode.SeparateAttribs && SpecialOuts.Contains(output))
             throw new ObjectTKException("Advanced interleaving features can not be used with separate mode.");
         // set the outputs buffer binding index
         output.Index = index;
         // increase the index if all outputs get routed to a separate bindind or if the gl_NextBuffer keyword is found
         if (bufferMode == TransformFeedbackMode.SeparateAttribs || output == NextBuffer) index++;
     }
     GL.TransformFeedbackVaryings(Handle, feedbackVaryings.Length, feedbackVaryings.Select(_ => _.Name).ToArray(), bufferMode);
 }
Пример #3
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();
        }
Пример #4
0
        /// <summary>
        /// Specify values to record in transform feedback buffers.
        /// </summary>
        /// <remarks>
        /// Transform feedback varyings must be specified before linking the program. Either specify them in the constructor of the program
        /// or call <see cref="Program.Link"/> again after a call to this method.<br/>
        /// To specify the keywords introduced with advanced interleaving "gl_NextBuffer" and "gl_SkipComponents#"
        /// use the TransformOut dummy-instances <see cref="NextBuffer"/> and <see cref="SkipComponents1"/>, etc.
        /// </remarks>
        /// <param name="bufferMode">Identifies the mode used to capture the varying variables when transform feedback is active. bufferMode must be InterleavedAttribs or SeparateAttribs.</param>
        /// <param name="feedbackVaryings">An array of TransformOut objects specifying the varying variables to use for transform feedback.</param>
        public void FeedbackVaryings(TransformFeedbackMode bufferMode, params TransformOut[] feedbackVaryings)
        {
            //TODO: find out if the varyings buffer binding indices can be queried from OpenGL
            var index = 0;

            foreach (var output in feedbackVaryings)
            {
                if (bufferMode == TransformFeedbackMode.SeparateAttribs && SpecialOuts.Contains(output))
                {
                    throw new ObjectTKException("Advanced interleaving features can not be used with separate mode.");
                }
                // set the outputs buffer binding index
                output.Index = index;
                // increase the index if all outputs get routed to a separate bindind or if the gl_NextBuffer keyword is found
                if (bufferMode == TransformFeedbackMode.SeparateAttribs || output == NextBuffer)
                {
                    index++;
                }
            }
            GL.TransformFeedbackVaryings(Handle, feedbackVaryings.Length, feedbackVaryings.Select(_ => _.Name).ToArray(), bufferMode);
        }
Пример #5
0
 public void TransformFeedbackVaryings(TransformFeedbackMode mode, params string[] varyings)
 {
     GL.TransformFeedbackVaryings(ID, varyings.Length, varyings, mode);
 }
        /// <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);
        }
 /// <summary>
 ///  Constructor
 /// </summary>
 /// <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 GLPLVertexShaderColorModelObjectTranslation(string[] varyings = null, TransformFeedbackMode varymode = TransformFeedbackMode.InterleavedAttribs, bool saveable = false)
 {
     CompileLink(ShaderType.VertexShader, Code(), null, varyings, varymode, auxname: GetType().Name, saveable: saveable);
 }
Пример #8
0
 public void TransformFeedbackVaryings(string strvaryings, uint count, TransformFeedbackMode mode = TransformFeedbackMode.InterleavedAttribs)
 {
 }
Пример #9
0
 /// <summary>
 /// Transform feedback varyings.
 /// </summary>
 /// <param name="mode">Mode.</param>
 /// <param name="varyings">Varyings.</param>
 public void TransformFeedbackVaryings(TransformFeedbackMode mode, params string[] varyings)
 {
     GL.TransformFeedbackVaryings(ProgramId, varyings.Length, varyings, mode);
 }