Beispiel #1
0
        public static int MakeProgram(string name, int vertShader, int fragShader)
        {
            int program = GL.CreateProgram();

            if (vertShader != 0)
            {
                GL.AttachShader(program, vertShader);
            }
            if (fragShader != 0)
            {
                GL.AttachShader(program, fragShader);
            }
            GL.LinkProgram(program);
            int status;

            GL.GetProgram(program, ProgramParameter.LinkStatus, out status);
            if (status == 0)
            {
                string info;
                GL.GetProgramInfoLog(program, out info);
                var ex = new FractronException("Program link failed.");
                ex.Data["name"] = name;
                ex.Data["info"] = info;
                throw ex;
            }
            return(program);
        }
Beispiel #2
0
        public static int MakeShader(string name, string src, ShaderType type)
        {
            int shader = GL.CreateShader(type);

            GL.ShaderSource(shader, src);
            GL.CompileShader(shader);
            int status;

            GL.GetShader(shader, ShaderParameter.CompileStatus, out status);
            if (status == 0)
            {
                string info;
                GL.GetShaderInfoLog(shader, out info);
                var ex = new FractronException("Shader compilation failed.");
                ex.Data["name"] = name;
                ex.Data["info"] = info;
                throw ex;
            }
            return(shader);
        }