Ejemplo 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>();
                glUniform1iv         = OpenGL.GetDelegateFor <OpenGL.glUniform1iv>();
                glUniform2iv         = OpenGL.GetDelegateFor <OpenGL.glUniform2iv>();
                glUniform3iv         = OpenGL.GetDelegateFor <OpenGL.glUniform3iv>();
                glUniform4iv         = OpenGL.GetDelegateFor <OpenGL.glUniform4iv>();
                glUniform1f          = OpenGL.GetDelegateFor <OpenGL.glUniform1f>();
                glUniform2f          = OpenGL.GetDelegateFor <OpenGL.glUniform2f>();
                glUniform3f          = OpenGL.GetDelegateFor <OpenGL.glUniform3f>();
                glUniform4f          = OpenGL.GetDelegateFor <OpenGL.glUniform4f>();
                glUniform1fv         = OpenGL.GetDelegateFor <OpenGL.glUniform1fv>();
                glUniform2fv         = OpenGL.GetDelegateFor <OpenGL.glUniform2fv>();
                glUniform3fv         = OpenGL.GetDelegateFor <OpenGL.glUniform3fv>();
                glUniform4fv         = OpenGL.GetDelegateFor <OpenGL.glUniform4fv>();
                glUniformMatrix2fv   = OpenGL.GetDelegateFor <OpenGL.glUniformMatrix2fv>();
                glUniformMatrix3fv   = OpenGL.GetDelegateFor <OpenGL.glUniformMatrix3fv>();
                glUniformMatrix4fv   = OpenGL.GetDelegateFor <OpenGL.glUniformMatrix4fv>();
                glGetUniformLocation = OpenGL.GetDelegateFor <OpenGL.glGetUniformLocation>();
            }

            this.ShaderProgramObject = glCreateProgram();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="uniformName"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public int SetUniform(string uniformName, ivec3[] values)
        {
            int location = GetUniformLocation(uniformName);

            if (location >= 0)
            {
                if (glUniform3iv == null)
                {
                    glUniform3iv = OpenGL.GetDelegateFor <OpenGL.glUniform3iv>();
                }
                int count = values.Length;
                var value = new int[count * 3];
                int index = 0;
                for (int i = 0; i < value.Length; i++)
                {
                    value[index++] = values[i].x;
                    value[index++] = values[i].y;
                    value[index++] = values[i].z;
                }
                glUniform3iv(GetUniformLocation(uniformName), count, value);
            }
            return(location);
        }