Exemplo n.º 1
0
func GenTexture() (r0 Texture) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.GenTexture() %v%v", r0, errstr)
	}()
	var t Texture
	C.glGenTextures(1, (*C.GLuint)(&t.Value))
	return t
}
Exemplo n.º 2
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.º 3
0
func CreateTexture() Texture {
	var t Texture
	C.glGenTextures(1, (*C.GLuint)(&t.Value))
	return t
}
Exemplo n.º 4
0
func GenTextures(
	n Sizei, textures *uint32) {
	C.glGenTextures(
		C.GLsizei(n),
		(*C.GLuint)(textures))
}
Exemplo n.º 5
0
Arquivo: texture.go Projeto: Nvveen/gl
// Fill slice with new textures
func GenTextures(textures []Texture) {
	if len(textures) > 0 {
		C.glGenTextures(C.GLsizei(len(textures)), (*C.GLuint)(&textures[0]))
	}
}
Exemplo n.º 6
0
Arquivo: texture.go Projeto: Nvveen/gl
// Create single texture object
func GenTexture() Texture {
	var b C.GLuint
	C.glGenTextures(1, &b)
	return Texture(b)
}
Exemplo n.º 7
0
func CreateTexture() Texture {
	texture := Texture(0)
	C.glGenTextures(1, (*C.GLuint)(&texture))
	return texture
}
Exemplo n.º 8
0
func GenTextures(n int, textures Void) {
	C.glGenTextures(C.GLsizei(n), (*C.GLuint)(unsafe.Pointer(textures)))
}
Exemplo n.º 9
0
// GenTextures generates texture names.
func GenTextures(n int) []Texture {
	texs := make([]Texture, n)
	C.glGenTextures(C.GLsizei(n), (*C.GLuint)(&texs[0]))
	return texs
}