Ejemplo n.º 1
0
        protected int CompileShaderSource(ShaderType t, string code)
        {
            int shaderId = Gl.CreateShader(t);

            Gl.ShaderSource(shaderId, code);
            Gl.CompileShader(shaderId);
            Gl.GetShader(shaderId, ShaderParameter.CompileStatus, out int success);
            if (success < 1)
            {
                string infoLog = null;
                Gl.GetShader(shaderId, ShaderParameter.InfoLogLength, out int loglen);
                if (loglen > 0)
                {
                    string log;
                    Gl.GetShaderInfoLog(shaderId, loglen, out _, out log);
                    infoLog = log;
                }
                throw new ShaderException(this, "Shader compilation failed. Type:" + t.ToString(), infoLog);
            }

            return(shaderId);
        }