예제 #1
0
파일: texture.go 프로젝트: eaburns/gl
// 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")
	}
}
예제 #2
0
파일: gles2.go 프로젝트: remogatto/egles
func TexParameteri(
	target Enum, pname Enum, param int32) {
	C.glTexParameteri(
		C.GLenum(target),
		C.GLenum(pname),
		C.GLint(param))
}
예제 #3
0
파일: gldebug.go 프로젝트: Miaque/mojo
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))
}
예제 #4
0
파일: gl.go 프로젝트: 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
}
예제 #5
0
파일: gl_opengles.go 프로젝트: tanema/amore
func TexParameteri(target, pname Enum, param int) {
	C.glTexParameteri(target.c(), pname.c(), C.GLint(param))
}
예제 #6
0
파일: gl.go 프로젝트: 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)
}
예제 #7
0
func TexParameter(target TextureTarget, pname TextureParameter, param TextureParameterValue) {
	C.glTexParameteri(C.GLenum(target), C.GLenum(pname), C.GLint(param))
}
예제 #8
0
파일: es2.go 프로젝트: nick-fedesna/egles
func TexParameteri(target, pname uint, param int) {
	C.glTexParameteri(C.GLenum(target), C.GLenum(pname), C.GLint(param))
}