mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphicsdriver/opengl: Reduce calls of glBindTexture
This commit is contained in:
parent
8285fbfac9
commit
815afe6670
@ -548,8 +548,7 @@ func (c *context) newPixelBufferObject(width, height int) buffer {
|
||||
return bf
|
||||
}
|
||||
|
||||
func (c *context) mapPixelBuffer(buffer buffer, t textureNative) uintptr {
|
||||
c.bindTexture(t)
|
||||
func (c *context) mapPixelBuffer(buffer buffer) uintptr {
|
||||
var ptr uintptr
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BindBuffer(gl.PIXEL_UNPACK_BUFFER, uint32(buffer))
|
||||
@ -561,7 +560,8 @@ func (c *context) mapPixelBuffer(buffer buffer, t textureNative) uintptr {
|
||||
return ptr
|
||||
}
|
||||
|
||||
func (c *context) unmapPixelBuffer(buffer buffer, width, height int) {
|
||||
func (c *context) unmapPixelBuffer(buffer buffer, t textureNative, width, height int) {
|
||||
c.bindTexture(t)
|
||||
_ = c.t.Call(func() error {
|
||||
gl.UnmapBuffer(gl.PIXEL_UNPACK_BUFFER)
|
||||
gl.TexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE, nil)
|
||||
|
@ -44,7 +44,7 @@ func (s *pboState) mapPBO(img *Image) {
|
||||
}
|
||||
|
||||
s.image = img
|
||||
s.mappedPBO = img.driver.context.mapPixelBuffer(img.pbo, img.textureNative)
|
||||
s.mappedPBO = img.driver.context.mapPixelBuffer(img.pbo)
|
||||
|
||||
if s.mappedPBO == 0 {
|
||||
panic("opengl: mapPixelBuffer failed")
|
||||
@ -69,7 +69,7 @@ func (s *pboState) draw(pix []byte, x, y, width, height int) {
|
||||
|
||||
func (s *pboState) unmapPBO() {
|
||||
i := s.image
|
||||
i.driver.context.unmapPixelBuffer(i.pbo, i.width, i.height)
|
||||
i.driver.context.unmapPixelBuffer(i.pbo, i.textureNative, i.width, i.height)
|
||||
|
||||
s.image = nil
|
||||
s.mappedPBO = 0
|
||||
|
Loading…
Reference in New Issue
Block a user