graphics: Bug fix: Delete buffer when necessary

This commit is contained in:
Hajime Hoshi 2017-09-24 23:20:26 +09:00
parent ecc9d0b3b1
commit e5ca84013c

View File

@ -132,6 +132,7 @@ var (
// theOpenGLState is the OpenGL state in the current process. // theOpenGLState is the OpenGL state in the current process.
theOpenGLState openGLState theOpenGLState openGLState
zeroBuffer opengl.Buffer
zeroProgram opengl.Program zeroProgram opengl.Program
) )
@ -175,10 +176,14 @@ func (s *openGLState) reset() error {
return err return err
} }
// TODO: Delete the array buffer and the element array buffer when needed? if s.arrayBuffer != zeroBuffer {
opengl.GetContext().DeleteBuffer(s.arrayBuffer)
}
s.arrayBuffer = theArrayBufferLayout.newArrayBuffer() s.arrayBuffer = theArrayBufferLayout.newArrayBuffer()
if s.elementArrayBuffer != zeroBuffer {
opengl.GetContext().DeleteBuffer(s.elementArrayBuffer)
}
indices := make([]uint16, 6*maxQuads) indices := make([]uint16, 6*maxQuads)
for i := uint16(0); i < maxQuads; i++ { for i := uint16(0); i < maxQuads; i++ {
indices[6*i+0] = 4*i + 0 indices[6*i+0] = 4*i + 0