aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Waller <p@pwaller.net>2013-10-21 06:22:11 -0700
committerPeter Waller <p@pwaller.net>2013-10-21 06:22:11 -0700
commitfd7f414b17bd1d2f6046353008f21e3a2650677a (patch)
treee0c7f421d0b797684680215d68f02db8929fbdc2
parentb09fa4f235d954f60e71e0fb21869ca80e719d53 (diff)
parentf88fb535a7e533bb4c36ddf2f54b5d51bdb6df14 (diff)
downloadgl-fd7f414b17bd1d2f6046353008f21e3a2650677a.tar.gz
Merge pull request #128 from Niriel/uniform_blocks
Added GetUniformBlockIndex and UniformBlockBinding.
-rw-r--r--program.go21
-rw-r--r--uniformblockindex.go7
2 files changed, 28 insertions, 0 deletions
diff --git a/program.go b/program.go
index 9fc7a3b..9dcef76 100644
--- a/program.go
+++ b/program.go
@@ -5,6 +5,9 @@
package gl
// #include "gl.h"
+// GLuint workaroundGlGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) {
+// return glGetUniformBlockIndex(program, uniformBlockName);
+// }
import "C"
import "unsafe"
@@ -128,6 +131,24 @@ func (program Program) GetUniformLocation(name string) UniformLocation {
return UniformLocation(C.glGetUniformLocation(C.GLuint(program), cname))
}
+func (program Program) GetUniformBlockIndex(name string) UniformBlockIndex {
+
+ cname := glString(name)
+ defer freeString(cname)
+
+ // Workaround bug in GLEW < 1.8 where glGetUniformBlockIndex expects
+ // a string of char instead of a string of GLchar. We could ask everybody
+ // to bump their version of GLEW, or we could add a bit of C code that
+ // will silently cast GLchar into char.
+
+ //return UniformBlockIndex(C.glGetUniformBlockIndex(C.GLuint(program), cname))
+ return UniformBlockIndex(C.workaroundGlGetUniformBlockIndex(C.GLuint(program), cname))
+}
+
+func (program Program) UniformBlockBinding(index UniformBlockIndex, binding uint) {
+ C.glUniformBlockBinding(C.GLuint(program), C.GLuint(index), C.GLuint(binding))
+}
+
func (program Program) GetAttribLocation(name string) AttribLocation {
cname := glString(name)
diff --git a/uniformblockindex.go b/uniformblockindex.go
new file mode 100644
index 0000000..7855b3f
--- /dev/null
+++ b/uniformblockindex.go
@@ -0,0 +1,7 @@
+// Copyright 2012 The go-gl Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package gl
+
+type UniformBlockIndex uint