mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +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
|
return bf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) mapPixelBuffer(buffer buffer, t textureNative) uintptr {
|
func (c *context) mapPixelBuffer(buffer buffer) uintptr {
|
||||||
c.bindTexture(t)
|
|
||||||
var ptr uintptr
|
var ptr uintptr
|
||||||
_ = c.t.Call(func() error {
|
_ = c.t.Call(func() error {
|
||||||
gl.BindBuffer(gl.PIXEL_UNPACK_BUFFER, uint32(buffer))
|
gl.BindBuffer(gl.PIXEL_UNPACK_BUFFER, uint32(buffer))
|
||||||
@ -561,7 +560,8 @@ func (c *context) mapPixelBuffer(buffer buffer, t textureNative) uintptr {
|
|||||||
return ptr
|
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 {
|
_ = c.t.Call(func() error {
|
||||||
gl.UnmapBuffer(gl.PIXEL_UNPACK_BUFFER)
|
gl.UnmapBuffer(gl.PIXEL_UNPACK_BUFFER)
|
||||||
gl.TexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE, nil)
|
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.image = img
|
||||||
s.mappedPBO = img.driver.context.mapPixelBuffer(img.pbo, img.textureNative)
|
s.mappedPBO = img.driver.context.mapPixelBuffer(img.pbo)
|
||||||
|
|
||||||
if s.mappedPBO == 0 {
|
if s.mappedPBO == 0 {
|
||||||
panic("opengl: mapPixelBuffer failed")
|
panic("opengl: mapPixelBuffer failed")
|
||||||
@ -69,7 +69,7 @@ func (s *pboState) draw(pix []byte, x, y, width, height int) {
|
|||||||
|
|
||||||
func (s *pboState) unmapPBO() {
|
func (s *pboState) unmapPBO() {
|
||||||
i := s.image
|
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.image = nil
|
||||||
s.mappedPBO = 0
|
s.mappedPBO = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user