Selaa lähdekoodia

cached active texture unit in gls

leonsal 8 vuotta sitten
vanhempi
commit
994b4aef3c
1 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  1. 6 0
      gls/gls.go

+ 6 - 0
gls/gls.go

@@ -22,6 +22,7 @@ type GLS struct {
 	prog                *Program          // current active shader program
 	programs            map[*Program]bool // shader programs cache
 	checkErrors         bool              // check openGL API errors flag
+	activeTexture       uint32            // cached last set active texture unit
 	viewportX           int32             // cached last set viewport x
 	viewportY           int32             // cached last set viewport y
 	viewportWidth       int32             // cached last set viewport width
@@ -135,6 +136,7 @@ func (gs *GLS) reset() {
 	gs.programs = make(map[*Program]bool)
 	gs.prog = nil
 
+	gs.activeTexture = uintUndef
 	gs.blendEquation = uintUndef
 	gs.blendSrc = uintUndef
 	gs.blendDst = uintUndef
@@ -183,7 +185,11 @@ func (gs *GLS) Stats(s *Stats) {
 
 func (gs *GLS) ActiveTexture(texture uint32) {
 
+	if gs.activeTexture == texture {
+		return
+	}
 	C.glActiveTexture(C.GLenum(texture))
+	gs.activeTexture = texture
 }
 
 func (gs *GLS) AttachShader(program, shader uint32) {