Exemplo n.º 1
0
// TexParameter sets texture parameters.
func TexParameter(targ TextureTarget, parm TexParam, val interface{}) {
	switch v := val.(type) {
	case float32:
		C.glTexParameterf(C.GLenum(targ), C.GLenum(parm), C.GLfloat(v))
	case float64:
		C.glTexParameterf(C.GLenum(targ), C.GLenum(parm), C.GLfloat(v))

	case int32:
		C.glTexParameteri(C.GLenum(targ), C.GLenum(parm), C.GLint(v))
	case int:
		C.glTexParameteri(C.GLenum(targ), C.GLenum(parm), C.GLint(v))
	default:
		panic("TexParameter requires either float32, float64, int32, or int")
	}
}
Exemplo n.º 2
0
func TexParameteri(
	target Enum, pname Enum, param int32) {
	C.glTexParameteri(
		C.GLenum(target),
		C.GLenum(pname),
		C.GLint(param))
}
Exemplo n.º 3
0
func TexParameteri(target, pname Enum, param int) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.TexParameteri(%v, %v, %v) %v", target, pname, param, errstr)
	}()
	C.glTexParameteri(target.c(), pname.c(), C.GLint(param))
}
Exemplo n.º 4
0
Arquivo: gl.go Projeto: extrame/gl
// NewTexture2D creates a new texture object from the given image using glTexImage2D. It uses RGBA as a color format and sets GL_TEXTURE_{MIN,MAG}_FILTER to GL_NEAREST
func NewTexture2D(img image.Image, border int) Texture {
	var t C.GLuint

	C.glGenTextures(1, &t)
	tt := Texture(t)
	tt.Bind(TEXTURE_2D)
	data := make([]uint16, img.Bounds().Dx()*img.Bounds().Dy()*4)
	r := img.Bounds()
	for x := r.Min.X; x < r.Max.X; x++ {
		for y := r.Min.Y; y < r.Max.Y; y++ {
			R, G, B, A := img.At(x, y).RGBA()
			i := (y*r.Dx() + x) * 4
			data[i] = uint16(R)
			data[i+1] = uint16(G)
			data[i+2] = uint16(B)
			data[i+3] = uint16(A)
		}
	}
	C.glTexImage2D(TEXTURE_2D, 0, RGBA, C.GLsizei(img.Bounds().Dx()), C.GLsizei(img.Bounds().Dy()), C.GLint(border), RGBA, UNSIGNED_SHORT, unsafe.Pointer(&data[0]))
	C.glTexParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST)
	C.glTexParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, NEAREST)
	tt.Unbind(TEXTURE_2D)
	return tt
}
Exemplo n.º 5
0
func TexParameteri(target, pname Enum, param int) {
	C.glTexParameteri(target.c(), pname.c(), C.GLint(param))
}
Exemplo n.º 6
0
Arquivo: gl.go Projeto: extrame/gl
// TexParameteri calls glTexParameteri on the texture. The targ argument is used for binding and should most likely be TEXTURE_2D.
func (t Texture) TexParameteri(targ, pname, param int) {
	t.Bind(targ)
	C.glTexParameteri(C.GLenum(targ), C.GLenum(pname), C.GLint(param))
	t.Unbind(targ)
}
Exemplo n.º 7
0
func TexParameter(target TextureTarget, pname TextureParameter, param TextureParameterValue) {
	C.glTexParameteri(C.GLenum(target), C.GLenum(pname), C.GLint(param))
}
Exemplo n.º 8
0
func TexParameteri(target, pname uint, param int) {
	C.glTexParameteri(C.GLenum(target), C.GLenum(pname), C.GLint(param))
}