Use []byte instead of unsafe.Pointer
This commit is contained in:
parent
8b0dcc549f
commit
0206cd3cd6
1 changed files with 5 additions and 5 deletions
|
@ -112,7 +112,7 @@ func (i *Image) ToImage() image.Image {
|
||||||
// Get pixel data from image (RGBA 32bit)
|
// Get pixel data from image (RGBA 32bit)
|
||||||
pixels := GetImageData(i)
|
pixels := GetImageData(i)
|
||||||
|
|
||||||
img.Pix = (*[1 << 30]uint8)(pixels)[:]
|
img.Pix = pixels
|
||||||
|
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
@ -284,10 +284,10 @@ func UnloadRenderTexture(target RenderTexture2D) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetImageData - Get pixel data from image
|
// GetImageData - Get pixel data from image
|
||||||
func GetImageData(image *Image) unsafe.Pointer {
|
func GetImageData(image *Image) []byte {
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
ret := C.GetImageData(*cimage)
|
ret := C.GetImageData(*cimage)
|
||||||
return unsafe.Pointer(ret)
|
return (*[1 << 30]uint8)(unsafe.Pointer(ret))[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextureData - Get pixel data from GPU texture and return an Image
|
// GetTextureData - Get pixel data from GPU texture and return an Image
|
||||||
|
@ -299,9 +299,9 @@ func GetTextureData(texture Texture2D) *Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateTexture - Update GPU texture with new data
|
// UpdateTexture - Update GPU texture with new data
|
||||||
func UpdateTexture(texture Texture2D, pixels unsafe.Pointer) {
|
func UpdateTexture(texture Texture2D, pixels []byte) {
|
||||||
ctexture := texture.cptr()
|
ctexture := texture.cptr()
|
||||||
cpixels := (unsafe.Pointer)(unsafe.Pointer(pixels))
|
cpixels := unsafe.Pointer(&pixels[0])
|
||||||
C.UpdateTexture(*ctexture, cpixels)
|
C.UpdateTexture(*ctexture, cpixels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue