diff --git a/pixelgl/shader.go b/pixelgl/shader.go
index 3023d8c45b1efd3d518aa42076b03c9e2ac44d39..ddc5f979809f6a18c3f1c98eb365ca27f0ba382a 100644
--- a/pixelgl/shader.go
+++ b/pixelgl/shader.go
@@ -388,14 +388,14 @@ func (s *Shader) Do(sub func(Context)) {
 			sub(ctx.WithShader(s))
 			return
 		}
-		s.enabled = true
 		DoNoBlock(func() {
 			gl.UseProgram(s.program)
 		})
+		s.enabled = true
 		sub(ctx.WithShader(s))
+		s.enabled = false
 		DoNoBlock(func() {
 			gl.UseProgram(0)
 		})
-		s.enabled = false
 	})
 }
diff --git a/pixelgl/texture.go b/pixelgl/texture.go
index c79d8cf5398e8a8ecd021f61454c0a74c592fa1f..1c5c4be9aeb064c23078eb56a4280c59bddddfbf 100644
--- a/pixelgl/texture.go
+++ b/pixelgl/texture.go
@@ -68,14 +68,14 @@ func (t *Texture) Do(sub func(Context)) {
 			sub(ctx)
 			return
 		}
-		t.enabled = true
 		DoNoBlock(func() {
 			gl.BindTexture(gl.TEXTURE_2D, t.tex)
 		})
+		t.enabled = true
 		sub(ctx)
+		t.enabled = false
 		DoNoBlock(func() {
 			gl.BindTexture(gl.TEXTURE_2D, 0)
 		})
-		t.enabled = false
 	})
 }
diff --git a/pixelgl/vertex.go b/pixelgl/vertex.go
index 25012d46a1f57c177f6717c540aa4bb4f15c3648..e007d235d766a9466ce2051ed9ff43e5d0570b60 100644
--- a/pixelgl/vertex.go
+++ b/pixelgl/vertex.go
@@ -346,17 +346,17 @@ func (va *VertexArray) Do(sub func(Context)) {
 			sub(ctx)
 			return
 		}
-		va.enabled = true
 		DoNoBlock(func() {
 			gl.BindVertexArray(va.vao)
 			gl.BindBuffer(gl.ARRAY_BUFFER, va.vbo)
 		})
+		va.enabled = true
 		sub(ctx)
+		va.enabled = false
 		DoNoBlock(func() {
 			gl.DrawArrays(uint32(va.mode), 0, int32(va.count))
 			gl.BindBuffer(gl.ARRAY_BUFFER, 0)
 			gl.BindVertexArray(0)
 		})
-		va.enabled = false
 	})
 }