Пример #1
0
        public override void AddShader(int id, string code, Shader.ShaderTypes type)
        {
            ShaderType stype = ShaderType.VertexShader;

            if (type == Shader.ShaderTypes.Vertex)
            {
                stype = ShaderType.VertexShader;
            }
            else if (type == Shader.ShaderTypes.Fragment)
            {
                stype = ShaderType.FragmentShader;
            }
            else if (type == Shader.ShaderTypes.Geometry)
            {
                stype = ShaderType.GeometryShader;
            }
            else if (type == Shader.ShaderTypes.TessControl)
            {
                stype = ShaderType.TessControlShader;
            }
            else if (type == Shader.ShaderTypes.TessEval)
            {
                stype = ShaderType.TessEvaluationShader;
            }

            int shader = GL.CreateShader(stype);

            if (shader == 0)
            {
                throw new Exception("Error creating shader.\n\tShader type: " + type + "\n\tCode: " + code);
            }
            GL.ShaderSource(shader, code);
            GL.CompileShader(shader);
            GL.AttachShader(id, shader);
            int    status = -1;
            string info   = "";

            GL.GetShaderInfoLog(shader, out info);
            GL.GetShader(shader, ShaderParameter.CompileStatus, out status);
            if (status != 1)
            {
                Console.WriteLine("Shader compiler error!\nType: " + type.ToString() + "\n\n" /* + "Source code:\n" + code + "\n\n"*/ +
                                  info + "\n" + "Status Code: " + status.ToString());
            }
        }
Пример #2
0
 public abstract void AddShader(int id, string code, Shader.ShaderTypes type);