示例#1
0
文件: opengl.go 项目: tanema/amore
// useVertexAttribArrays will enable the vertex attrib array for the flags passed
// and if the flags were not passed it will disabled them. This make sure that only
// those attributes are enabled.
func useVertexAttribArrays(arraybits uint32) {
	diff := arraybits ^ gl_state.enabledAttribArrays

	if diff == 0 {
		return
	}

	// Max 32 attributes. As of when this was written, no GL driver exposes more
	// than 32. Lets hope that doesn't change...
	for i := uint32(0); i < 32; i++ {
		bit := uint32(1 << i)
		if (diff & bit) > 0 {
			if (arraybits & bit) > 0 {
				gl.EnableVertexAttribArray(gl.Attrib{Value: uint(i)})
			} else {
				gl.DisableVertexAttribArray(gl.Attrib{Value: uint(i)})
			}
		}
	}

	gl_state.enabledAttribArrays = arraybits

	// glDisableVertexAttribArray will make the constant value for a vertex
	// attribute undefined. We rely on the per-vertex color attribute being
	// white when no per-vertex color is used, so we set it here.
	// FIXME: Is there a better place to do this?
	if (diff&attribflag_color) > 0 && (arraybits&attribflag_color) == 0 {
		gl.VertexAttrib4f(attrib_color, 1.0, 1.0, 1.0, 1.0)
	}
}
示例#2
0
文件: opengl.go 项目: tanema/amore
// SetColorC will sets the color used for drawing.
func SetColorC(c *Color) {
	states.back().color = c

	gl.VertexAttrib4f(attrib_constantcolor, c[0], c[1], c[2], c[3])
}