Exemple #1
0
func (d *Display) routine() {
	rect := C.SDL_Rect{x: 0, y: 0, w: C.Uint16(d.width), h: C.Uint16(d.height)}
	for d.rendering {
		frame := <-d.frame
		C.SDL_LockYUVOverlay(d.overlay)
		pixels := (*[1 << 30]*C.Uint8)(unsafe.Pointer(d.overlay.pixels))
		pitches := (*[1 << 30]C.Uint8)(unsafe.Pointer(d.overlay.pitches))
		pixels[0] = (*C.Uint8)(frame.data[0])
		pixels[1] = (*C.Uint8)(frame.data[1])
		pixels[2] = (*C.Uint8)(frame.data[2])
		pitches[0] = (C.Uint8)(frame.linesize[0])
		pitches[1] = (C.Uint8)(frame.linesize[1])
		pitches[2] = (C.Uint8)(frame.linesize[2])
		C.SDL_UnlockYUVOverlay(d.overlay)
		C.SDL_DisplayYUVOverlay(d.overlay, &rect)
	}
}
Exemple #2
0
// Blit a video overlay to the display surface.
// The contents of the video surface underneath the blit destination are
// not defined.
// The width and height of the destination rectangle may be different from
// that of the overlay, but currently only 2x scaling is supported.
func DisplayYUVOverlay(overlay *C.SDL_Overlay, dstrect *C.SDL_Rect) int {
	return int(C.SDL_DisplayYUVOverlay(overlay, dstrect))
}