#!/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 1 - The Basics"
. configure -background white
createframe .c1menubar 2 
# call procedure createframe and create a frame for the menus available
# in chapter1. we call this menu frame .c1menubar 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 .c1menubar.menu -text "Concepts" -underline 0 \
-menu .c1menubar.menu.conceptMenu

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

set m [ menu .c1menubar.menu.conceptMenu ]
# create an example menu on the menubar .c1menubar.menu and add options to it

$m add command -label "1 - Window Position"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept1.tk & ]
	procfile $pid c1Process
        displaytext "$pothome/CHAP1/TEXT_FILES/Concept1.txt"
	greentag .textdisplay 1.0 1.55
	redtag .textdisplay 3.0 3.55
	bluetag .textdisplay 6.0 6.55
	bluetag .textdisplay 13.0 13.55
	bluetag .textdisplay 22.0 22.55
	functag .textdisplay 9.12 9.40
	functag .textdisplay 19.0 19.24

}

$m add separator

$m add command -label "2 - Window Size"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept2.tk & ]
        procfile $pid c1Process
	displaytext "$pothome/CHAP1/TEXT_FILES/Concept2.txt"
	greentag .textdisplay 1.0 1.55
	redtag .textdisplay 3.0 3.55
	bluetag .textdisplay 6.0 6.55
	bluetag .textdisplay 13.0 13.55
	functag .textdisplay 9.12 9.40
      }

$m add separator

$m add command -label "3 - Window Title"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept3.tk & ]
        procfile $pid c1Process
	displaytext "$pothome/CHAP1/TEXT_FILES/Concept3.txt"
	greentag .textdisplay 1.0 1.55
	redtag .textdisplay 3.0 3.55
	bluetag .textdisplay 6.0 6.55
	bluetag .textdisplay 12.0 12.55
	bluetag .textdisplay 16.0 16.55
	functag .textdisplay 9.12 9.33
}

$m add separator

$m add command -label "4 - Background Color"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept4.tk & ]
        procfile $pid c1Process
	displaytext "$pothome/CHAP1/TEXT_FILES/Concept4.txt"
	greentag .textdisplay 1.0 3.55
	redtag .textdisplay 5.0 5.55
	bluetag .textdisplay 8.0 8.55
	functag .textdisplay 11.18 11.40
	bluetag .textdisplay 15.0 15.55
	bluetag .textdisplay 19.0 19.55
	functag .textdisplay 22.27 22.38
	bluetag .textdisplay 29.0 29.55
	functag .textdisplay 32.0 32.14
	functag .textdisplay 33.0 33.28

}

$m add separator

$m add command -label "5 - Object Color"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept5.tk & ]
        procfile $pid c1Process
	displaytext "$pothome/CHAP1/TEXT_FILES/Concept5.txt"
	greentag .textdisplay 1.0 2.55
	redtag .textdisplay 4.0 4.55
	bluetag .textdisplay 7.0 7.55
	functag .textdisplay 10.8 10.28
	bluetag .textdisplay 14.0 14.55
	bluetag .textdisplay 19.0 19.55
}

$m add separator

$m add command -label "6 - Coordinate System"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept6 &]
        procfile $pid c1Process
	displaytext "$pothome/CHAP1/TEXT_FILES/Concept6.txt"
	greentag .textdisplay 1.0 2.55
	redtag .textdisplay 4.0 4.55
	bluetag .textdisplay 7.0 7.55
	bluetag .textdisplay 19.0 19.55
	}


$m add separator
$m add command -label "7 - Drawing Objects"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept7.tk & ]
        procfile $pid c1Process
	displaytext "$pothome/CHAP1/TEXT_FILES/Concept7.txt"
	greentag .textdisplay 1.0 1.55
	redtag .textdisplay 3.0 3.55
	bluetag .textdisplay 6.0 6.55
	bluetag .textdisplay 11.0 11.55
	bluetag .textdisplay 23.0 23.55
}


$m add separator

$m add command -label "8 - Absolute/Relative Units"\
	-command {catch {exec kill $pid}
        killprocess c1Process
	set pid [exec $pothome/CHAP1/PROG_FILES/Concept8.tk & ]
        procfile $pid c1Process
	displaytext "$pothome/CHAP1/TEXT_FILES/Concept8.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
	underlinetag .textdisplay 26.19 26.33
	
}


$m add separator

$m add command -label "9 - The OpenGL Program Structure" \
		-command { catch {exec kill $pid}
                           killprocess c1Process
			set pid [ exec $pothome/CHAP1/PROG_FILES/OglFlow.tk & ]
                           procfile $pid c1Process
			   displaytext "$pothome/CHAP1/TEXT_FILES/OglFlow.txt"
			   greentag .textdisplay 1.0 2.55
			   redtag .textdisplay 4.0 4.55
			   bluetag .textdisplay 10.0 10.55
			   bluetag .textdisplay 46.0 46.55
			   bluetag .textdisplay 60.0 60.55
			   bluetag .textdisplay 83.0 83.55
			   bluetag .textdisplay 105.0 105.55
			   functag .textdisplay 15.5 15.37
			   functag .textdisplay 16.44 16.55
			   functag .textdisplay 19.5 19.44
			   functag .textdisplay 26.5 26.42
			   functag .textdisplay 30.5 30.45
			   functag .textdisplay 33.5 33.40
			   functag .textdisplay 37.14 37.46
			   functag .textdisplay 40.5 40.19
			   functag .textdisplay 53.5 53.19
			   functag .textdisplay 63.10 63.20
			   functag .textdisplay 65.5 65.33
			   functag .textdisplay 69.5 69.27
			   functag .textdisplay 72.5 72.36
			   functag .textdisplay 75.5 75.36
			   functag .textdisplay 79.5 79.14
			   functag .textdisplay 91.0 94.0
			   functag .textdisplay 108.30 108.50
			   functag .textdisplay 113.15 113.34
			   functag .textdisplay 118.8 118.20
			   functag .textdisplay 123.44 123.54
			   functag .textdisplay 124.9 124.16
    }

$m add separator
$m add command -label "10 - My Program"\
	-command { catch {exec kill $pid}
		   killprocess c1Process
                   set pid [exec $pothome/CHAP1/PROG_FILES/MyProg.tk &]
                    
                   procfile $pid c1Process
		   displaytext "$pothome/CHAP1/TEXT_FILES/MyProg.txt"
		   greentag .textdisplay 1.0 1.55
		   bluetag .textdisplay 3.0 3.55
   }
		  

button .c1menubar.unpack -relief flat -text "Unpack" -underline 0 
		
button .c1menubar.pack -relief flat -text "Pack" -underline 0 
	
button .c1menubar.exit -relief flat -text "Exit" -underline 1 \
	-command {
		     catch { exec kill $pid }
                     killprocess c1Process
		     catch {  send main wm deiconify . }
                     exit}


pack .c1menubar.menu .c1menubar.unpack .c1menubar.pack .c1menubar.exit -side left

bind .c1menubar.unpack <1> {
set cwd [ pwd ]
cd $pothome/CHAP1/PROG_FILES

catch { exec make >& /dev/tty}
cd $cwd


}
bind .c1menubar.pack <1> {
set cwd [ pwd ]
cd $pothome/CHAP1/PROG_FILES
catch { exec make clean  >& /dev/tty }
cd $cwd
}
displaytext  "$pothome/CHAP1/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] }































































































