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(); }
/// <summary> /// </summary> /// <param name="uniformName"></param> /// <param name="v0"></param> /// <param name="v1"></param> /// <param name="v2"></param> public int SetUniform(string uniformName, float v0, float v1, float v2) { int location = GetUniformLocation(uniformName); if (location >= 0) { if (glUniform3f == null) { glUniform3f = OpenGL.GetDelegateFor <OpenGL.glUniform3f>(); } glUniform3f(GetUniformLocation(uniformName), v0, v1, v2); } return(location); }