mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
opengl: Add BindBuffer accepting both element-array-buffer and array-buffer
This change is a pure refactoring to clarify that array buffer is binded before its usage.
This commit is contained in:
parent
311788dfe2
commit
399f965729
@ -288,7 +288,8 @@ func (s *openGLState) useProgram(proj []float32, texture opengl.Texture, dst, sr
|
||||
s.lastColorMatrixTranslation = nil
|
||||
s.lastSourceWidth = 0
|
||||
s.lastSourceHeight = 0
|
||||
c.BindElementArrayBuffer(s.elementArrayBuffer)
|
||||
c.BindBuffer(opengl.ArrayBuffer, s.arrayBuffer)
|
||||
c.BindBuffer(opengl.ElementArrayBuffer, s.elementArrayBuffer)
|
||||
c.UniformInt(program, "texture", 0)
|
||||
}
|
||||
|
||||
|
@ -465,9 +465,9 @@ func (c *Context) NewElementArrayBuffer(indices []uint16) Buffer {
|
||||
return buffer
|
||||
}
|
||||
|
||||
func (c *Context) BindElementArrayBuffer(b Buffer) {
|
||||
func (c *Context) BindBuffer(bufferType BufferType, b Buffer) {
|
||||
_ = c.runOnContextThread(func() error {
|
||||
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, uint32(b))
|
||||
gl.BindBuffer(uint32(bufferType), uint32(b))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -366,9 +366,9 @@ func (c *Context) NewElementArrayBuffer(indices []uint16) Buffer {
|
||||
return b
|
||||
}
|
||||
|
||||
func (c *Context) BindElementArrayBuffer(b Buffer) {
|
||||
func (c *Context) BindBuffer(bufferType BufferType, b Buffer) {
|
||||
gl := c.gl
|
||||
gl.Call("bindBuffer", gl.Get("ELEMENT_ARRAY_BUFFER"), b)
|
||||
gl.Call("bindBuffer", int(bufferType), b)
|
||||
}
|
||||
|
||||
func (c *Context) BufferSubData(bufferType BufferType, data []float32) {
|
||||
|
@ -380,9 +380,9 @@ func (c *Context) NewElementArrayBuffer(indices []uint16) Buffer {
|
||||
return Buffer(b)
|
||||
}
|
||||
|
||||
func (c *Context) BindElementArrayBuffer(b Buffer) {
|
||||
func (c *Context) BindBuffer(bufferType BufferType, b Buffer) {
|
||||
gl := c.gl
|
||||
gl.BindBuffer(mgl.ELEMENT_ARRAY_BUFFER, mgl.Buffer(b))
|
||||
gl.BindBuffer(mgl.Enum(bufferType), mgl.Buffer(b))
|
||||
}
|
||||
|
||||
func float32ToBytes(v []float32) []byte {
|
||||
|
Loading…
Reference in New Issue
Block a user