I have an SDL2 go program which tries to write a pixel array to the screen. When I try and update the texture with the new pixels the program panics with a runtime error:
fatal error: unexpected signal during runtime execution
Unfortunately I can find little to no documentation about how to pass around unsafe pointers in Go and I'm not sure if I'm approaching this correctly, here is some example code that exhibits the problem:
func main() {
window := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
800, 600, sdl.WINDOW_SHOWN)
renderer := sdl.CreateRenderer(window, -1, 0)
texture := sdl.CreateTexture(renderer, sdl.PIXELFORMAT_ARGB8888,
sdl.TEXTUREACCESS_STATIC, 800, 600)
defer renderer.Destroy()
defer texture.Destroy()
defer window.Destroy()
for {
pixels := make([]uint32, 800*600)
texture.Update(nil, unsafe.Pointer(&pixels), int(800*unsafe.Sizeof(pixels)))
window.UpdateSurface()
renderer.Clear()
renderer.Copy(texture, nil, nil)
renderer.Present()
}
sdl.Delay(1000)
sdl.Quit()
}
This code will compile with no errors, but when ran it will produce a runtime panic, but I can't see what would cause that in this code.
I am using these SDL2 Go bindings: https://github.com/veandco/go-sdl2