// <!-- Warning -->
        public static ShaderProgram MakeProgram(Shader vertex, Shader fragment)
        {
            var program = new ShaderProgram(vertex, fragment);
            var programHandle = program.GetHandle();

            GL.AttachShader(programHandle, vertex.GetHandle());
            GL.AttachShader(programHandle, fragment.GetHandle());
            GL.LinkProgram (programHandle);

            int link_ok = 0;
            GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out link_ok);

            int bufLength = 0;
            StringBuilder buf = new StringBuilder(8192);
            GL.GetProgramInfoLog(programHandle, buf.Capacity, out bufLength, buf);
            CheckGLError();

            if (link_ok != 0)
            {
                Console.Write("Attached and linked shaders.");
                if (bufLength > 0)
                    Console.Write(" Program Info Log: \n\n{0}", buf.ToString());
                Console.WriteLine();
            }
            else
            {
                string stream = "";
                stream = String.Format("Could not link shader program \n{0}", buf.ToString());
                throw new Exception(stream);
            }

            return program;
        }
Beispiel #2
0
 public static Shader Make_ShaderStr(string code, ShaderType type)
 {
     var shader = new Shader(type);
     SetCode(shader.GetHandle(), code);
     return shader;
 }
 public ShaderProgram(Shader vertex, Shader fragment)
 {
     _handle = GL.CreateProgram();
     _vertex = vertex;
     _fragment = fragment;
 }
Beispiel #4
0
 public static Shader Make_Shader(string path, ShaderType type)
 {
     var code = GetCode(path);
     var shader = new Shader(type);
     SetCode(shader.GetHandle(), code);
     return shader;
 }