#!/usr/bin
set pothome /mnt/dd3/ebook/tech/opengl/pot
source /mnt/dd3/ebook/tech/opengl/pot/tkheader.h
tk_bisque
wm geometry . 600x300$winX$winY
##############################################################################
# The following procedure creates a screen for chapter 1 of the tutorial.

wm title . "Chapter 5 - Lighting"
. configure -background white
createframe .c5menubar 2 
# call procedure createframe and create a frame for the menus available
# in chapter5. we call this menu frame .c5menubar and give it a width
# of 2 units.
   
createtextwidget "-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" blue white 0 0 nw


menubutton .c5menubar.menu -text "Concepts" -underline 0 \
-menu .c5menubar.menu.conceptMenu

# next we create a menubutton in this frame (.c5menubar) and call it
# .c5menubar.menu.  We also assign it some text - Concepts and 
# underline the letter C.

set m [	menu .c5menubar.menu.conceptMenu ]
# create an topic menu on the menubar .c3menubar.menu and add options to it

$m add command -label "1 - What's the difference"\
               -command {catch {exec kill $pid }
               catch {exec kill $pid1 }
               killprocess c5Process	
               set pid [exec $pothome/CHAP5/PROG_FILES/Sphere.tk &]
               procfile $pid c5Process
               displaytext "$pothome/CHAP5/TEXT_FILES/Sphere.txt"
               greentag .textdisplay 1.0 1.55
               redtag .textdisplay 3.0 4.55
               bluetag .textdisplay 7.0 7.55
               bluetag .textdisplay 15.0 15.55
               functag .textdisplay 18.0 18.55
               functag .textdisplay 19.0 19.55
               functag .textdisplay 28.0 28.55
               functag .textdisplay 30.0 30.55

}

$m add separator

$m add command -label "2 - Hidden Surface Removal"\
               -command { catch { exec kill $pid }
               catch { exec kill $pid1}
               killprocess c5Process	
               set pid [exec $pothome/CHAP5/PROG_FILES/SurfRemove.tk &]
               procfile $pid c5Process
               displaytext "$pothome/CHAP5/TEXT_FILES/HiddenSurf.txt"
               greentag .textdisplay 1.0 2.55
               redtag .textdisplay 4.0 4.55
               bluetag .textdisplay 7.0 7.55
               bluetag .textdisplay 18.0 18.55
               bluetag .textdisplay 30.0 30.55
               functag .textdisplay 40.0 40.55
               functag .textdisplay 43.0 43.55
               functag .textdisplay 46.0 46.55
}
$m add separator
$m add cascade -label "3 - Real vs. OGL Lighting" -menu $m.theoryMenu
set m1 [ menu $m.theoryMenu]
$m1 add command -label "3.1 - Introduction"\
                -command { catch { exec kill $pid }
	        catch { exec kill $pid1}
                killprocess c5Process	
	        displaytext "$pothome/CHAP5/TEXT_FILES/Introduction.txt"
                greentag .textdisplay 1.0 3.55
                redtag .textdisplay 5.0 5.55
                
               
}
$m1 add separator
$m1 add command -label "3.2 - Ambient Light"\
	        -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/Ambient.tk &]
               procfile $pid c5Process
	        displaytext "$pothome/CHAP5/TEXT_FILES/Ambient.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 21.0 21.55
                functag .textdisplay 17.0 18.55

}
$m1 add separator
$m1 add command -label "3.3 - Diffuse Light"\
	        -command { catch { exec kill $pid }
	        catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/Diffuse.tk &]
               procfile $pid c5Process
	        displaytext "$pothome/CHAP5/TEXT_FILES/Diffuse.txt"
                greentag .textdisplay 1.0 1.55
                redtag .textdisplay 3.0 3.55
                bluetag .textdisplay 6.0 6.55
                functag .textdisplay 14.0 15.55

}
$m1 add separator
$m1 add command -label "3.4 - Specular Light"\
                -command { catch { exec kill $pid }
	        catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/Specular.tk &]
               procfile $pid c5Process
	        displaytext "$pothome/CHAP5/TEXT_FILES/Specular.txt"
	        greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
	        bluetag .textdisplay 15.0 15.55
                functag .textdisplay 121.0 22.55

}
$m1 add separator
$m1 add command -label "3.5 - Light Position"\
                -command { catch { exec kill $pid }
                catch {exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/Position.tk &]
               procfile $pid c5Process
                displaytext "$pothome/CHAP5/TEXT_FILES/Position.txt"
                greentag .textdisplay 1.0 1.55
                redtag .textdisplay 3.0 3.55
                bluetag .textdisplay 6.0 6.55
                functag .textdisplay 8.0 9.55
                bluetag .textdisplay 18.0 18.55
}

$m add separator
$m add cascade -label "4 - Material Properties" -menu $m.materialMenu
set m2 [ menu $m.materialMenu ]
$m2 add command -label "4.1 - Introduction"\
                -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
	        displaytext "$pothome/CHAP5/TEXT_FILES/MaterialColor.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
}

$m2 add separator
$m2 add command -label "4.2 - Material Ambience"\
                -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/MAmbient.tk &]
               procfile $pid c5Process
	        displaytext "$pothome/CHAP5/TEXT_FILES/MAmbient.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                functag .textdisplay 9.0 10.55
}

$m2 add separator
$m2 add command -label "4.3 - Material Diffusivity"\
                -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
	        set pid [exec $pothome/CHAP5/PROG_FILES/MDiffuse.tk &]
               procfile $pid c5Process
                displaytext "$pothome/CHAP5/TEXT_FILES/MDiffuse.txt"
                greentag .textdisplay 1.0 3.55
                redtag .textdisplay 5.0 5.55
                bluetag .textdisplay 8.0 8.55
                functag .textdisplay 10.0 11.60
}

$m2 add separator
$m2 add command -label "4.4 - Material Specularity"\
                -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/MSpecular.tk &]
               procfile $pid c5Process
	        displaytext "$pothome/CHAP5/TEXT_FILES/MSpecular.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                functag .textdisplay 9.0 10.60
}

$m2 add separator
$m2 add command -label "4.5 - Material Shininess"\
                -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/MShininess.tk &]
               procfile $pid c5Process
	        displaytext "$pothome/CHAP5/TEXT_FILES/MShininess.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                functag .textdisplay 9.0 10.60
                functag .textdisplay 15.0 15.12
}

$m2 add separator
$m2 add command -label "4.6 - Material Emissivity"\
                -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/MEmissivity.tk &]
               procfile $pid c5Process
	        displaytext "$pothome/CHAP5/TEXT_FILES/MEmissivity.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                functag .textdisplay 9.0 10.60
                
}
$m add separator
$m add command -label "5 - Color Values - Light/Materials"\
                -command { catch { exec kill $pid }
                catch { exec kill $pid1}
               killprocess c5Process	
	        displaytext "$pothome/CHAP5/TEXT_FILES/ColorValues.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 12.0 12.55
                bluetag .textdisplay 31.0 31.55

}

$m add separator
$m add command -label "6 - A Light Module"\
               -command {catch {exec kill $pid }
               catch { exec kill $pid1 }
               killprocess c5Process	
               set pid [exec $pothome/CHAP5/PROG_FILES/LightModule.tk & ]
               procfile $pid c5Process
               displaytext "$pothome/CHAP5/TEXT_FILES/LightModule.txt"
               greentag .textdisplay 1.0 2.55
               redtag .textdisplay 4.0 4.55
}

$m add separator

$m add cascade -label "7 - More Light Details" -menu $m.positionMenu
set m3 [ menu $m.positionMenu ]
$m3 add command -label "7.1 - Position & Attenuation" \
		-command { catch {exec kill $pid}
                catch { exec kill $pid1}
               killprocess c5Process	
                displaytext "$pothome/CHAP5/TEXT_FILES/PositionTheory.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 20.0 20.55
                bluetag .textdisplay 34.0 34.55
                functag .textdisplay 26.0 26.12 
                functag .textdisplay 53.0 55.55
                functag .textdisplay 59.0 59.11
                functag .textdisplay 61.0 63.55
}
$m3 add separator
$m3 add command -label "7.2 - Stationary Lights" \
		-command { catch {exec kill $pid}
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/Stationary.tk & ]
               procfile $pid c5Process
                displaytext "$pothome/CHAP5/TEXT_FILES/Stationary.txt"
                greentag .textdisplay 1.0 3.55
                redtag .textdisplay 5.0 5.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 14.0 14.55


 }
$m3 add separator
$m3 add command -label "7.3 - Independent Light Movement"\
	        -command {catch {exec kill $pid}
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/independent &]
               procfile $pid c5Process
                displaytext "$pothome/CHAP5/TEXT_FILES/independent.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
         
 }
$m3 add separator
$m3 add command -label "7.4 - Moving Light with Viewpoint"\
	        -command {catch {exec kill $pid}
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [exec $pothome/CHAP5/PROG_FILES/vlight.tk &]
               procfile $pid c5Process
                displaytext "$pothome/CHAP5/TEXT_FILES/vlight.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
 }

$m add separator

$m add cascade -label "8 - Spotlight & Multiple Lights" -menu $m.spotMenu
set m4 [menu $m.spotMenu ]

$m4 add command -label "8.1 - Theory" \
	        -command {catch {exec kill $pid}
                catch { exec kill $pid1}
               killprocess c5Process	
               procfile $pid c5Process
                displaytext "$pothome/CHAP5/TEXT_FILES/SpotTheory.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 44.0 44.55
                functag .textdisplay 30.0 30.14
                functag .textdisplay 33.14 33.30
                functag .textdisplay 40.0 40.16
               
 }
$m4 add separator
$m4 add command  -label "8.2 - A second light source" \
                 -command {catch {exec kill $pid}
                 catch { exec kill $pid1}
               killprocess c5Process	
                 set pid [exec $pothome/CHAP5/PROG_FILES/secondlight &]
               procfile $pid c5Process
                 displaytext "$pothome/CHAP5/TEXT_FILES/secondlight.txt"
                 greentag .textdisplay 1.0 2.55
                 redtag .textdisplay 4.0 4.55
                 bluetag .textdisplay 7.0 7.55
                 bluetag .textdisplay 16.0 16.55
                 bluetag .textdisplay 47.0 47.55

}


$m add separator
$m add cascade -label "9 - Normal Vectors" -menu $m.normalMenu
set m5 [menu $m.normalMenu]
$m5 add command -label "9.1 - Declaring Normal Vectors"\
                 -command {catch {exec kill $pid}
                 catch { exec kill $pid1}
               killprocess c5Process	
                 displaytext "$pothome/CHAP5/TEXT_FILES/normal.txt"
                 greentag .textdisplay 1.0 2.55
                 redtag .textdisplay 4.0 4.55
                 bluetag .textdisplay 11.0 11.55
                 bluetag .textdisplay 35.0 35.55
                 bluetag .textdisplay 43.0 43.55
                 bluetag .textdisplay 55.0 55.55
                 bluetag .textdisplay 82.0 82.55
                 bluetag .textdisplay 94.0 94.55
                 bluetag .textdisplay 144.0 144.55
                 bluetag .textdisplay 208.0 208.55
}
$m5 add separator
$m5 add command -label "9.2 - An Example - Affect on Lighting"\
	        -command {catch {exec kill $pid}
                catch { exec kill $pid1}
               killprocess c5Process	
                set pid [ exec $pothome/CHAP5/PROG_FILES/normals &]
                set pid1 [ exec $pothome/CHAP5/PROG_FILES/normals1 &]
               procfile $pid c5Process
               procfile $pid1 c5Process
                displaytext "$pothome/CHAP5/TEXT_FILES/normallight.txt"
                redtag .textdisplay 4.0 4.55
                greentag .textdisplay 1.0 2.55
                bluetag .textdisplay 28.0 28.55
                bluetag .textdisplay 69.0 69.55
}

button .c5menubar.unpack -relief flat -text "Unpack" -underline 0 
		
button .c5menubar.pack -relief flat -text "Pack" -underline 0 

      
button .c5menubar.exit -relief flat -text "Exit" -underline 1 \
	        -command {
		catch { exec kill $pid }
		catch { exec kill $pid1}
               killprocess c5Process	
		catch { send main wm deiconify . }
                exit}
pack .c5menubar.menu .c5menubar.unpack .c5menubar.pack .c5menubar.exit -side left

bind .c5menubar.unpack <1> {
set cwd [ pwd ]
cd $pothome/CHAP5/PROG_FILES
catch { exec make >& /dev/tty }
cd $cwd


}
bind .c5menubar.pack <1> {
set cwd [ pwd ]
cd $pothome/CHAP5/PROG_FILES
catch { exec make clean  >& /dev/tty }
cd $cwd
}



displaytext  "$pothome/CHAP5/TEXT_FILES/Main.txt" 
greentag .textdisplay 1.0 2.55
redtag .textdisplay 4.0 4.55 



#set $cmd {lappend pid_list [expr 1 * $pid]} 
#send Tutorial.tk {eval $cmd }
#send Tutorial.tk {lappend pid_list  [expr 1 * $pid] }
































































































