func (renderer *SDLRenderer) addUpdatedRect(rect *sdl.Rect) {
	visibleX, visibleY := renderer.transformToVisibleXY(int(rect.X), int(rect.Y))
	visibleRect := sdl.Rect{int16(visibleX), int16(visibleY), rect.W, rect.H}

	if visibleRect.Y > int16(renderer.height) {
		visibleRect.Y = int16(renderer.height)
	}
	if visibleRect.Y < 0 {
		visibleRect.Y = 0
	}
	if visibleRect.H > uint16(renderer.height) {
		visibleRect.H = uint16(renderer.height)
	}

	renderer.updatedRects = append(renderer.updatedRects, visibleRect)
}
Example #2
0
func apply_surface(x, y int16, src, dest *sdl.Surface) {
	var offset sdl.Rect

	offset.X = x
	offset.Y = y

	dest.Blit(&offset, src, nil)
}