Exemple #1
0
// bindTextureToUnit will bind a texture to a texture unit. If restorprev is true
// it will enable the current texture unit after completing
func bindTextureToUnit(texture gl.Texture, textureunit int, restoreprev bool) error {
	if texture != gl_state.boundTextures[textureunit] {
		oldtextureunit := gl_state.curTextureUnit
		if err := setTextureUnit(textureunit); err != nil {
			return err
		}
		gl_state.boundTextures[textureunit] = texture
		gl.BindTexture(gl.TEXTURE_2D, gl_state.boundTextures[textureunit])
		if restoreprev {
			return setTextureUnit(oldtextureunit)
		}
	}
	return nil
}
Exemple #2
0
// bindTexture will bind a texture to the current context if it isnt already bound
func bindTexture(texture gl.Texture) {
	if texture != gl_state.boundTextures[gl_state.curTextureUnit] {
		gl_state.boundTextures[gl_state.curTextureUnit] = texture
		gl.BindTexture(gl.TEXTURE_2D, texture)
	}
}