Esempio n. 1
0
        public ShaderProgram()
        {
            if (glCreateProgram == null)
            {
                glCreateProgram      = OpenGL.GetDelegateFor <OpenGL.glCreateProgram>();
                glAttachShader       = OpenGL.GetDelegateFor <OpenGL.glAttachShader>();
                glLinkProgram        = OpenGL.GetDelegateFor <OpenGL.glLinkProgram>();
                glDetachShader       = OpenGL.GetDelegateFor <OpenGL.glDetachShader>();
                glDeleteProgram      = OpenGL.GetDelegateFor <OpenGL.glDeleteProgram>();
                glGetAttribLocation  = OpenGL.GetDelegateFor <OpenGL.glGetAttribLocation>();
                glUseProgram         = OpenGL.GetDelegateFor <OpenGL.glUseProgram>();
                glGetProgramiv       = OpenGL.GetDelegateFor <OpenGL.glGetProgramiv>();
                glUniform1ui         = OpenGL.GetDelegateFor <OpenGL.glUniform1ui>();
                glUniform2ui         = OpenGL.GetDelegateFor <OpenGL.glUniform2ui>();
                glUniform3ui         = OpenGL.GetDelegateFor <OpenGL.glUniform3ui>();
                glUniform4ui         = OpenGL.GetDelegateFor <OpenGL.glUniform4ui>();
                glUniform1i          = OpenGL.GetDelegateFor <OpenGL.glUniform1i>();
                glUniform2i          = OpenGL.GetDelegateFor <OpenGL.glUniform2i>();
                glUniform3i          = OpenGL.GetDelegateFor <OpenGL.glUniform3i>();
                glUniform4i          = OpenGL.GetDelegateFor <OpenGL.glUniform4i>();
                glUniform1f          = OpenGL.GetDelegateFor <OpenGL.glUniform1f>();
                glUniform2f          = OpenGL.GetDelegateFor <OpenGL.glUniform2f>();
                glUniform3f          = OpenGL.GetDelegateFor <OpenGL.glUniform3f>();
                glUniform4f          = OpenGL.GetDelegateFor <OpenGL.glUniform4f>();
                glUniformMatrix2fv   = OpenGL.GetDelegateFor <OpenGL.glUniformMatrix2fv>();
                glUniformMatrix3fv   = OpenGL.GetDelegateFor <OpenGL.glUniformMatrix3fv>();
                glUniformMatrix4fv   = OpenGL.GetDelegateFor <OpenGL.glUniformMatrix4fv>();
                glGetUniformLocation = OpenGL.GetDelegateFor <OpenGL.glGetUniformLocation>();
            }

            this.ShaderProgramObject = glCreateProgram();
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        public ShaderProgram()
        {
            if (glCreateProgram == null)
            {
                glCreateProgram      = OpenGL.GetDelegateFor <OpenGL.glCreateProgram>();
                glAttachShader       = OpenGL.GetDelegateFor <OpenGL.glAttachShader>();
                glLinkProgram        = OpenGL.GetDelegateFor <OpenGL.glLinkProgram>();
                glDetachShader       = OpenGL.GetDelegateFor <OpenGL.glDetachShader>();
                glDeleteProgram      = OpenGL.GetDelegateFor <OpenGL.glDeleteProgram>();
                glGetAttribLocation  = OpenGL.GetDelegateFor <OpenGL.glGetAttribLocation>();
                glUseProgram         = OpenGL.GetDelegateFor <OpenGL.glUseProgram>();
                glGetProgramiv       = OpenGL.GetDelegateFor <OpenGL.glGetProgramiv>();
                glGetUniformLocation = OpenGL.GetDelegateFor <OpenGL.glGetUniformLocation>();
            }

            this.ShaderProgramObject = glCreateProgram();
        }
Esempio n. 3
0
        /// <summary>
        /// Initialize this shader program object.
        /// </summary>
        /// <param name="shaders"></param>
        public void Initialize(params Shader[] shaders)
        {
            //if (shaders.Length < 1) { throw new ArgumentException(); }

            if (glCreateProgram == null)
            {
                glCreateProgram      = OpenGL.GetDelegateFor <OpenGL.glCreateProgram>();
                glAttachShader       = OpenGL.GetDelegateFor <OpenGL.glAttachShader>();
                glLinkProgram        = OpenGL.GetDelegateFor <OpenGL.glLinkProgram>();
                glDetachShader       = OpenGL.GetDelegateFor <OpenGL.glDetachShader>();
                glDeleteProgram      = OpenGL.GetDelegateFor <OpenGL.glDeleteProgram>();
                glGetAttribLocation  = OpenGL.GetDelegateFor <OpenGL.glGetAttribLocation>();
                glUseProgram         = OpenGL.GetDelegateFor <OpenGL.glUseProgram>();
                glGetProgramiv       = OpenGL.GetDelegateFor <OpenGL.glGetProgramiv>();
                glGetUniformLocation = OpenGL.GetDelegateFor <OpenGL.glGetUniformLocation>();
            }

            uint programId = glCreateProgram();

            foreach (var item in shaders)
            {
                glAttachShader(programId, item.ShaderId);
            }

            glLinkProgram(programId);

            if (this.GetLinkStatus(programId) == false)
            {
                string log = this.GetInfoLog(programId);
                throw new Exception(
                          string.Format("Failed to compile shader with ID {0}: {1}",
                                        programId.ToString(), log));
            }

            foreach (var item in shaders)
            {
                glDetachShader(programId, item.ShaderId);
            }

            this.ProgramId = programId;
        }
Esempio n. 4
0
        /// <summary>
        /// Initialize this shader program object.
        /// </summary>
        /// <param name="shaders"></param>
        public void Initialize(params Shader[] shaders)
        {
            //if (shaders.Length < 1) { throw new ArgumentException(); }

            if (glCreateProgram == null)
            {
                glCreateProgram = OpenGL.GetDelegateFor<OpenGL.glCreateProgram>();
                glAttachShader = OpenGL.GetDelegateFor<OpenGL.glAttachShader>();
                glLinkProgram = OpenGL.GetDelegateFor<OpenGL.glLinkProgram>();
                glDetachShader = OpenGL.GetDelegateFor<OpenGL.glDetachShader>();
                glDeleteProgram = OpenGL.GetDelegateFor<OpenGL.glDeleteProgram>();
                glGetAttribLocation = OpenGL.GetDelegateFor<OpenGL.glGetAttribLocation>();
                glUseProgram = OpenGL.GetDelegateFor<OpenGL.glUseProgram>();
                glGetProgramiv = OpenGL.GetDelegateFor<OpenGL.glGetProgramiv>();
                glGetUniformLocation = OpenGL.GetDelegateFor<OpenGL.glGetUniformLocation>();
            }

            uint programId = glCreateProgram();

            foreach (Shader item in shaders)
            {
                glAttachShader(programId, item.ShaderId);
            }

            glLinkProgram(programId);

            if (this.GetLinkStatus(programId) == false)
            {
                string log = this.GetInfoLog(programId);
                throw new Exception(
                    string.Format("Failed to compile shader with ID {0}: {1}",
                        programId.ToString(), log));
            }

            foreach (Shader item in shaders)
            {
                glDetachShader(programId, item.ShaderId);
            }

            this.ProgramId = programId;
        }