mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
Bug fix: gl.EnableClientState should not be called
This commit is contained in:
parent
8ae96875c9
commit
ce81251730
@ -36,6 +36,7 @@ type Matrix interface {
|
|||||||
var initialized = false
|
var initialized = false
|
||||||
|
|
||||||
const size = 10000
|
const size = 10000
|
||||||
|
// TODO: Use unsafe.SizeOf?
|
||||||
const uint16Size = 2
|
const uint16Size = 2
|
||||||
const short32Size = 4
|
const short32Size = 4
|
||||||
|
|
||||||
@ -45,6 +46,11 @@ func DrawTexture(native gl.Texture, projectionMatrix [4][4]float64, quads []Text
|
|||||||
if !initialized {
|
if !initialized {
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
|
vertexBuffer := gl.GenBuffer()
|
||||||
|
vertexBuffer.Bind(gl.ARRAY_BUFFER)
|
||||||
|
vertices := make([]float32, stride*size)
|
||||||
|
gl.BufferData(gl.ARRAY_BUFFER, short32Size*len(vertices), vertices, gl.DYNAMIC_DRAW)
|
||||||
|
|
||||||
indexBuffer := gl.GenBuffer()
|
indexBuffer := gl.GenBuffer()
|
||||||
indexBuffer.Bind(gl.ELEMENT_ARRAY_BUFFER)
|
indexBuffer.Bind(gl.ELEMENT_ARRAY_BUFFER)
|
||||||
indices := make([]uint16, 6*size)
|
indices := make([]uint16, 6*size)
|
||||||
@ -58,11 +64,6 @@ func DrawTexture(native gl.Texture, projectionMatrix [4][4]float64, quads []Text
|
|||||||
}
|
}
|
||||||
gl.BufferData(gl.ELEMENT_ARRAY_BUFFER, uint16Size*len(indices), indices, gl.STATIC_DRAW)
|
gl.BufferData(gl.ELEMENT_ARRAY_BUFFER, uint16Size*len(indices), indices, gl.STATIC_DRAW)
|
||||||
|
|
||||||
vertexBuffer := gl.GenBuffer()
|
|
||||||
vertexBuffer.Bind(gl.ARRAY_BUFFER)
|
|
||||||
vertices := make([]float32, stride*size)
|
|
||||||
gl.BufferData(gl.ARRAY_BUFFER, short32Size*len(vertices), vertices, gl.DYNAMIC_DRAW)
|
|
||||||
|
|
||||||
initialized = true
|
initialized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,15 +79,11 @@ func DrawTexture(native gl.Texture, projectionMatrix [4][4]float64, quads []Text
|
|||||||
vertexAttrLocation := getAttributeLocation(program, "vertex")
|
vertexAttrLocation := getAttributeLocation(program, "vertex")
|
||||||
texCoordAttrLocation := getAttributeLocation(program, "tex_coord")
|
texCoordAttrLocation := getAttributeLocation(program, "tex_coord")
|
||||||
|
|
||||||
gl.EnableClientState(gl.VERTEX_ARRAY)
|
|
||||||
gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
|
|
||||||
vertexAttrLocation.EnableArray()
|
vertexAttrLocation.EnableArray()
|
||||||
texCoordAttrLocation.EnableArray()
|
texCoordAttrLocation.EnableArray()
|
||||||
defer func() {
|
defer func() {
|
||||||
texCoordAttrLocation.DisableArray()
|
texCoordAttrLocation.DisableArray()
|
||||||
vertexAttrLocation.DisableArray()
|
vertexAttrLocation.DisableArray()
|
||||||
gl.DisableClientState(gl.TEXTURE_COORD_ARRAY)
|
|
||||||
gl.DisableClientState(gl.VERTEX_ARRAY)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// TODO: Fix this dirty hack after fixing https://github.com/go-gl/gl/issues/174
|
// TODO: Fix this dirty hack after fixing https://github.com/go-gl/gl/issues/174
|
||||||
|
Loading…
Reference in New Issue
Block a user