示例#1
0
文件: opengl.go 项目: tanema/amore
// 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
}
示例#2
0
文件: opengl.go 项目: tanema/amore
// 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)
	}
}