public void Initialize(Shader vertexShader, Shader fragmentShader)
        {
            if (!Initialized)
            {
                this.vertexShader   = vertexShader;
                this.fragmentShader = fragmentShader;

                if (!vertexShader.Initialized)
                {
                    vertexShader.Initialize();
                }

                if (!fragmentShader.Initialized)
                {
                    fragmentShader.Initialize();
                }

                Handle = GL.CreateProgram();

                GL.AttachShader(Handle, vertexShader.Handle);
                GL.AttachShader(Handle, fragmentShader.Handle);

                GL.LinkProgram(Handle);

                int status;
                GL.GetProgram(Handle, ProgramParameter.LinkStatus, out status);

                string info;
                GL.GetProgramInfoLog(Handle, out info);

                string message = string.IsNullOrEmpty(info) ? "Program linked succesfully"
                                                                                                                        : string.Format("Program link result:{0}{1}",
                                                                                                                                        Environment.NewLine, info);

                System.Diagnostics.Debug.WriteLine(message);

                if (status == 0)
                {
                    throw new GraphicsException(message);
                }

                Initialized = true;
            }
        }
Exemple #2
0
        public void Initialize(Shader vertexShader, Shader fragmentShader)
        {
            if (!Initialized)
            {
                this.vertexShader = vertexShader;
                this.fragmentShader = fragmentShader;

                if (!vertexShader.Initialized)
                {
                    vertexShader.Initialize();
                }

                if (!fragmentShader.Initialized)
                {
                    fragmentShader.Initialize();
                }

                Handle = GL.CreateProgram();

                GL.AttachShader(Handle, vertexShader.Handle);
                GL.AttachShader(Handle, fragmentShader.Handle);

                GL.LinkProgram(Handle);

                int status;
                GL.GetProgram(Handle, ProgramParameter.LinkStatus, out status);

                string info;
                GL.GetProgramInfoLog(Handle, out info);

                string message = string.IsNullOrEmpty(info) ? "Program linked succesfully"
                                                            : string.Format("Program link result:{0}{1}",
                                                                            Environment.NewLine, info);

                System.Diagnostics.Debug.WriteLine(message);

                if (status == 0)
                {
                    throw new GraphicsException(message);
                }

                Initialized = true;
            }
        }