Modified lines:  7
Added line:  None
Removed line:  20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224
Generated by diff2html.pl
© Yves Bailly, MandrakeSoft S.A. 2001, Ryohei Morita 2007
diff2html.pl is licensed under the GNU GPL.

  ../07-01/07-01-Planning.c     07-02-CommonHeaders.h
  224 lines
8716 bytes
Last modified : Mon Nov 5 08:00:38 2012

    19 lines
730 bytes
Last modified : Mon Nov 5 07:56:51 2012

1 // Keisanki Joron 2 (Introduction to Computing II)   1 // Keisanki Joron 2 (Introduction to Computing II)
2 // Dept. of Engineering Systems, University of Tsukuba   2 // Dept. of Engineering Systems, University of Tsukuba
3 // [UTF-8 / Unix]   3 // [UTF-8 / Unix]
4 // 計算機序論2・実習 (筑波大学工学システム学類)   4 // 計算機序論2・実習 (筑波大学工学システム学類)
5   5
6 // 2012/11/05a kameda[at]iit.tsukuba.ac.jp   6 // 2012/11/05a kameda[at]iit.tsukuba.ac.jp
7 // 07.01. プログラムの構造設計   7 // 07.02. ファイル分割
8   8
9 // ***********************************************************************    9 // *********************************************************************** 
10 // CommonHeaders.h : common header files *********************************   10 // CommonHeaders.h : common header files *********************************
11   11
12 // +++--------------------------------------------------   12 // +++--------------------------------------------------
13 // どの部分ソースでも利用する可能性が高いライブラリ(関数)に   13 // どの部分ソースでも利用する可能性が高いライブラリ(関数)に
14 // 相当するヘッダファイル   14 // 相当するヘッダファイル
15 // +++--------------------------------------------------   15 // +++--------------------------------------------------
16   16
17 #include <stdio.h> // printf()   17 #include <stdio.h> // printf()
18 #include <GL/glut.h> // gl*(), glut*()   18 #include <GL/glut.h> // gl*(), glut*()
19   19
20 // ***********************************************************************       
21 // EmbededObjects ********************************************************      
22      
23 // +++--------------------------------------------------      
24 // ソース内部でのCG物体の直接描画      
25 // +++--------------------------------------------------      
26      
27 // +----------------------------------------------------      
28 // OpenGL Logoを描く      
29 // +----------------------------------------------------      
30 // s はスケーリングファクタ(s=1.0 で 概ね -1.0 〜 1.0 の大きさ)      
31 void ic2_OpenGLLogo (float s) {      
32 // 光源によるシェーディング効果を切る(と色の指定が直接色になる)      
33   glDisable(GL_LIGHTING);         
34      
35   // 線の幅(画素単位)      
36   glLineWidth(1.0);      
37      
38   // (R, G, B) 値域は 0.0 - 1.0      
39   glColor3f(1.0, 1.0, 1.0);      
40      
41   // glBegin(GL_LINES); から glEnd(); までの間は、      
42   // 「始点・終点」ごとに線分が描画される      
43   glBegin(GL_LINES);       
44   glVertex3f(s * -0.8, s *  0.8, 0.0); glVertex3f(s * -0.8, s *  0.2, 0.0); // O      
45   glVertex3f(s * -0.8, s *  0.2, 0.0); glVertex3f(s * -0.4, s *  0.2, 0.0); // O      
46   glVertex3f(s * -0.4, s *  0.2, 0.0); glVertex3f(s * -0.4, s *  0.8, 0.0); // O      
47   glVertex3f(s * -0.4, s *  0.8, 0.0); glVertex3f(s * -0.8, s *  0.8, 0.0); // O      
48      
49   glVertex3f(s * -0.2, s *  0.6, 0.0); glVertex3f(s * -0.2, s *  0.0, 0.0); // p      
50   glVertex3f(s * -0.2, s *  0.6, 0.0); glVertex3f(s *  0.0, s *  0.6, 0.0); // p      
51   glVertex3f(s *  0.0, s *  0.6, 0.0); glVertex3f(s *  0.0, s *  0.2, 0.0); // p      
52   glVertex3f(s *  0.0, s *  0.2, 0.0); glVertex3f(s * -0.2, s *  0.2, 0.0); // p      
53      
54   glVertex3f(s *  0.2, s *  0.4, 0.0); glVertex3f(s *  0.4, s *  0.4, 0.0); // e      
55   glVertex3f(s *  0.4, s *  0.4, 0.0); glVertex3f(s *  0.4, s *  0.6, 0.0); // e      
56   glVertex3f(s *  0.4, s *  0.6, 0.0); glVertex3f(s *  0.2, s *  0.6, 0.0); // e      
57   glVertex3f(s *  0.2, s *  0.6, 0.0); glVertex3f(s *  0.2, s *  0.2, 0.0); // e      
58   glVertex3f(s *  0.2, s *  0.2, 0.0); glVertex3f(s *  0.4, s *  0.2, 0.0); // e      
59      
60   glVertex3f(s *  0.6, s *  0.6, 0.0); glVertex3f(s *  0.6, s *  0.2, 0.0); // n      
61   glVertex3f(s *  0.6, s *  0.6, 0.0); glVertex3f(s *  0.8, s *  0.6, 0.0); // n      
62   glVertex3f(s *  0.8, s *  0.6, 0.0); glVertex3f(s *  0.8, s *  0.2, 0.0); // n      
63      
64   glVertex3f(s *  0.0, s * -0.2, 0.0); glVertex3f(s * -0.6, s * - 0.2, 0.0); // G      
65   glVertex3f(s * -0.6, s * -0.2, 0.0); glVertex3f(s * -0.6, s * - 0.8, 0.0); // G      
66   glVertex3f(s * -0.6, s * -0.8, 0.0); glVertex3f(s *  0.0, s * - 0.8, 0.0); // G      
67   glVertex3f(s *  0.0, s * -0.8, 0.0); glVertex3f(s *  0.0, s * - 0.5, 0.0); // G      
68   glVertex3f(s *  0.0, s * -0.5, 0.0); glVertex3f(s * -0.3, s * - 0.5, 0.0); // G      
69      
70   glVertex3f(s *  0.2, s * -0.2, 0.0); glVertex3f(s *  0.2, s * - 0.8, 0.0); // L      
71   glVertex3f(s *  0.2, s * -0.8, 0.0); glVertex3f(s *  0.8, s * - 0.8, 0.0); // L      
72   glEnd();      
73      
74   // glBegin(GL_LINE_LOOP); から glEnd(); までの間は、      
75   // 全ての頂点を使った閉じた線分が描画される      
76      
77   // 左上隅      
78   glColor3f(1.0, 1.0, 1.0);      
79   glBegin(GL_LINE_LOOP);      
80   glVertex3f(s * -1.0, s *  1.0, 0.0);      
81   glVertex3f(s * -0.8, s *  1.0, 0.0);      
82   glVertex3f(s * -1.0, s *  0.8, 0.0);      
83   glEnd();      
84         
85   // 右上隅      
86   glColor3f(0.1, 1.0, 1.0);      
87   glBegin(GL_LINE_LOOP);      
88   glVertex3f(s *  0.8, s *  1.0, 0.0);      
89   glVertex3f(s *  1.0, s *  1.0, 0.0);      
90   glVertex3f(s *  1.0, s *  0.8, 0.0);      
91   glEnd();      
92      
93   // 左下隅      
94   glColor3f(1.0, 0.1, 1.0);      
95   glBegin(GL_LINE_LOOP);      
96   glVertex3f(s * -1.0, s * -0.8, 0.0);      
97   glVertex3f(s * -0.8, s * -1.0, 0.0);      
98   glVertex3f(s * -1.0, s * -1.0, 0.0);      
99   glEnd();      
100      
101   // 右下隅      
102   glColor3f(1.0, 1.0, 0.1);      
103   glBegin(GL_LINE_LOOP);      
104   glVertex3f(s *  0.8, s * -1.0, 0.0);      
105   glVertex3f(s *  1.0, s * -0.8, 0.0);      
106   glVertex3f(s *  1.0, s * -1.0, 0.0);      
107   glEnd();      
108 }      
109      
110 // ***********************************************************************       
111 // Projection ************************************************************      
112      
113 // +++--------------------------------------------------      
114 // カメラの投影行列を設定      
115 // +++--------------------------------------------------      
116      
117 // +----------------------------------------------------      
118 // 直交投影      
119 // +----------------------------------------------------      
120 void ic2_SetUpCamera_Ortho (void) {      
121   // OpenGLのPROJECTION行列スタックにアクセス      
122   glMatrixMode(GL_PROJECTION);      
123      
124   // PROJECTION行列スタックトップを単位行列で初期化      
125   glLoadIdentity();       
126      
127   // 直交投影行列を生成するサポート関数 glOrtho を呼び出す      
128   // glOrtho(左端, 右端, 下端, 上端, 近接側クリッピング面,  遠方側クリッピング面)      
129   glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); //       
130 }      
131      
132 // ***********************************************************************       
133 // Rendering *************************************************************      
134      
135 // +++--------------------------------------------------      
136 // スクリーンに描画する      
137 // +++--------------------------------------------------      
138      
139 // +----------------------------------------------------      
140 // 1フレーム分の描画      
141 // +----------------------------------------------------      
142 void ic2_DrawFrame (void) {      
143   // (1) 描画バッファの初期化      
144   // 以前にglClearColor()で指定した色で塗り潰す      
145   glClear(GL_COLOR_BUFFER_BIT);      
146      
147   // (2) カメラの設定      
148   ic2_SetUpCamera_Ortho();      
149      
150   // (3) 光源の設置      
151      
152   // (4) 物体の描画      
153   ic2_OpenGLLogo(0.95);      
154      
155   // (5) 描画バッファの切替      
156   glutSwapBuffers();      
157 }      
158      
159 // ***********************************************************************       
160 // Callback **************************************************************       
161      
162 // +++--------------------------------------------------      
163 // GLUTでのイベント駆動型プログラミング      
164 // +++--------------------------------------------------      
165      
166 // +----------------------------------------------------      
167 // 「タイマー」で呼出し(繰り返すことで「一定間隔呼出し」化)      
168 // +----------------------------------------------------      
169 void ic2_timerhandler(int keynumber){      
170   glutPostRedisplay(); // OpenGLのmainloopに戻ったら再描画を頼む      
171   glutTimerFunc(250, ic2_timerhandler, 0); // 250[ms]後にまた呼び出す      
172 }      
173      
174 // ***********************************************************************       
175 // Initialization ********************************************************       
176      
177 // +++--------------------------------------------------      
178 // 初期化(主にGLUT)      
179 // +++--------------------------------------------------      
180      
181 // +----------------------------------------------------      
182 // OpenGLとしてのWindowの初期化      
183 // +----------------------------------------------------      
184 void ic2_BootWindow (char winname[]) {      
185      
186   // DisplayModeの設定(それぞれを|で繋ぐ)      
187   //   GLUT_DOUBLE ... ダブルバッファ      
188   //   GLUT_RGB    ... RGB表色モード      
189   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);       
190      
191   // 準備(Initialization)が済んだらウィンドウを開く      
192   glutCreateWindow(winname);      
193      
194   // Callback関数を設定 (イベント処理)      
195   glutDisplayFunc(ic2_DrawFrame); // フレームを(再)描画するために呼び出す関数      
196   glutTimerFunc(250, ic2_timerhandler, 0); // 250[ms]後に呼び出す関数      
197      
198   // ウィンドウ全体を書き直すときの色(R,G,B,0) ここでは黒      
199   glClearColor(0.0, 0.0, 0.0, 0.0);      
200 }      
201      
202 // ***********************************************************************       
203 // MainFunction **********************************************************       
204      
205 // +----------------------------------------------------      
206 // メイン関数など      
207 // +----------------------------------------------------      
208      
209 // +----------------------------------------------------      
210 // Main Function      
211 // +----------------------------------------------------      
212 int main (int argc, char *argv[]) {      
213      
214   // glutライブラリによる引数の解釈      
215   glutInit(&argc, argv);      
216      
217   // OpenGL Window の初期化      
218   ic2_BootWindow(argv[0]);      
219      
220   // 無限ループの開始      
221   glutMainLoop();      
222         
223   return 0;      
224 }      

Generated by diff2html.pl on Mon Nov 5 13:34:39 2012
Command-line:
/home/ubuntu/scripts/diff2html_utf.pl ../07-01/07-01-Planning.c 07-02-CommonHeaders.h