gl: Improve API signatures to match spec, improve docs.

Reorder DrawElements arguments to match OpenGL spec order:
    DrawElements(mode, ty, offset, count) -> (mode, count, ty, offset)
GetActiveAttrib, GetActiveUniform are defined by spec to accept
corresponding integer _index_, not location type. Change their
signature to do that:
    GetActiveAttrib(p Program, a Attrib) -> (p Program, index uint32)
    GetActiveUniform(p Program, u Uniform) -> (p Program, index uint32)
Clarify and make documentation, parameter names more clear for Uniform
(uniform location), Attrib (attribute location) types,
EnableVertexAttribArray, DisableVertexAttribArray, GetAttribLocation,
GetUniformLocation funcs.
Resolves golang/go#10218 again.

Change-Id: I5b822235d9485701186a43dae0b9fd898cc6a3d8
Reviewed-on: https://go-review.googlesource.com/8166
Reviewed-by: David Crawshaw <crawshaw@golang.org>
diff --git a/gl/gl.go b/gl/gl.go
index e0a156d..9ec6e5d 100644
--- a/gl/gl.go
+++ b/gl/gl.go
@@ -370,8 +370,8 @@
 }
 
 // http://www.khronos.org/opengles/sdk/docs/man3/html/glDisableVertexAttribArray.xhtml
-func DisableVertexAttribArray(index Attrib) {
-	C.glDisableVertexAttribArray(index.c())
+func DisableVertexAttribArray(a Attrib) {
+	C.glDisableVertexAttribArray(a.c())
 }
 
 // DrawArrays renders geometric primitives from the bound data.
@@ -384,7 +384,7 @@
 // DrawElements renders primitives from a bound buffer.
 //
 // http://www.khronos.org/opengles/sdk/docs/man3/html/glDrawElements.xhtml
-func DrawElements(mode, ty Enum, offset, count int) {
+func DrawElements(mode Enum, count int, ty Enum, offset int) {
 	C.glDrawElements(mode.c(), C.GLsizei(count), ty.c(), unsafe.Pointer(uintptr(offset)))
 }
 
@@ -400,8 +400,8 @@
 // EnableVertexAttribArray enables a vertex attribute array.
 //
 // http://www.khronos.org/opengles/sdk/docs/man3/html/glEnableVertexAttribArray.xhtml
-func EnableVertexAttribArray(index Attrib) {
-	C.glEnableVertexAttribArray(index.c())
+func EnableVertexAttribArray(a Attrib) {
+	C.glEnableVertexAttribArray(a.c())
 }
 
 // Finish blocks until the effects of all previously called GL
@@ -452,24 +452,30 @@
 	C.glGenerateMipmap(target.c())
 }
 
-// GetActiveAttrib returns details about an attribute variable.
+// GetActiveAttrib returns details about an active attribute variable.
+// A value of 0 for index selects the first active attribute variable.
+// Permissible values for index range from 0 to the number of active
+// attribute variables minus 1.
 //
 // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetActiveAttrib.xhtml
-func GetActiveAttrib(p Program, a Attrib) (name string, size int, ty Enum) {
+func GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {
 	bufSize := GetProgrami(p, ACTIVE_ATTRIBUTE_MAX_LENGTH)
 	buf := C.malloc(C.size_t(bufSize))
 	defer C.free(buf)
 
 	var cSize C.GLint
 	var cType C.GLenum
-	C.glGetActiveAttrib(p.c(), a.c(), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
+	C.glGetActiveAttrib(p.c(), C.GLuint(index), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
 	return C.GoString((*C.char)(buf)), int(cSize), Enum(cType)
 }
 
 // GetActiveUniform returns details about an active uniform variable.
+// A value of 0 for index selects the first active uniform variable.
+// Permissible values for index range from 0 to the number of active
+// uniform variables minus 1.
 //
 // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetActiveUniform.xhtml
-func GetActiveUniform(p Program, u Uniform) (name string, size int, ty Enum) {
+func GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum) {
 	bufSize := GetProgrami(p, ACTIVE_UNIFORM_MAX_LENGTH)
 	buf := C.malloc(C.size_t(bufSize))
 	defer C.free(buf)
@@ -477,7 +483,7 @@
 	var cSize C.GLint
 	var cType C.GLenum
 
-	C.glGetActiveUniform(p.c(), C.GLuint(u.Value), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
+	C.glGetActiveUniform(p.c(), C.GLuint(index), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
 	return C.GoString((*C.char)(buf)), int(cSize), Enum(cType)
 }
 
@@ -497,7 +503,7 @@
 	return shaders
 }
 
-// GetAttribLocation finds a program attribute variable by name.
+// GetAttribLocation returns the location of an attribute variable.
 //
 // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetAttribLocation.xhtml
 func GetAttribLocation(p Program, name string) Attrib {
@@ -694,7 +700,7 @@
 	C.glGetUniformiv(p.c(), src.c(), (*C.GLint)(&dst[0]))
 }
 
-// GetUniformLocation returns the location of uniform variable.
+// GetUniformLocation returns the location of a uniform variable.
 //
 // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniformLocation.xhtml
 func GetUniformLocation(p Program, name string) Uniform {
diff --git a/gl/gldebug.go b/gl/gldebug.go
index 7e856c2..4840a64 100644
--- a/gl/gldebug.go
+++ b/gl/gldebug.go
@@ -1003,12 +1003,12 @@
 	C.glDisable(cap.c())
 }
 
-func DisableVertexAttribArray(index Attrib) {
+func DisableVertexAttribArray(a Attrib) {
 	defer func() {
 		errstr := errDrain()
-		log.Printf("gl.DisableVertexAttribArray(%v) %v", index, errstr)
+		log.Printf("gl.DisableVertexAttribArray(%v) %v", a, errstr)
 	}()
-	C.glDisableVertexAttribArray(index.c())
+	C.glDisableVertexAttribArray(a.c())
 }
 
 func DrawArrays(mode Enum, first, count int) {
@@ -1019,10 +1019,10 @@
 	C.glDrawArrays(mode.c(), C.GLint(first), C.GLsizei(count))
 }
 
-func DrawElements(mode, ty Enum, offset, count int) {
+func DrawElements(mode Enum, count int, ty Enum, offset int) {
 	defer func() {
 		errstr := errDrain()
-		log.Printf("gl.DrawElements(%v, %v, %v, %v) %v", mode, ty, offset, count, errstr)
+		log.Printf("gl.DrawElements(%v, %v, %v, %v) %v", mode, count, ty, offset, errstr)
 	}()
 	C.glDrawElements(mode.c(), C.GLsizei(count), ty.c(), unsafe.Pointer(uintptr(offset)))
 }
@@ -1035,12 +1035,12 @@
 	C.glEnable(cap.c())
 }
 
-func EnableVertexAttribArray(index Attrib) {
+func EnableVertexAttribArray(a Attrib) {
 	defer func() {
 		errstr := errDrain()
-		log.Printf("gl.EnableVertexAttribArray(%v) %v", index, errstr)
+		log.Printf("gl.EnableVertexAttribArray(%v) %v", a, errstr)
 	}()
-	C.glEnableVertexAttribArray(index.c())
+	C.glEnableVertexAttribArray(a.c())
 }
 
 func Finish() {
@@ -1091,31 +1091,31 @@
 	C.glGenerateMipmap(target.c())
 }
 
-func GetActiveAttrib(p Program, a Attrib) (name string, size int, ty Enum) {
+func GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {
 	defer func() {
 		errstr := errDrain()
-		log.Printf("gl.GetActiveAttrib(%v, %v) (%v, %v, %v) %v", p, a, name, size, ty, errstr)
+		log.Printf("gl.GetActiveAttrib(%v, %v) (%v, %v, %v) %v", p, index, name, size, ty, errstr)
 	}()
 	bufSize := GetProgrami(p, ACTIVE_ATTRIBUTE_MAX_LENGTH)
 	buf := C.malloc(C.size_t(bufSize))
 	defer C.free(buf)
 	var cSize C.GLint
 	var cType C.GLenum
-	C.glGetActiveAttrib(p.c(), a.c(), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
+	C.glGetActiveAttrib(p.c(), C.GLuint(index), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
 	return C.GoString((*C.char)(buf)), int(cSize), Enum(cType)
 }
 
-func GetActiveUniform(p Program, u Uniform) (name string, size int, ty Enum) {
+func GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum) {
 	defer func() {
 		errstr := errDrain()
-		log.Printf("gl.GetActiveUniform(%v, %v) (%v, %v, %v) %v", p, u, name, size, ty, errstr)
+		log.Printf("gl.GetActiveUniform(%v, %v) (%v, %v, %v) %v", p, index, name, size, ty, errstr)
 	}()
 	bufSize := GetProgrami(p, ACTIVE_UNIFORM_MAX_LENGTH)
 	buf := C.malloc(C.size_t(bufSize))
 	defer C.free(buf)
 	var cSize C.GLint
 	var cType C.GLenum
-	C.glGetActiveUniform(p.c(), C.GLuint(u.Value), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
+	C.glGetActiveUniform(p.c(), C.GLuint(index), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
 	return C.GoString((*C.char)(buf)), int(cSize), Enum(cType)
 }
 
diff --git a/gl/types_prod.go b/gl/types_prod.go
index 0b7a96b..770d3e7 100644
--- a/gl/types_prod.go
+++ b/gl/types_prod.go
@@ -28,7 +28,7 @@
 // Types are defined a structs so that in debug mode they can carry
 // extra information, such as a string name. See typesdebug.go.
 
-// Attrib is an attribute index.
+// Attrib identifies the location of a specific attribute variable.
 type Attrib struct {
 	Value uint
 }
@@ -63,7 +63,7 @@
 	Value uint32
 }
 
-// A Uniform identifies a GL uniform attribute value.
+// Uniform identifies the location of a specific uniform variable.
 type Uniform struct {
 	Value int32
 }