Example #1
0
func Uniform2i(
	location int32, x int32, y int32) {
	C.glUniform2i(
		C.GLint(location),
		C.GLint(x),
		C.GLint(y))
}
Example #2
0
func Uniform2i(dst Uniform, v0, v1 int) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.Uniform2i(%v, %v, %v) %v", dst, v0, v1, errstr)
	}()
	C.glUniform2i(dst.c(), C.GLint(v0), C.GLint(v1))
}
Example #3
0
File: shader.go Project: eaburns/gl
// Uniform specifies the value of a uniform variable for the current program object.
func (u Uniform) Uniform(vls ...interface{}) {
	if len(vls) == 0 || len(vls) > 4 {
		panic("Uniform requires 1, 2, 3, or 4 values")
	}
	switch vls[0].(type) {
	case float32:
		switch len(vls) {
		case 1:
			C.glUniform1f(C.GLint(u), C.GLfloat(vls[0].(float32)))
		case 2:
			C.glUniform2f(C.GLint(u), C.GLfloat(vls[0].(float32)), C.GLfloat(vls[1].(float32)))
		case 3:
			C.glUniform3f(C.GLint(u), C.GLfloat(vls[0].(float32)), C.GLfloat(vls[1].(float32)), C.GLfloat(vls[2].(float32)))
		case 4:
			C.glUniform4f(C.GLint(u), C.GLfloat(vls[0].(float32)), C.GLfloat(vls[1].(float32)), C.GLfloat(vls[2].(float32)), C.GLfloat(vls[3].(float32)))
		}
	case int:
		switch len(vls) {
		case 1:
			C.glUniform1i(C.GLint(u), C.GLint(vls[0].(int)))
		case 2:
			C.glUniform2i(C.GLint(u), C.GLint(vls[0].(int)), C.GLint(vls[1].(int)))
		case 3:
			C.glUniform3i(C.GLint(u), C.GLint(vls[0].(int)), C.GLint(vls[1].(int)), C.GLint(vls[2].(int)))
		case 4:
			C.glUniform4i(C.GLint(u), C.GLint(vls[0].(int)), C.GLint(vls[1].(int)), C.GLint(vls[2].(int)), C.GLint(vls[3].(int)))
		}
	default:
		panic("Uniform only accepts int and float32 typed parameters")
	}
}
Example #4
0
func Uniform2i(location, v0, v1 int) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.Uniform2i(%v, %v, %v) %v", location, v0, v1, errstr)
	}()
	C.glUniform2i(C.GLint(location), C.GLint(v0), C.GLint(v1))
}
Example #5
0
File: gl.go Project: extrame/gl
// SetUniform sets a uniform variable using the appropriate glUniform* or glUniformMatrix* call. It supports arrays of float32 and float64 or Mat4 objects.
// NB: The underlying API does not support double precision, being able to pass float64 values is for convenience only.
// BUG: It does not support non-square matrices.
func (p *Program) SetUniform(loc string, data interface{}) {
	uni := p.uni[loc]
	switch f := data.(type) {
	case float32:
		C.glUniform1f(uni, C.GLfloat(f))
	case [1]float32:
		C.glUniform1f(uni, C.GLfloat(f[0]))
	case [2]float32:
		C.glUniform2f(uni, C.GLfloat(f[0]), C.GLfloat(f[1]))
	case [3]float32:
		C.glUniform3f(uni, C.GLfloat(f[0]), C.GLfloat(f[1]), C.GLfloat(f[2]))
	case [4]float32:
		C.glUniform4f(uni, C.GLfloat(f[0]), C.GLfloat(f[1]), C.GLfloat(f[2]), C.GLfloat(f[3]))
	case float64:
		C.glUniform1f(uni, C.GLfloat(f))
	case [1]float64:
		C.glUniform1f(uni, C.GLfloat(f[0]))
	case [2]float64:
		C.glUniform2f(uni, C.GLfloat(f[0]), C.GLfloat(f[1]))
	case [3]float64:
		C.glUniform3f(uni, C.GLfloat(f[0]), C.GLfloat(f[1]), C.GLfloat(f[2]))
	case [4]float64:
		C.glUniform4f(uni, C.GLfloat(f[0]), C.GLfloat(f[1]), C.GLfloat(f[2]), C.GLfloat(f[3]))
	case int:
		C.glUniform1i(uni, C.GLint(f))
	case [1]int:
		C.glUniform1i(uni, C.GLint(f[0]))
	case [2]int:
		C.glUniform2i(uni, C.GLint(f[0]), C.GLint(f[1]))
	case [3]int:
		C.glUniform3i(uni, C.GLint(f[0]), C.GLint(f[1]), C.GLint(f[2]))
	case [4]int:
		C.glUniform4i(uni, C.GLint(f[0]), C.GLint(f[1]), C.GLint(f[2]), C.GLint(f[3]))
	case [2][2]float32:
		g := [4]C.GLfloat{C.GLfloat(f[0][0]), C.GLfloat(f[1][0]), C.GLfloat(f[0][1]), C.GLfloat(f[1][1])}
		C.glUniformMatrix2fv(uni, 1, FALSE, &g[0])
	case [2][2]float64:
		g := [4]C.GLfloat{C.GLfloat(f[0][0]), C.GLfloat(f[1][0]), C.GLfloat(f[0][1]), C.GLfloat(f[1][1])}
		C.glUniformMatrix2fv(uni, 1, FALSE, &g[0])
	case [3][3]float32:
		g := [9]C.GLfloat{C.GLfloat(f[0][0]), C.GLfloat(f[1][0]), C.GLfloat(f[2][0]), C.GLfloat(f[0][1]), C.GLfloat(f[1][1]), C.GLfloat(f[2][1]), C.GLfloat(f[0][2]), C.GLfloat(f[1][2]), C.GLfloat(f[2][2])}
		C.glUniformMatrix3fv(uni, 1, FALSE, &g[0])
	case [3][3]float64:
		g := [9]C.GLfloat{C.GLfloat(f[0][0]), C.GLfloat(f[1][0]), C.GLfloat(f[2][0]), C.GLfloat(f[0][1]), C.GLfloat(f[1][1]), C.GLfloat(f[2][1]), C.GLfloat(f[0][2]), C.GLfloat(f[1][2]), C.GLfloat(f[2][2])}
		C.glUniformMatrix3fv(uni, 1, FALSE, &g[0])
	case [4][4]float32:
		g := [16]C.GLfloat{C.GLfloat(f[0][0]), C.GLfloat(f[1][0]), C.GLfloat(f[2][0]), C.GLfloat(f[3][0]), C.GLfloat(f[0][1]), C.GLfloat(f[1][1]), C.GLfloat(f[2][1]), C.GLfloat(f[3][1]), C.GLfloat(f[0][2]), C.GLfloat(f[1][2]), C.GLfloat(f[2][2]), C.GLfloat(f[3][2]), C.GLfloat(f[0][3]), C.GLfloat(f[1][3]), C.GLfloat(f[2][3]), C.GLfloat(f[3][3])}
		C.glUniformMatrix4fv(uni, 1, FALSE, &g[0])
	case [4][4]float64:
		g := [16]C.GLfloat{C.GLfloat(f[0][0]), C.GLfloat(f[1][0]), C.GLfloat(f[2][0]), C.GLfloat(f[3][0]), C.GLfloat(f[0][1]), C.GLfloat(f[1][1]), C.GLfloat(f[2][1]), C.GLfloat(f[3][1]), C.GLfloat(f[0][2]), C.GLfloat(f[1][2]), C.GLfloat(f[2][2]), C.GLfloat(f[3][2]), C.GLfloat(f[0][3]), C.GLfloat(f[1][3]), C.GLfloat(f[2][3]), C.GLfloat(f[3][3])}
		C.glUniformMatrix4fv(uni, 1, FALSE, &g[0])
	case Mat4:
		g := [16]C.GLfloat{C.GLfloat(f[0][0]), C.GLfloat(f[1][0]), C.GLfloat(f[2][0]), C.GLfloat(f[3][0]), C.GLfloat(f[0][1]), C.GLfloat(f[1][1]), C.GLfloat(f[2][1]), C.GLfloat(f[3][1]), C.GLfloat(f[0][2]), C.GLfloat(f[1][2]), C.GLfloat(f[2][2]), C.GLfloat(f[3][2]), C.GLfloat(f[0][3]), C.GLfloat(f[1][3]), C.GLfloat(f[2][3]), C.GLfloat(f[3][3])}
		C.glUniformMatrix4fv(uni, 1, FALSE, &g[0])
	default:
		panic("invalid type passed to SetUniform()")
	}
}
Example #6
0
func Uniform2i(dst Uniform, v0, v1 int) {
	C.glUniform2i(dst.c(), C.GLint(v0), C.GLint(v1))
}
Example #7
0
func (location UniformLocation) Uniform2i(x int, y int) {
	C.glUniform2i(C.GLint(location), C.GLint(x), C.GLint(y))
}
Example #8
0
func Uniform2i(location, x, y int) {
	C.glUniform2i(C.GLint(location), C.GLint(x), C.GLint(y))
}
Example #9
0
// Uniform2i writes an ivec2 uniform variable.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
func Uniform2i(location, v0, v1 int) {
	C.glUniform2i(C.GLint(location), C.GLint(v0), C.GLint(v1))
}