mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
graphicsdriver/opengl: Use uintptr whenever possible instead of unsafe.Pointer
This commit is contained in:
parent
4296c11256
commit
0ef8009c11
@ -22,7 +22,6 @@ package opengl
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl/gl"
|
||||
@ -525,9 +524,9 @@ func (c *context) newPixelBufferObject(width, height int) buffer {
|
||||
return bf
|
||||
}
|
||||
|
||||
func (c *context) mapPixelBuffer(buffer buffer, t textureNative) unsafe.Pointer {
|
||||
func (c *context) mapPixelBuffer(buffer buffer, t textureNative) uintptr {
|
||||
c.bindTexture(t)
|
||||
var ptr unsafe.Pointer
|
||||
var ptr uintptr
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BindBuffer(gl.PIXEL_UNPACK_BUFFER, uint32(buffer))
|
||||
ptr = gl.MapBuffer(gl.PIXEL_UNPACK_BUFFER, gl.READ_WRITE)
|
||||
|
@ -626,9 +626,9 @@ func LinkProgram(program uint32) {
|
||||
C.glowLinkProgram(gpLinkProgram, (C.GLuint)(program))
|
||||
}
|
||||
|
||||
func MapBuffer(target uint32, access uint32) unsafe.Pointer {
|
||||
func MapBuffer(target uint32, access uint32) uintptr {
|
||||
ret := C.glowMapBuffer(gpMapBuffer, (C.GLenum)(target), (C.GLenum)(access))
|
||||
return (unsafe.Pointer)(ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
func PixelStorei(pname uint32, param int32) {
|
||||
|
@ -271,9 +271,9 @@ func IsTexture(texture uint32) bool {
|
||||
return ret != 0
|
||||
}
|
||||
|
||||
func MapBuffer(target uint32, access uint32) unsafe.Pointer {
|
||||
func MapBuffer(target uint32, access uint32) uintptr {
|
||||
ret, _, _ := syscall.Syscall(gpMapBuffer, 2, uintptr(target), uintptr(access), 0)
|
||||
return unsafe.Pointer(ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
func LinkProgram(program uint32) {
|
||||
|
@ -30,7 +30,7 @@ const canUsePBO = true
|
||||
|
||||
type pboState struct {
|
||||
image *Image
|
||||
mappedPBO unsafe.Pointer
|
||||
mappedPBO uintptr
|
||||
mapped []byte
|
||||
}
|
||||
|
||||
@ -44,13 +44,13 @@ func (s *pboState) mapPBO(img *Image) {
|
||||
s.image = img
|
||||
s.mappedPBO = img.driver.context.mapPixelBuffer(img.pbo, img.textureNative)
|
||||
|
||||
if s.mappedPBO == nil {
|
||||
if s.mappedPBO == 0 {
|
||||
panic("opengl: mapPixelBuffer failed")
|
||||
}
|
||||
|
||||
var mapped []byte
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&mapped))
|
||||
sh.Data = uintptr(s.mappedPBO)
|
||||
sh.Data = s.mappedPBO
|
||||
sh.Len = 4 * w * h
|
||||
sh.Cap = 4 * w * h
|
||||
s.mapped = mapped
|
||||
@ -71,6 +71,6 @@ func (s *pboState) unmapPBO() {
|
||||
i.driver.context.unmapPixelBuffer(i.pbo, w, h)
|
||||
|
||||
s.image = nil
|
||||
s.mappedPBO = nil
|
||||
s.mappedPBO = 0
|
||||
s.mapped = nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user