add vertex format primitives

This commit is contained in:
faiface 2016-11-23 14:03:23 +01:00
parent c1688cb8c7
commit 4a52f3a7dd
1 changed files with 34 additions and 0 deletions

34
pixelgl/vertex.go Normal file
View File

@ -0,0 +1,34 @@
package pixelgl
// VertexFormat defines a data format in a vertex buffer.
//
// Example:
//
// vf := VertexFormat{{Position, 2}, {Color, 4}, {TexCoord, 2}}
type VertexFormat []VertexAttribute
// VertexAttribute specifies a single attribute in a vertex buffer.
// All vertex attributes are composed of float64s.
//
// A vertex attribute has a Purpose (such as Position, Color, etc.) and Size. Size specifies
// the number of float64s the vertex attribute is composed of.
type VertexAttribute struct {
Purpose VertexAttributePurpose
Size int
}
// VertexAttributePurpose clarifies the purpose of a vertex attribute. This can be a color, position, texture
// coordinates or anything else.
//
// VertexAttributePurpose may be used to correctly assign data to a vertex buffer.
type VertexAttributePurpose int
// Position, Color and TexCoord are the standard vertex attributes.
//
// Feel free to define more vertex attribute purposes (e.g. in an effects library).
const (
Position VertexAttributePurpose = iota
Color
TexCoord
NumStandardVertexAttrib
)