MCPcopy
hub / github.com/EngoEngine/engo / UploadTexture

Function UploadTexture

common/render_filetype.go:100–119  ·  view source on GitHub ↗

UploadTexture sends the image to the GPU, to be kept in GPU RAM

(img Image)

Source from the content-addressed store, hash-verified

98
99// UploadTexture sends the image to the GPU, to be kept in GPU RAM
100func 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
122func NewTextureResource(img Image) TextureResource {

Callers 2

NewTextureResourceFunction · 0.85
NewTextureSingleFunction · 0.85

Calls 2

HeadlessFunction · 0.92
DataMethod · 0.65

Tested by

no test coverage detected