2014-08-26 10:03:00 -04:00
|
|
|
// Copyright 2014 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-12-09 12:52:53 -05:00
|
|
|
// +build linux darwin windows
|
2014-09-17 18:07:50 -04:00
|
|
|
// +build !gldebug
|
|
|
|
|
2014-08-26 10:03:00 -04:00
|
|
|
package gl
|
|
|
|
|
2014-10-09 14:00:00 +11:00
|
|
|
import "fmt"
|
2014-08-26 10:03:00 -04:00
|
|
|
|
|
|
|
// Enum is equivalent to GLenum, and is normally used with one of the
|
|
|
|
// constants defined in this package.
|
|
|
|
type Enum uint32
|
|
|
|
|
2014-09-17 18:07:50 -04:00
|
|
|
// Types are defined a structs so that in debug mode they can carry
|
|
|
|
// extra information, such as a string name. See typesdebug.go.
|
|
|
|
|
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>
2015-03-28 22:53:36 -07:00
|
|
|
// Attrib identifies the location of a specific attribute variable.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Attrib struct {
|
|
|
|
Value uint
|
|
|
|
}
|
|
|
|
|
2014-08-26 10:03:00 -04:00
|
|
|
// Program identifies a compiled shader program.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Program struct {
|
2015-12-09 12:52:53 -05:00
|
|
|
// Init is set by CreateProgram, as some GL drivers (in particular,
|
|
|
|
// ANGLE) return true for glIsProgram(0).
|
|
|
|
Init bool
|
2014-09-17 18:07:50 -04:00
|
|
|
Value uint32
|
|
|
|
}
|
2014-08-26 10:03:00 -04:00
|
|
|
|
|
|
|
// Shader identifies a GLSL shader.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Shader struct {
|
|
|
|
Value uint32
|
|
|
|
}
|
2014-08-26 10:03:00 -04:00
|
|
|
|
|
|
|
// Buffer identifies a GL buffer object.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Buffer struct {
|
|
|
|
Value uint32
|
|
|
|
}
|
2014-08-26 10:03:00 -04:00
|
|
|
|
|
|
|
// Framebuffer identifies a GL framebuffer.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Framebuffer struct {
|
|
|
|
Value uint32
|
|
|
|
}
|
2014-08-26 10:03:00 -04:00
|
|
|
|
|
|
|
// A Renderbuffer is a GL object that holds an image in an internal format.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Renderbuffer struct {
|
|
|
|
Value uint32
|
|
|
|
}
|
2014-08-26 10:03:00 -04:00
|
|
|
|
|
|
|
// A Texture identifies a GL texture unit.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Texture struct {
|
|
|
|
Value uint32
|
|
|
|
}
|
2014-08-26 10:03:00 -04:00
|
|
|
|
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>
2015-03-28 22:53:36 -07:00
|
|
|
// Uniform identifies the location of a specific uniform variable.
|
2014-09-17 18:07:50 -04:00
|
|
|
type Uniform struct {
|
|
|
|
Value int32
|
|
|
|
}
|
|
|
|
|
2015-12-09 12:52:53 -05:00
|
|
|
func (v Attrib) c() uintptr { return uintptr(v.Value) }
|
|
|
|
func (v Enum) c() uintptr { return uintptr(v) }
|
|
|
|
func (v Program) c() uintptr {
|
|
|
|
if !v.Init {
|
|
|
|
ret := uintptr(0)
|
|
|
|
ret--
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
return uintptr(v.Value)
|
|
|
|
}
|
|
|
|
func (v Shader) c() uintptr { return uintptr(v.Value) }
|
|
|
|
func (v Buffer) c() uintptr { return uintptr(v.Value) }
|
|
|
|
func (v Framebuffer) c() uintptr { return uintptr(v.Value) }
|
|
|
|
func (v Renderbuffer) c() uintptr { return uintptr(v.Value) }
|
|
|
|
func (v Texture) c() uintptr { return uintptr(v.Value) }
|
|
|
|
func (v Uniform) c() uintptr { return uintptr(v.Value) }
|
2014-08-26 10:03:00 -04:00
|
|
|
|
2015-03-23 20:18:30 -07:00
|
|
|
func (v Attrib) String() string { return fmt.Sprintf("Attrib(%d)", v.Value) }
|
2014-09-17 18:07:50 -04:00
|
|
|
func (v Program) String() string { return fmt.Sprintf("Program(%d)", v.Value) }
|
|
|
|
func (v Shader) String() string { return fmt.Sprintf("Shader(%d)", v.Value) }
|
|
|
|
func (v Buffer) String() string { return fmt.Sprintf("Buffer(%d)", v.Value) }
|
|
|
|
func (v Framebuffer) String() string { return fmt.Sprintf("Framebuffer(%d)", v.Value) }
|
|
|
|
func (v Renderbuffer) String() string { return fmt.Sprintf("Renderbuffer(%d)", v.Value) }
|
|
|
|
func (v Texture) String() string { return fmt.Sprintf("Texture(%d)", v.Value) }
|
|
|
|
func (v Uniform) String() string { return fmt.Sprintf("Uniform(%d)", v.Value) }
|