mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-03 22:44:28 +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.lastColorMatrixTranslation = nil
|
||||||
s.lastSourceWidth = 0
|
s.lastSourceWidth = 0
|
||||||
s.lastSourceHeight = 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)
|
c.UniformInt(program, "texture", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,9 +465,9 @@ func (c *Context) NewElementArrayBuffer(indices []uint16) Buffer {
|
|||||||
return buffer
|
return buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) BindElementArrayBuffer(b Buffer) {
|
func (c *Context) BindBuffer(bufferType BufferType, b Buffer) {
|
||||||
_ = c.runOnContextThread(func() error {
|
_ = c.runOnContextThread(func() error {
|
||||||
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, uint32(b))
|
gl.BindBuffer(uint32(bufferType), uint32(b))
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -366,9 +366,9 @@ func (c *Context) NewElementArrayBuffer(indices []uint16) Buffer {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) BindElementArrayBuffer(b Buffer) {
|
func (c *Context) BindBuffer(bufferType BufferType, b Buffer) {
|
||||||
gl := c.gl
|
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) {
|
func (c *Context) BufferSubData(bufferType BufferType, data []float32) {
|
||||||
|
@ -380,9 +380,9 @@ func (c *Context) NewElementArrayBuffer(indices []uint16) Buffer {
|
|||||||
return Buffer(b)
|
return Buffer(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) BindElementArrayBuffer(b Buffer) {
|
func (c *Context) BindBuffer(bufferType BufferType, b Buffer) {
|
||||||
gl := c.gl
|
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 {
|
func float32ToBytes(v []float32) []byte {
|
||||||
|
Loading…
Reference in New Issue
Block a user