-
Notifications
You must be signed in to change notification settings - Fork 52
Description
I am just moving my code to go-gl, code is an improvement but, I am struggling to understand the reasoning behind passing slices and arrays to the various funcs in uniformlocator.go .
For example:
func (location UniformLocation) Uniform3fv(count int, v []float32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform3fv(C.GLint(location), C.GLsizei(count), (*C.GLfloat)(&v[0]))
}
I think 99% of the time this is meant to pass some sort of Vector3 structure. I also guess this kind of approach is very common:
type Vector3 struct {
x,y,z float32
}
Now converting this into a slice is quite a mess... internally the funcion is then converting to a float* .. my proposal is to use *float32 as parameter with these functions, like this:
func (location UniformLocation) KSUniform3fv(count int, v *float32) {
C.glUniform3fv(C.GLint(location), C.GLsizei(count), (*C.GLfloat)(v))
}
and
func (location UniformLocation) KSUniformMatrix4fv(transpose bool, count int, matrix *float32) {
C.glUniformMatrix4fv(C.GLint(location), C.GLsizei(count), glBool(transpose), (*C.GLfloat)(matrix))
}
This should easily map to any kind of internal data structure used by the clients of go-gl .