diff options
author | Tom Myers <tom.stephen.myers@gmail.com> | 2014-01-17 14:27:55 +0000 |
---|---|---|
committer | Tom Myers <tom.stephen.myers@gmail.com> | 2014-01-17 14:27:55 +0000 |
commit | f6f02bb7e574506596ae42e066fcfce3d9fde314 (patch) | |
tree | 5e7e638bcadc2c40b09a368b690d148e5af47756 | |
parent | fd7f414b17bd1d2f6046353008f21e3a2650677a (diff) | |
download | gl-f6f02bb7e574506596ae42e066fcfce3d9fde314.tar.gz |
Support for multiple string inputs to shader.Source().
-rw-r--r-- | shader.go | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -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)) } |