view samples/sdl.tp @ 287:b01d7c1b4edd

Add binding for simple form of SDL_RenderCopyEx
author Michael Pavone <pavone@retrodev.com>
date Tue, 22 Jul 2014 18:39:00 -0700
parents 99c18127da04
children 38bbbf74b735
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)
							tex copyTo: (sdl rect: 320 240 size: 320 224) rotated: 45.0
							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
		}
	}
}