Exemple #1
0
func (c *Context) UniformMatrix4fv(location *UniformLocation, transpose bool, value []float32) {
	// TODO: count value of 1 is currently hardcoded.
	//       Perhaps it should be len(value) / 16 or something else?
	//       In OpenGL 2.1 it is a manually supplied parameter, but WebGL does not have it.
	//       Not sure if WebGL automatically deduces it and supports count values greater than 1, or if 1 is always assumed.
	gl.UniformMatrix4fv(location.int32, 1, transpose, &value[0])
}
Exemple #2
0
func (c *Context) UniformFloats(p Program, location string, v []float32) {
	l := int32(GetUniformLocation(c, p, location))
	switch len(v) {
	case 4:
		gl.Uniform4fv(l, 1, (*float32)(gl.Ptr(v)))
	case 16:
		gl.UniformMatrix4fv(l, 1, false, (*float32)(gl.Ptr(v)))
	default:
		panic("not reach")
	}
}
func (c *Context) UniformFloats(p Program, location string, v []float32) {
	_ = c.runOnContextThread(func() error {
		l := int32(c.locationCache.GetUniformLocation(c, p, location))
		switch len(v) {
		case 4:
			gl.Uniform4fv(l, 1, (*float32)(gl.Ptr(v)))
		case 16:
			gl.UniformMatrix4fv(l, 1, false, (*float32)(gl.Ptr(v)))
		default:
			panic("not reach")
		}
		return nil
	})
}
Exemple #4
0
// UniformMatrix4fv writes 4x4 matrices. Each matrix uses 16
// float32 values, so the number of matrices written is len(src)/16.
//
// Each matrix must be supplied in column major order.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
func UniformMatrix4fv(dst Uniform, src []float32) {
	gl.UniformMatrix4fv(dst.Value, int32(len(src)/(4*4)), false, &src[0])
}
Exemple #5
0
func (s *Shader) setUniformM(uniformName string, value Matrix4f) {
	floats := value.asArray()

	gl.UniformMatrix4fv(s.uniforms[uniformName], 1, true, &floats[0])
}
Exemple #6
0
Fichier : gg.go Projet : dmac/gg
func (*backend) UniformMatrix4fv(u *gg.Uniform, values []float32) {
	gl.UniformMatrix4fv(u.Value.(int32), 1, false, &values[0])
}