Exemplo n.º 1
0
// Return the OpenGL texture as a golang `image.RGBA`
func (t *Texture) AsImage() *image.RGBA {
	rgba := image.NewRGBA(image.Rect(0, 0, t.W, t.H))
	With(t, func() {
		// TODO: check internal format (with GetIntegerv?)
		gl.GetTexImage(gl.TEXTURE_2D, 0, gl.RGBA, gl.UNSIGNED_BYTE, rgba.Pix)
	})
	return rgba
}
Exemplo n.º 2
0
func (bank *TextureBank) UnitAsImage(index, level int) *image.RGBA {
	geometry := bank.PixelData[index].Geometry[level]
	rgba := image.NewRGBA(image.Rect(0, 0, geometry.Width, geometry.Height))
	unit := bank.Units[index]

	unit.Texture.Bind(unit.Target)

	gl.GetTexImage(unit.Target, 0, gl.RGBA, gl.UNSIGNED_BYTE, rgba.Pix)

	unit.Texture.Unbind(unit.Target)

	return rgba
}