go-opengl-pixel/pixelgl/attr.go

67 lines
1.3 KiB
Go
Raw Normal View History

2016-11-29 16:11:53 -06:00
package pixelgl
// Attr represents an arbitrary OpenGL attribute, such as a vertex attribute or a shader uniform attribute.
type Attr struct {
Purpose AttrPurpose
Type AttrType
}
// AttrPurpose specified a purpose of an attribute. Feel free to create your own purposes for your own needs.
type AttrPurpose int
const (
// Position of a vertex
Position AttrPurpose = iota
// Color of a vertex
Color
// TexCoord are texture coordinates
TexCoord
// Transform is an object transformation matrix
Transform
2016-12-03 08:48:40 -06:00
// MaskColor is a masking color. When drawing, each color gets multiplied by this color.
MaskColor
2016-12-01 09:12:51 -06:00
// NumStandardAttrPurposes is the number of standard attribute purposes
NumStandardAttrPurposes
2016-11-29 16:11:53 -06:00
)
// AttrType represents the type of an OpenGL attribute.
type AttrType int
// List of all possible attribute types.
const (
2016-12-01 09:09:56 -06:00
Int AttrType = iota
2016-11-29 16:11:53 -06:00
Float
Vec2
Vec3
Vec4
Mat2
Mat23
Mat24
Mat3
Mat32
Mat34
Mat4
Mat42
Mat43
)
// Size returns the size of a type in bytes.
func (at AttrType) Size() int {
2016-12-02 15:55:58 -06:00
return map[AttrType]int{
2016-11-29 16:11:53 -06:00
Int: 4,
2016-12-01 09:44:54 -06:00
Float: 4,
Vec2: 2 * 4,
Vec3: 3 * 4,
Vec4: 4 * 4,
Mat2: 2 * 2 * 4,
Mat23: 2 * 3 * 4,
Mat24: 2 * 4 * 4,
Mat3: 3 * 3 * 4,
Mat32: 3 * 2 * 4,
Mat34: 3 * 4 * 4,
Mat4: 4 * 4 * 4,
Mat42: 4 * 2 * 4,
Mat43: 4 * 3 * 4,
2016-12-02 15:55:58 -06:00
}[at]
2016-11-29 16:11:53 -06:00
}