public void Destroy()
 {
     if (program != null)
     {
         program.Dispose();
         program = null;
     }
     foreach (var shaderInfo in shaders)
     {
         shaderInfo.Destroy();
     }
 }
Exemple #2
0
        public bool Setup()
        {
            bool okProgram = true;

            program = null;

            foreach (var shaderInfo in shaders)
            {
                if (!shaderInfo.Compile())
                {
                    okProgram = false;
                    break;
                }
            }

            if (okProgram)
            {
                // all shaders compiled ok, now we'll try to link them together..
                program = new GlProgram();
                foreach (var shaderInfo in shaders)
                {
                    if (!program.AttachShader(shaderInfo.shader))
                    {
                        Util.LogFormat("GLSL program attach error: {0}", program.Message);
                        okProgram = false;
                        break;
                    }
                }

                if (okProgram)
                {
                    okProgram = program.Link();
                    if (okProgram)
                    {
                        program.LogProgramInfo();
                    }
                    else
                    {
                        Util.LogFormat("GLSL program link error: {0}", program.Message);
                    }
                }
            }

            if (!okProgram)
            {
                Destroy();
            }

            return(okProgram);
        }
Exemple #3
0
 public GlProgramInfo(string _name, IEnumerable <GlShaderInfo> si = null)
 {
     name    = _name;
     program = null;
     shaders = (si == null) ? new List <GlShaderInfo>() : new List <GlShaderInfo>(si);
 }