diff --git a/pixelgl/shader.go b/pixelgl/shader.go index 3023d8c..ddc5f97 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 c79d8cf..1c5c4be 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 25012d4..e007d23 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 }) }