Placing screen rendering on pause as well.

This commit is contained in:
Rob Greene 2020-03-15 10:41:00 -05:00 committed by Iván Izaguirre
parent da7bb3ebf7
commit 01099a8ce3
1 changed files with 25 additions and 23 deletions

View File

@ -76,31 +76,33 @@ func SDLRun(a *apple2.Apple2) {
paused = a.IsPaused() paused = a.IsPaused()
} }
img := apple2.Snapshot(a) if !a.IsPaused() {
if img != nil { img := apple2.Snapshot(a)
surface, err := sdl.CreateRGBSurfaceFrom(unsafe.Pointer(&img.Pix[0]), if img != nil {
int32(img.Bounds().Dx()), int32(img.Bounds().Dy()), surface, err := sdl.CreateRGBSurfaceFrom(unsafe.Pointer(&img.Pix[0]),
32, 4*img.Bounds().Dx(), int32(img.Bounds().Dx()), int32(img.Bounds().Dy()),
0x0000ff, 0x0000ff00, 0x00ff0000, 0xff000000) 32, 4*img.Bounds().Dx(),
// Valid for little endian. Should we reverse for big endian? 0x0000ff, 0x0000ff00, 0x00ff0000, 0xff000000)
// 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff) // Valid for little endian. Should we reverse for big endian?
// 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff)
if err != nil { if err != nil {
panic(err) panic(err)
}
texture, err := renderer.CreateTextureFromSurface(surface)
if err != nil {
panic(err)
}
renderer.Clear()
w, h := window.GetSize()
renderer.Copy(texture, nil, &sdl.Rect{X: 0, Y: 0, W: w, H: h})
renderer.Present()
surface.Free()
texture.Destroy()
} }
texture, err := renderer.CreateTextureFromSurface(surface)
if err != nil {
panic(err)
}
renderer.Clear()
w, h := window.GetSize()
renderer.Copy(texture, nil, &sdl.Rect{X: 0, Y: 0, W: w, H: h})
renderer.Present()
surface.Free()
texture.Destroy()
} }
sdl.Delay(1000 / 30) sdl.Delay(1000 / 30)
} }