Exemplo n.º 1
0
        private void DoCompileCommand(object parameter)
        {
            //  Clear the output.
            Output = string.Empty;

            //  Create a shader ref.
            List<SharpGL.SceneGraph.Shaders.Shader> shaders =
                new List<SharpGL.SceneGraph.Shaders.Shader>();
            
            //  Create the appropriate type.
            switch (ShaderType)
            {
                case ShaderType.FragmentShader:
                    {
                        var shader = new SharpGL.SceneGraph.Shaders.FragmentShader();
                        shader.CreateInContext(ApplicationState.Instance.OpenGL);
                        shader.SetSource(Source);
                        shaders.Add(shader);
                    }
                    break;
                case ShaderType.VertexShader:
                    {
                        var shader = new SharpGL.SceneGraph.Shaders.FragmentShader();
                        shader.CreateInContext(ApplicationState.Instance.OpenGL);
                        shader.SetSource(Source);
                        shaders.Add(shader);
                    }
                    break;
                case ShaderType.Shader:
                    {
                        //  Use the shader program to load the shader.
                        var program = new SharpGL.SceneGraph.Shaders.ShaderProgram();
                        program.CreateInContext(ApplicationState.Instance.OpenGL);
                        program.SetFullShaderSource(Source);

                        //  Add the attached shaders.
                        foreach (var shader in program.AttachedShaders)
                            shaders.Add(shader);
                    }
                    break;
                default:
                    throw new ArgumentException("Unknown shader type.");
            }

            //  Go through each shader.
            foreach (var shader in shaders)
            {
                CompilerOutput("Preparing to compile " + Name + " as " + ShaderType.ToString());
                
                 //  Compile the shader.
                shader.Compile();

                //  Set the output.
                CompilerOutput(shader.InfoLog);

                //  Set the status.
                CompilerOutput(shader.CompileStatus == true ? 
                    shader.Name + " compiled Successfully." :
                    shader.Name + " failed to compile.");

                //  Free the shader.
                shader.DestroyInContext(ApplicationState.Instance.OpenGL);
            }
        }
Exemplo n.º 2
0
        private void DoCompileCommand(object parameter)
        {
            //  Clear the output.
            Output = string.Empty;

            //  Create a shader ref.
            List <SharpGL.SceneGraph.Shaders.Shader> shaders =
                new List <SharpGL.SceneGraph.Shaders.Shader>();

            //  Create the appropriate type.
            switch (ShaderType)
            {
            case ShaderType.FragmentShader:
            {
                var shader = new SharpGL.SceneGraph.Shaders.FragmentShader();
                shader.CreateInContext(ApplicationState.Instance.OpenGL);
                shader.SetSource(Source);
                shaders.Add(shader);
            }
            break;

            case ShaderType.VertexShader:
            {
                var shader = new SharpGL.SceneGraph.Shaders.FragmentShader();
                shader.CreateInContext(ApplicationState.Instance.OpenGL);
                shader.SetSource(Source);
                shaders.Add(shader);
            }
            break;

            case ShaderType.Shader:
            {
                //  Use the shader program to load the shader.
                var program = new SharpGL.SceneGraph.Shaders.ShaderProgram();
                program.CreateInContext(ApplicationState.Instance.OpenGL);
                program.SetFullShaderSource(Source);

                //  Add the attached shaders.
                foreach (var shader in program.AttachedShaders)
                {
                    shaders.Add(shader);
                }
            }
            break;

            default:
                throw new ArgumentException("Unknown shader type.");
            }

            //  Go through each shader.
            foreach (var shader in shaders)
            {
                CompilerOutput("Preparing to compile " + Name + " as " + ShaderType.ToString());

                //  Compile the shader.
                shader.Compile();

                //  Set the output.
                CompilerOutput(shader.InfoLog);

                //  Set the status.
                CompilerOutput(shader.CompileStatus == true ?
                               shader.Name + " compiled Successfully." :
                               shader.Name + " failed to compile.");

                //  Free the shader.
                shader.DestroyInContext(ApplicationState.Instance.OpenGL);
            }
        }