graphics: Call BindBuffer only when the program was null

This commit is contained in:
Hajime Hoshi 2018-06-04 00:13:23 +09:00
parent fac639f9b7
commit b86860abcc

View File

@ -272,15 +272,18 @@ func (s *openGLState) useProgram(proj []float32, texture opengl.Texture, dst, sr
} }
theArrayBufferLayout.enable(program) theArrayBufferLayout.enable(program)
if s.lastProgram == zeroProgram {
c.BindBuffer(opengl.ArrayBuffer, s.arrayBuffer)
c.BindBuffer(opengl.ElementArrayBuffer, s.elementArrayBuffer)
c.UniformInt(program, "texture", 0)
}
s.lastProgram = program s.lastProgram = program
s.lastProjectionMatrix = nil s.lastProjectionMatrix = nil
s.lastColorMatrix = nil s.lastColorMatrix = nil
s.lastColorMatrixTranslation = nil s.lastColorMatrixTranslation = nil
s.lastSourceWidth = 0 s.lastSourceWidth = 0
s.lastSourceHeight = 0 s.lastSourceHeight = 0
c.BindBuffer(opengl.ArrayBuffer, s.arrayBuffer)
c.BindBuffer(opengl.ElementArrayBuffer, s.elementArrayBuffer)
c.UniformInt(program, "texture", 0)
} }
if !areSameFloat32Array(s.lastProjectionMatrix, proj) { if !areSameFloat32Array(s.lastProjectionMatrix, proj) {