mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphicsdriver/opengl: Refactoring
This commit is contained in:
parent
3df198f68e
commit
4296c11256
@ -525,7 +525,8 @@ func (c *context) newPixelBufferObject(width, height int) buffer {
|
||||
return bf
|
||||
}
|
||||
|
||||
func (c *context) mapPixelBuffer(buffer buffer) unsafe.Pointer {
|
||||
func (c *context) mapPixelBuffer(buffer buffer, t textureNative) unsafe.Pointer {
|
||||
c.bindTexture(t)
|
||||
var ptr unsafe.Pointer
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BindBuffer(gl.PIXEL_UNPACK_BUFFER, uint32(buffer))
|
||||
@ -535,13 +536,9 @@ func (c *context) mapPixelBuffer(buffer buffer) unsafe.Pointer {
|
||||
return ptr
|
||||
}
|
||||
|
||||
func (c *context) unmapPixelBuffer(buffer buffer, t textureNative, width, height int) {
|
||||
func (c *context) unmapPixelBuffer(buffer buffer, width, height int) {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.UnmapBuffer(gl.PIXEL_UNPACK_BUFFER)
|
||||
return nil
|
||||
})
|
||||
c.bindTexture(t)
|
||||
_ = c.t.Call(func() error {
|
||||
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, int32(width), int32(height), 0, gl.RGBA, gl.UNSIGNED_BYTE, nil)
|
||||
gl.BindBuffer(gl.PIXEL_UNPACK_BUFFER, 0)
|
||||
return nil
|
||||
|
@ -42,7 +42,7 @@ func (s *pboState) mapPBO(img *Image) {
|
||||
img.pbo = img.driver.context.newPixelBufferObject(w, h)
|
||||
}
|
||||
s.image = img
|
||||
s.mappedPBO = img.driver.context.mapPixelBuffer(img.pbo)
|
||||
s.mappedPBO = img.driver.context.mapPixelBuffer(img.pbo, img.textureNative)
|
||||
|
||||
if s.mappedPBO == nil {
|
||||
panic("opengl: mapPixelBuffer failed")
|
||||
@ -68,7 +68,7 @@ func (s *pboState) draw(pix []byte, x, y, width, height int) {
|
||||
func (s *pboState) unmapPBO() {
|
||||
i := s.image
|
||||
w, h := graphics.InternalImageSize(i.width), graphics.InternalImageSize(i.height)
|
||||
i.driver.context.unmapPixelBuffer(i.pbo, i.textureNative, w, h)
|
||||
i.driver.context.unmapPixelBuffer(i.pbo, w, h)
|
||||
|
||||
s.image = nil
|
||||
s.mappedPBO = nil
|
||||
|
Loading…
Reference in New Issue
Block a user