From 3b834e42ee5887f85d10d7e50814b29d1b81a09f Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Wed, 30 Dec 2020 11:39:05 +1000 Subject: sdl: Add support for SDL2 Now we only support using pkg-config to find SDL, and prefer SDL2 over SDL. For compatibility between versions, the render surface is now cleared on flip. And closing the window now results in a JIM_EXIT return code from flip. Also supports [sdl clear] to clear the background to a given colour. Signed-off-by: Steve Bennett --- examples/sdltest.tcl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/sdltest.tcl (limited to 'examples') diff --git a/examples/sdltest.tcl b/examples/sdltest.tcl new file mode 100644 index 0000000..6607574 --- /dev/null +++ b/examples/sdltest.tcl @@ -0,0 +1,28 @@ +package require sdl + +set xres 1024 +set yres 768 +set s [sdl.screen $xres $yres] + +proc drawlist {s list} { + foreach item $list { + $s {*}$item + } +} + +proc rand_circle {xres yres maxradius alpha} { + list fcircle [rand $xres] [rand $yres] [rand $maxradius] [rand 256] [rand 256] [rand 256] $alpha +} + +loop i 0 200 { + set commands {} + loop j 0 1000 { + lappend commands [rand_circle $xres $yres 40 100] + if {$j % 50 == 0} { + #$s clear 200 200 200 + drawlist $s $commands + $s flip + sleep 0.1 + } + } +} -- cgit v1.1