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 }
// 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 }
func CreateTexture() Texture { var t Texture C.glGenTextures(1, (*C.GLuint)(&t.Value)) return t }
func GenTextures( n Sizei, textures *uint32) { C.glGenTextures( C.GLsizei(n), (*C.GLuint)(textures)) }
// Fill slice with new textures func GenTextures(textures []Texture) { if len(textures) > 0 { C.glGenTextures(C.GLsizei(len(textures)), (*C.GLuint)(&textures[0])) } }
// Create single texture object func GenTexture() Texture { var b C.GLuint C.glGenTextures(1, &b) return Texture(b) }
func CreateTexture() Texture { texture := Texture(0) C.glGenTextures(1, (*C.GLuint)(&texture)) return texture }
func GenTextures(n int, textures Void) { C.glGenTextures(C.GLsizei(n), (*C.GLuint)(unsafe.Pointer(textures))) }
// GenTextures generates texture names. func GenTextures(n int) []Texture { texs := make([]Texture, n) C.glGenTextures(C.GLsizei(n), (*C.GLuint)(&texs[0])) return texs }