aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Myers <tom.stephen.myers@gmail.com>2014-01-17 14:27:55 +0000
committerTom Myers <tom.stephen.myers@gmail.com>2014-01-17 14:27:55 +0000
commitf6f02bb7e574506596ae42e066fcfce3d9fde314 (patch)
tree5e7e638bcadc2c40b09a368b690d148e5af47756
parentfd7f414b17bd1d2f6046353008f21e3a2650677a (diff)
downloadgl-f6f02bb7e574506596ae42e066fcfce3d9fde314.tar.gz
Support for multiple string inputs to shader.Source().
-rw-r--r--shader.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/shader.go b/shader.go
index aec8742..cd8514f 100644
--- a/shader.go
+++ b/shader.go
@@ -12,6 +12,7 @@ package gl
// }
//
import "C"
+import "unsafe"
// Shader
@@ -53,14 +54,19 @@ func (shader Shader) GetSource() string {
return ""
}
-func (shader Shader) Source(source string) {
+func (shader Shader) Source(source ...string) {
+ count := C.GLsizei(len(source))
+ cstrings := make([]*C.GLchar, count)
+ length := make([]C.GLint, count)
- csource := glString(source)
- defer freeString(csource)
-
- var one C.GLint = C.GLint(len(source))
+ for i, s := range source {
+ csource := glString(s)
+ cstrings[i] = csource
+ length[i] = C.GLint(len(s))
+ defer freeString(csource)
+ }
- C.glShaderSource(C.GLuint(shader), 1, &csource, &one)
+ C.glShaderSource(C.GLuint(shader), count, (**_Ctype_GLchar)(unsafe.Pointer(&cstrings[0])), (*_Ctype_GLint)(unsafe.Pointer(&length[0])))
}
func (shader Shader) Compile() { C.glCompileShader(C.GLuint(shader)) }