view samples/sdl.tp @ 284:99c18127da04

Add another SDL_RenderCopy binding in the form of copyRect:To
author Michael Pavone <pavone@retrodev.com>
date Tue, 22 Jul 2014 08:32:39 -0700
parents 0ec4f1b68a38
children b01d7c1b4edd
line wrap: on
line source

#{
	import: [
		video
		timer
	] from: (sdl subsystems)
	main <- {
		if: (sdl init: (video or timer)) = 0 {
			(sdl createWindow: "SDL Test" pos: 0 0 size: 640 480 flags: 0u32) value: :window {
				(window createRenderer: -1 flags: ((window renderOpts) accelerated)) value: :render {
					render drawColor!: (sdl r: 0u8 g: 0u8 b: 255u8)
					render clear
					(sdl loadBMP: "944.bmp") value: :surf {
						(surf asTexture: render) value: :tex {
							sdl clearError
							if: (tex copy) != 0 {
								print: "Failed to copy texture to renderer: " . (sdl getError) . "\n"
							}
							surf free
							tex copyTo: (sdl rect: 160 120 size: 320 224)
							tex copyRect: (sdl rect: 80 60 size: 160 120) To: (sdl rect: 40 30 size: 320 224)
							render present
							sdl delay: 3000u32
							tex destroy
						} none: {
							surf free
						}
					} none: {
					}
					render destroy
				} none: {
					print: "Failed to create renderer\n"
				}
				window destroy
			} none: {
				print: "Failed to create window\n"
				1
			}
		} else: {
			print: "Failed to initialize SDL\n"
			1
		}
	}
}