improve docs in pixelgl
This commit is contained in:
parent
1894e213d2
commit
8917a09da9
|
@ -6,7 +6,7 @@ package pixelgl
|
|||
// AttrFormat{{"position", Vec2}, {"color", Vec4}, {"texCoord": Vec2}}
|
||||
type AttrFormat []Attr
|
||||
|
||||
// Size returns the total size of all attributes of an attribute format.
|
||||
// Size returns the total size of all attributes of the AttrFormat.
|
||||
func (af AttrFormat) Size() int {
|
||||
total := 0
|
||||
for _, attr := range af {
|
||||
|
|
|
@ -2,11 +2,12 @@ package pixelgl
|
|||
|
||||
import "github.com/go-gl/gl/v3.3-core/gl"
|
||||
|
||||
// Init initializes OpenGL by loading the function pointers from the active OpenGL context.
|
||||
// This function must be manually run inside the main thread (Do, DoErr, DoVal, etc.).
|
||||
// Init initializes OpenGL by loading function pointers from the active OpenGL context.
|
||||
// This function must be manually run inside the main thread (using "github.com/faiface/mainthread"
|
||||
// package).
|
||||
//
|
||||
// It must be called under the presence of an active OpenGL context, e.g., always after calling
|
||||
// window.MakeContextCurrent(). Also, always call this function when switching contexts.
|
||||
// window.MakeContextCurrent(). Also, always call this function when switching contexts.
|
||||
func Init() {
|
||||
err := gl.Init()
|
||||
if err != nil {
|
||||
|
|
|
@ -119,17 +119,17 @@ func (s *Shader) delete() {
|
|||
})
|
||||
}
|
||||
|
||||
// VertexFormat returns the vertex attribute format of this shader. Do not change it.
|
||||
// VertexFormat returns the vertex attribute format of this Shader. Do not change it.
|
||||
func (s *Shader) VertexFormat() AttrFormat {
|
||||
return s.vertexFmt
|
||||
}
|
||||
|
||||
// UniformFormat returns the uniform attribute format of this shader. Do not change it.
|
||||
// UniformFormat returns the uniform attribute format of this Shader. Do not change it.
|
||||
func (s *Shader) UniformFormat() AttrFormat {
|
||||
return s.uniformFmt
|
||||
}
|
||||
|
||||
// SetUniformAttr sets the value of a uniform attribute of a shader. The attribute is
|
||||
// SetUniformAttr sets the value of a uniform attribute of this Shader. The attribute is
|
||||
// specified by the index in the Shader's uniform format.
|
||||
//
|
||||
// If the uniform attribute does not exist in the Shader, this method returns false.
|
||||
|
@ -152,7 +152,7 @@ func (s *Shader) UniformFormat() AttrFormat {
|
|||
// Attr{Type: Mat43}: mgl32.Mat4x3
|
||||
// No other types are supported.
|
||||
//
|
||||
// The shader must be bound before calling this method.
|
||||
// The Shader must be bound before calling this method.
|
||||
func (s *Shader) SetUniformAttr(uniform int, value interface{}) (ok bool) {
|
||||
if s.uniformLoc[uniform] < 0 {
|
||||
return false
|
||||
|
@ -208,12 +208,12 @@ func (s *Shader) SetUniformAttr(uniform int, value interface{}) (ok bool) {
|
|||
return true
|
||||
}
|
||||
|
||||
// Begin binds a shader program. This is necessary before using the shader.
|
||||
// Begin binds the Shader program. This is necessary before using the Shader.
|
||||
func (s *Shader) Begin() {
|
||||
s.program.bind()
|
||||
}
|
||||
|
||||
// End unbinds a shader program and restores the previous one.
|
||||
// End unbinds the Shader program and restores the previous one.
|
||||
func (s *Shader) End() {
|
||||
s.program.restore()
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ type Texture struct {
|
|||
}
|
||||
|
||||
// NewTexture creates a new texture with the specified width and height with some initial
|
||||
// pixel values. The pixels must be a sequence of RGBA values.
|
||||
// pixel values. The pixels must be a sequence of RGBA values (one byte per component).
|
||||
func NewTexture(width, height int, smooth bool, pixels []uint8) *Texture {
|
||||
tex := &Texture{
|
||||
tex: binder{
|
||||
|
@ -70,12 +70,12 @@ func (t *Texture) delete() {
|
|||
})
|
||||
}
|
||||
|
||||
// Width returns the width of a texture in pixels.
|
||||
// Width returns the width of the Texture in pixels.
|
||||
func (t *Texture) Width() int {
|
||||
return t.width
|
||||
}
|
||||
|
||||
// Height returns the height of a texture in pixels.
|
||||
// Height returns the height of the Texture in pixels.
|
||||
func (t *Texture) Height() int {
|
||||
return t.height
|
||||
}
|
||||
|
@ -117,12 +117,12 @@ func (t *Texture) Pixels(x, y, w, h int) []uint8 {
|
|||
return subPixels
|
||||
}
|
||||
|
||||
// Begin binds a texture. This is necessary before using the texture.
|
||||
// Begin binds the Texture. This is necessary before using the Texture.
|
||||
func (t *Texture) Begin() {
|
||||
t.tex.bind()
|
||||
}
|
||||
|
||||
// End unbinds a texture and restores the previous one.
|
||||
// End unbinds the Texture and restores the previous one.
|
||||
func (t *Texture) End() {
|
||||
t.tex.restore()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue