set Angle 0
set RenderTime 10
set Step 50

set tframe [frame .t]
set quitb [button $tframe.quit -width 10 -text "Quit" -command "destroy ."]
pack append $tframe $quitb {left pady 5}


set gframe [frame .g]
set gfx [glxwin $gframe.g  -width 400 -height 400 -rgb true -db true]
set s [scale $gframe.s -showvalue 0 -orient vertical -from 10 -to 500]

$s set $Step
$s config -command "set Step"

pack append  $gframe $gfx {left expand fill} $s {right filly}

pack append . $tframe {fillx} $gframe {expand fill}

bind $gfx <Map> {if [%W islinked] {gl-init}}
bind $gfx <Expose> gl-render
bind $gfx <Configure> {if [%W islinked] {glx_viewport %w %h}}


proc incr_ang {s} {
	global Angle
	set Angle [expr "($Angle + $s) % 3600"]
}

proc loop {} {
	global RenderTime gfx
	after $RenderTime {
		if [$gfx islinked] {
			incr_ang $Step
			gl-param angle $Angle
			gl-render
		}
		after $RenderTime loop
	}
}

wm minsize . 300 300
loop

