示例#1
0
        internal static int LinkShaders(IGLGraphicsPipelineEntrypoint entrypoint, IGLErrorHandler errHandler, int[] shaders)
        {
            int retVal = entrypoint.CreateProgram();

            foreach (var shader in shaders)
            {
                entrypoint.AttachShaderToProgram(retVal, shader);
                //GL.AttachShader (retVal, shader);
            }
            entrypoint.CompileProgram(retVal);

            bool isCompiled = entrypoint.IsCompiled(retVal);
            //int linkStatus = 0;
            //GL.GetProgram(retVal,GetProgramParameterName.LinkStatus, out linkStatus);
            // return (linkStatus == (int)All.True)

            //int glinfoLogLength = 0;
            //GL.GetProgram(retVal, GetProgramParameterName.InfoLogLength, out glinfoLogLength);
            // return (glinfoLogLength > 1)

            bool hasMessages = entrypoint.HasCompilerMessages(retVal);

            if (hasMessages)
            {
                string buffer = entrypoint.GetCompilerMessages(retVal);

                // GL.GetProgramInfoLog(retVal);
                if (!isCompiled)
                {
                    errHandler.Trace("Shader Linking failed with the following errors:");
                }
                else
                {
                    errHandler.Trace("Shader Linking succeeded, with following warnings/messages:\n");
                }

                errHandler.Trace(buffer);
            }

            if (!isCompiled)
            {
                //		        #ifndef POSIX
                //		            assert(!"Shader failed linking, here's an assert to break you in the debugger.");
                //		        #endif
                entrypoint.DeleteProgram(retVal);
                retVal = 0;
            }

            return(retVal);
        }
示例#2
0
        internal int LinkShaders(params int[] shaders)
        {
            int retVal = mEntrypoint.CreateProgram();

            foreach (var shader in shaders)
            {
                mEntrypoint.AttachShaderToProgram(retVal, shader);
                //GL.AttachShader (retVal, shader);
            }
            mEntrypoint.CompileProgram(retVal);

            bool isLinked = mEntrypoint.IsCompiled(retVal);
            //int linkStatus = 0;
            //GL.GetProgram(retVal,GetProgramParameterName.LinkStatus, out linkStatus);
            // return (linkStatus == (int)All.True)

            //int glinfoLogLength = 0;
            //GL.GetProgram(retVal, GetProgramParameterName.InfoLogLength, out glinfoLogLength);
            // return (glinfoLogLength > 1)

            bool hasMessages = mEntrypoint.HasCompilerMessages(retVal);

            if (hasMessages)
            {
                string buffer = GL.GetProgramInfoLog(retVal);
                if (!isLinked)
                {
                    Console.WriteLine("Shader Linking failed with the following errors:");
                }
                else
                {
                    Console.WriteLine("Shader Linking succeeded, with following warnings/messages:\n");
                }

                Console.WriteLine(buffer);
            }

            if (!isLinked)
            {
                //		        #ifndef POSIX
                //		            assert(!"Shader failed linking, here's an assert to break you in the debugger.");
                //		        #endif
                mEntrypoint.DeleteProgram(retVal);
                retVal = 0;
            }

            return(retVal);
        }