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>
This commit is contained in:
parent
4d47512510
commit
a01c060faa
30
gl/gl.go
30
gl/gl.go
@ -370,8 +370,8 @@ func Disable(cap Enum) {
|
||||
}
|
||||
|
||||
// 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 @@ func DrawArrays(mode Enum, first, count int) {
|
||||
// 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 @@ func Enable(cap Enum) {
|
||||
// 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 @@ func GenerateMipmap(target Enum) {
|
||||
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 @@ func GetActiveUniform(p Program, u Uniform) (name string, size int, ty Enum) {
|
||||
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 @@ func GetAttachedShaders(p Program) []Shader {
|
||||
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 @@ func GetUniformiv(dst []int32, src Uniform, p Program) {
|
||||
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 {
|
||||
|
@ -1003,12 +1003,12 @@ func Disable(cap Enum) {
|
||||
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 @@ func DrawArrays(mode Enum, first, count int) {
|
||||
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 @@ func Enable(cap Enum) {
|
||||
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 @@ func GenerateMipmap(target Enum) {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ type Enum uint32
|
||||
// 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 @@ type Texture struct {
|
||||
Value uint32
|
||||
}
|
||||
|
||||
// A Uniform identifies a GL uniform attribute value.
|
||||
// Uniform identifies the location of a specific uniform variable.
|
||||
type Uniform struct {
|
||||
Value int32
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user