UploadTexture sends the image to the GPU, to be kept in GPU RAM
(img Image)
| 98 | |
| 99 | // UploadTexture sends the image to the GPU, to be kept in GPU RAM |
| 100 | func UploadTexture(img Image) *gl.Texture { |
| 101 | var id *gl.Texture |
| 102 | if !engo.Headless() { |
| 103 | id = engo.Gl.CreateTexture() |
| 104 | |
| 105 | engo.Gl.BindTexture(engo.Gl.TEXTURE_2D, id) |
| 106 | |
| 107 | engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_WRAP_S, engo.Gl.CLAMP_TO_EDGE) |
| 108 | engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_WRAP_T, engo.Gl.CLAMP_TO_EDGE) |
| 109 | engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_MIN_FILTER, engo.Gl.LINEAR) |
| 110 | engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_MAG_FILTER, engo.Gl.NEAREST) |
| 111 | |
| 112 | if img.Data() == nil { |
| 113 | panic("Texture image data is nil.") |
| 114 | } |
| 115 | |
| 116 | engo.Gl.TexImage2D(engo.Gl.TEXTURE_2D, 0, engo.Gl.RGBA, engo.Gl.RGBA, engo.Gl.UNSIGNED_BYTE, img.Data()) |
| 117 | } |
| 118 | return id |
| 119 | } |
| 120 | |
| 121 | // NewTextureResource sends the image to the GPU and returns a `TextureResource` for easy access |
| 122 | func NewTextureResource(img Image) TextureResource { |
no test coverage detected