func (f *Font) teardownTextRendering(texture gl.GLuint, initial *sdl.Surface, intermediarya *sdl.Surface, intermediary *sdl.Surface) (endw int, endh int) { // gl.Disable(gl.BLEND) /* Bad things happen if we delete the texture before it finishes */ gl.Finish() /* return the deltas in the unused w,h part of the rect */ endw = int(initial.W) endh = int(initial.H) /* Clean up */ initial.Free() intermediarya.Free() intermediary.Free() gl.DeleteTextures(1, &texture) // return }
func uploadTexture_RGBA32(w, h int, data []byte) gl.GLuint { var id gl.GLuint gl.GenTextures(1, &id) gl.BindTexture(gl.TEXTURE_2D, id) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE) gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.GLsizei(w), gl.GLsizei(h), 0, gl.RGBA, gl.UNSIGNED_BYTE, unsafe.Pointer(&data[0])) if gl.GetError() != gl.NO_ERROR { gl.DeleteTextures(1, &id) panic("Failed to load a texture") return 0 } return id }
func ReuploadTexture(tex *gl.GLuint, w, h int, data []byte) { if *tex > 0 { gl.DeleteTextures(1, tex) } *tex = uploadTexture_RGBA32(w, h, data) }