diff options
author | Peter Waller <p@pwaller.net> | 2013-10-21 06:22:11 -0700 |
---|---|---|
committer | Peter Waller <p@pwaller.net> | 2013-10-21 06:22:11 -0700 |
commit | fd7f414b17bd1d2f6046353008f21e3a2650677a (patch) | |
tree | e0c7f421d0b797684680215d68f02db8929fbdc2 | |
parent | b09fa4f235d954f60e71e0fb21869ca80e719d53 (diff) | |
parent | f88fb535a7e533bb4c36ddf2f54b5d51bdb6df14 (diff) | |
download | gl-fd7f414b17bd1d2f6046353008f21e3a2650677a.tar.gz |
Merge pull request #128 from Niriel/uniform_blocks
Added GetUniformBlockIndex and UniformBlockBinding.
-rw-r--r-- | program.go | 21 | ||||
-rw-r--r-- | uniformblockindex.go | 7 |
2 files changed, 28 insertions, 0 deletions
@@ -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 |