aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-12-30 11:39:05 +1000
committerSteve Bennett <steveb@workware.net.au>2021-01-01 16:54:24 +1000
commit3b834e42ee5887f85d10d7e50814b29d1b81a09f (patch)
tree7458adbd80a56028addff1b879d726187d4fe81b /examples
parent982ec4f524bc81a240cb729cf09bd3c677aea485 (diff)
downloadjimtcl-3b834e42ee5887f85d10d7e50814b29d1b81a09f.zip
jimtcl-3b834e42ee5887f85d10d7e50814b29d1b81a09f.tar.gz
jimtcl-3b834e42ee5887f85d10d7e50814b29d1b81a09f.tar.bz2
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 <steveb@workware.net.au>
Diffstat (limited to 'examples')
-rw-r--r--examples/sdltest.tcl28
1 files changed, 28 insertions, 0 deletions
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
+ }
+ }
+}