| 
 | Generated by diff2html.pl © Yves Bailly, MandrakeSoft S.A. 2001, Ryohei Morita 2007 diff2html.pl is licensed under the GNU GPL. | 
| ../11-04/11-04-Rendering.c | 11-05-Rendering.c | |||
|---|---|---|---|---|
| 49 lines 1574 bytes Last modified : Mon Nov 19 18:44:45 2012 | 52 lines 1688 bytes Last modified : Mon Nov 19 19:00:56 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/19b kameda[at]iit.tsukuba.ac.jp | 6 | // 2012/11/19b kameda[at]iit.tsukuba.ac.jp | |
| 7 | // 11.04. ポリゴン表示 | 7 | // 11.05. ポリゴン表示・Depth付 | |
| 8 | 8 | |||
| 9 | #include "ic2-CommonHeaders.h" | 9 | #include "ic2-CommonHeaders.h" | |
| 10 | 10 | |||
| 11 | 11 | |||
| 12 | // *********************************************************************** | 12 | // *********************************************************************** | |
| 13 | // Rendering ************************************************************* | 13 | // Rendering ************************************************************* | |
| 14 | 14 | |||
| 15 | // +++-------------------------------------------------- | 15 | // +++-------------------------------------------------- | |
| 16 | // スクリーンに描画する | 16 | // スクリーンに描画する | |
| 17 | // +++-------------------------------------------------- | 17 | // +++-------------------------------------------------- | |
| 18 | 18 | |||
| 19 | // +---------------------------------------------------- | 19 | // +---------------------------------------------------- | |
| 20 | // 1フレーム分の描画 | 20 | // 1フレーム分の描画 | |
| 21 | // +---------------------------------------------------- | 21 | // +---------------------------------------------------- | |
| 22 | void ic2_DrawFrame (void) { | 22 | void ic2_DrawFrame (void) { | |
| 23 | // (1) 描画バッファの初期化 | 23 | // (1) 描画バッファの初期化 | |
| 24 | // 以前にglClearColor()で指定した色で塗り潰す | 24 | // 以前にglClearColor()で指定した色で塗り潰す | |
| 25 | glClear(GL_COLOR_BUFFER_BIT); | 25 | // depth buffer 初期化 | |
| 26 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||
| 27 | // depth test 有効化 | |||
| 28 | glEnable(GL_DEPTH_TEST); | |||
| 26 | 29 | |||
| 27 | // (2) カメラの設定 | 30 | // (2) カメラの設定 | |
| 28 | ic2_SetUpCamera_Perspective(); // 透視投影 | 31 | ic2_SetUpCamera_Perspective(); // 透視投影 | |
| 29 | 32 | |||
| 30 | // (3) 光源の設置 | 33 | // (3) 光源の設置 | |
| 31 | 34 | |||
| 32 | // (4) 物体の描画 | 35 | // (4) 物体の描画 | |
| 33 | glMatrixMode(GL_MODELVIEW); | 36 | glMatrixMode(GL_MODELVIEW); | |
| 34 | { | 37 | { | |
| 35 | static float roty = 0.0; // Y軸回りの回転 [degree] | 38 | static float roty = 0.0; // Y軸回りの回転 [degree] | |
| 36 | static float rotx = 0.0; | 39 | static float rotx = 0.0; | |
| 37 | glLoadIdentity(); | 40 | glLoadIdentity(); | |
| 38 | glTranslatef(0.0, 0.0, -3.0); // 透視投影の描画範囲と対応必要 | 41 | glTranslatef(0.0, 0.0, -3.0); // 透視投影の描画範囲と対応必要 | |
| 39 | glRotatef(roty-=1.0, 0, 1, 0); // Y軸回りの回転 | 42 | glRotatef(roty-=1.0, 0, 1, 0); // Y軸回りの回転 | |
| 40 | glRotatef(rotx+=2.0, 1, 0, 0); // X軸回りの回転 | 43 | glRotatef(rotx+=2.0, 1, 0, 0); // X軸回りの回転 | |
| 41 | //ic2_OpenGLLogo(logoscale); | 44 | //ic2_OpenGLLogo(logoscale); | |
| 42 | ic2_DrawModel(); | 45 | ic2_DrawModel(); | |
| 43 | if (roty <= -360.0) roty += 360.0; | 46 | if (roty <= -360.0) roty += 360.0; | |
| 44 | if (rotx >= +360.0) rotx -= 360.0; | 47 | if (rotx >= +360.0) rotx -= 360.0; | |
| 45 | } | 48 | } | |
| 46 | // (5) 描画バッファの切替 | 49 | // (5) 描画バッファの切替 | |
| 47 | glutSwapBuffers(); | 50 | glutSwapBuffers(); | |
| 48 | } | 51 | } | |
| 49 | 52 |