func (_ *GlCache) BindTextureTo(textureUnit, glHandle gl.Uint, glTarget gl.Enum) { if Cache.bindTexture[textureUnit] != glHandle { Cache.bindTexture[textureUnit] = glHandle Cache.ActiveTexture(gl.Enum(gl.TEXTURE0 + textureUnit)) gl.BindTexture(glTarget, glHandle) } }
func (me *FxProc) setProcIndex(index int) { if index != me.procIndex { me.procIndex = index me.unifNames = map[[2]string]string{} if me.IsTex() { me.Tex.glUnitI = gl.Int(index) me.Tex.glUnitU = gl.Uint(index) me.Tex.glUnitE = gl.Enum(gl.TEXTURE0 + index) } } }
func (me *TextureBase) recreate(numTargets int, initialTarget gl.Enum, maxNumMipLevels, width, height gl.Sizei) (err error) { err = me.onBeforeRecreate() defer me.onAfterRecreate() if err == nil { var ( glTargets []gl.Enum hasPixData, hasAllFaces bool i int ) min, numLevels := int(initialTarget), me.MipMap.NumLevels glTargets = make([]gl.Enum, numTargets) for i = 0; i < numTargets; i++ { glTargets[i] = gl.Enum(min + i) } if numLevels < 1 { numLevels = maxNumMipLevels } if me.immutable() { err = Try.TexStorage2D(me.GlTarget, numLevels, me.SizedInternalFormat, width, height) } if hasAllFaces = true; err == nil { for i = 0; i < numTargets; i++ { if hasPixData = me.PixelData.Ptrs[i] != PtrNil; !hasPixData { hasAllFaces = false } if me.immutable() { err = me.subImage(glTargets[i], 0, 0, width, height, me.PixelData.Ptrs[i]) } else { err = me.texImage(glTargets[i], width, height, me.PixelData.Ptrs[i]) } } } if (err == nil) && hasAllFaces && me.MipMap.AutoGen { err = Try.GenerateMipmap(me.GlTarget) } } return }