$B7W;;5!=xO@#2!J#2#0#1#1G/EY!K

$B7W;;5!=xO@#2(B, $B, www.kameda-lab.org 2011/11/21f

$B%j%s%/(B

$B!&(BOpenGL(ver.2.1)$B$N3F4X?t(B($B>.J8;z$N(Bgl$B$N#2J8;z$G;O$^$k4X?t(B)$B$N@bL@(B
$B!&(BOpenGL$B$N(BProgramming Guide Book (ver1.1, $BDL>N@VK\(B)


8. $BD>8rEj1F(B


8.1 OpenGL$B$K$*$1$kD>8rEj1F$NL@<(E*;XDj(B

$B$3$l$^$G$N(B(6$B@a(B,7$B@a$^$G$N(B)$B%W%m%0%i%`$G$O!"7k2LE*$KEj1FJ}K!$H$7$FD>8rEj1F$N7A$K$J$C$F$$$^$7$?!#(B
$B$7$+$7!"$3$l$O@5<0$J(BOpenGL$B$NEj1F!J6u4V$N;#A|LL$X$N$BK\@a$+$i$O!"(BOpenGL$B$K$h$kD>8rEj1F$N;XDj$rL@<(E*$K%W%m%0%i%`>e$G9T$&$h$&$K$7$^$9!#(B
glOrtho()$B4X?t$rMQ$$$F!"(BPROJECTION$B9TNs%9%?%C%/%H%C%W$KD>8rEj1F$rOpenGL$B$K$h$kEj1F;XDj$NFCD'$H$7$F!"%/%j%C%T%s%06u4V(B($B;#1FLL$KIA2h$9$k6u4V$NHO0O(B)$B$r;XDj$9$k$3$H$,5s$2$i$l$^$9!#(B

$B!ZDj<02=![(B
pcamp = Portho M Plocal
pcamp = Portho Pcamera
$B$3$3$G(B Portho $B$OD>8rEj1F$rpcamp $B$O;#A|LL(B(camera plane)$BCf$N:BI8$rI=8=$9$k108-1-Ortho.c
106-6$B$+$i$N:9J,(B

ic2_showMATRIX()$B$H$$$&4X?t$G!"$=$N;~E@$N(BMODELVIEW$B9TNs%9%?%C%/%H%C%W$H!"(BPROJECTIOn$B9TNs%9%?%C%/%H%C%W$H$N>uBV$rI=<($G$-$^$9!#(B
$B$3$3$GCm0U$9$k$Y$-$J$N$O(B3$B9T(B3$BNsL\$NMWAG$,(B-1$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$^$9!#(B
ic2PATCH$B9=B$BN$N(Blinked list$B$O(Bfirstmodelptr$B$G<($5$l$k%"%I%l%9$+$i3+;O$5$l$^$9!#(B
ic2PATCH$B9=B$BN$K$O(Bic2POINT$B9=B$BN#3$D$H(Bic2COLOR$B9=B$BN#1$D$,4^$^$l$^$9!#(B

109-4-ReadModel.c
109-3$B$+$i$N:9J,(B


10. $B%b%G%k%G!<%?$NFI$_9~$_$HI=<((B

$B$$$h$$$h!J$d$C$H!K%b%G%k$rFI$_9~$s$GI=<($^$G$r$7$F$_$^$7$g$&!#(B
$B!JK\Ev$O$3$NA0$K%=!<%9J,3d$r$7$F$*$-$?$+$C$?$N$G$9$,!"%=!<%9I=<($NET9gEy$GC10l%U%!%$%k$N$^$^$G$9!E!K(B
$B!J$"$^$jIaDL$N?M$K?d>)$9$k%3!<%I$N=q$-J}$G$O$"$j$^$;$s!E!K(B


10.1 $B%U%!%$%k$NE}9g(B

108-3-ViewpointCentering.c$B$H(B 109-4-ReadModel.c$B$H$r%Y!<%9$K$7$^$9!#(B
$B8e110-1-MergedSource.c
109-4$B$+$i$N:9J,(B


10.2 $B4{Dj5AJ*BN$N(BOn/Off

$B0\?"[email protected]$7$^$7$?$+!)(B
$B$G$b2?$bJQ$o$j$^$;$s$M!)(B
$B$b$7$+$7$?$i$b$H$+$iIA$$$F$$$k(BTeapot$B$,$B$3$N:]$J$N$G!"I=<($7$?$jHsI=<($K$7$?$j$G$-$k$h$&$K$7$^$7$g$&!#(B

110-2-MergedSource.c
110-1$B$+$i$N:9J,(B


10.3 $B%b%G%k$NFI$_9~$_$HI=<((B

$B9M$($F$_$l$P!"FI$_9~$s$@I=<($r$9$k$h$&$J%W%m%0%i%_%s%0$r$^$@$7$F$J$$$N$G!"(BTeapot$B$r>C$7$?$H$3$m$G0UL#$J$$$G$9$M!J5$$E$$$F$?!)!K!#(B
$BFI$_9~$s$@J*BN%b%G%k$r$H$K$b$+$/$K$bI=<($5$;$k$h$&$K$7$^$7$g$&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