manual.dvi

Size: px
Start display at page:

Download "manual.dvi"

Transcription

1 ' & VR CompleXcope $ % { {6 1) kage@tokitheorynifsacjp 2) sato@tokitheorynifsacjp

2 CompleXcope Programming Guide, Ver 1, by A Kageyama and T Sato, August 1998

3 1 CompleXcope 5 11 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 12 CompleXcope : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 13 CompleXcope : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 6 14 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 7 2 OpenGL 9 21 OpenGL : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9 22 Web : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : OpenGL : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : OpenGL : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : OpenGL : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : OpenGL : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : aux : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : glu library : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : aux library : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 57 3

4 4 232 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 60 3 CAVE CompleXcope : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : CAVE : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : CAVE : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Conguration File : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : CompleXcope : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : CAVE : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : CompleXcope : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 94 A CAVE 95 B OpenGL 97 C C (diff f c) 101 C1 C : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 101 C2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 102 C3 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 103 C4 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 103 C5 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 104 C6 if : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 104 C7 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 104 C8 for : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 106 C9 while : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 106 C10 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 107 C11 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 108 C12 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 110 D 113 D1 : : : : : : : : : : : : : : : : : : : : : : : : 113 D2 x2texture : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 113

5 1 CompleXcope 11 ( ) AVS (VR) VR VR VR (Head Mounted Display, HMD) (Univ Illinois, Chicago) Electronic Visualization Laboratory (EVL) 1 CAVE VR VR 1996 ( ) CAVE CAVE 1997 CAVE VR (complex) CompleXcope 12 CompleXcope CompleXcope 10 ( ) ( 1 5

6 6 CompleXcope ) CompleXcope CAVE ( ) ( ) ( ) ( ) cm CompleXcope CompleXcope CAVE CompleXcope 13 CompleXcope CAVE CAVE EVL CAVE UNIX VR CompleXcope CAVE 1 2 ( ) 3 ( ) 4 CompleXcope OpenGL 2 OpenGL CompleXcope OpenGL CAVE OpenGL CAVE CompleXcope 2 Iris GL Open Inventor, Iris Performer

7 OpenGL CAVE CompleXcope \ " 14 CompleXcope CompleXcope OpenGL CG CompleXcope OpenGL OpenGL CG CompleXcope OpenGL ( ) OpenGL CG CompleXcope \ OpenGL " AVS OpenGL AVS CAVE library OpenGL CAVE library ( ) Web CAVE library (OpenGL ) OpenGL CompleXcope X ( ) CompleXcope CAVE library Appendix A CAVE Appendix B OpenGL CompleXcope C( C++) Fortran C Appendix C Fortran C C C Appendix D ( ) pict gif

8 8 CompleXcope

9 2 OpenGL 21 OpenGL OpenGL 1 SGI (Silicon Graphics, Inc) GL OpenGL ARB (Architecture Review Board) OpenGL (CG) (1) (2) (3) ( ) (4) (5) (6) ( ) (7) CG (1) (5) OpenGL (6) (7) OpenGL (7) OpenGL OpenGL 120 OpenGL X Window Macintosh Windows95/NT Be OpenGL CG OpenGL CG CompleXcope CompleXcope X Window OpenGL X Window OpenGL glut library[1] M Kilgard OpenGL glut library aux library 2 1 \OpenGL" \Open GL" 2 Xlib Motif Tcl/Tk 9

10 10 OpenGL \aux" aux library CompleXcope (7) CAVE library CAVE library \CAVE" CompleXcope aux library (5) ( ) CompleXcope ( ) OpenGL CompleXcope CAVE CAVE OpenGL 22 Web OpenGL \OpenGL Programming Guide" [2, 3] 1993 [4, 5] 1997 aux library glut library OpenGL OpenGL OpenGL \OpenGL Reference Manual" [6] OpenGL man OpenGL (R) (B) (G) glut \OpenGL Programming for the X Window System"[1] OpenGL [7] OpenGL OpenGL OpenGL WEB OpenGL Japan OpenGL FAQ OpenGL Mesa Mesa Avid Technology, Inc Brian Paul 23 OpenGL OpenGL ( ) X

11 24 OpenGL 11 aux library glu library glx library glut library `aux' aux library `glu' X Window `glx' X Window OpenGL `glut' aux library glu library glx glut 24 OpenGL simplec aux library OpenGL OpenGL z =0 1: #include <GL/glh> 2: #include "auxh" 3: 4: main() { 5: 6: auxinitdisplaymode (AUX_SINGLE AUX_RGB); 7: auxinitposition (0, 0, 500, 500); 8: auxinitwindow ("simplec"); 9: 10: glclearcolor (00, 00, 00, 00); 11: glclear(gl_color_buffer_bit); 12: glcolor3f(10, 10, 10); 13: glmatrixmode (GL_PROJECTION); 14: glloadidentity (); 15: glortho(-10, 10, -10, 10, -10, 10); 16: glbegin(gl_polygon); 17: glvertex3f(-05, -05, 00); 18: glvertex3f(-05, 05, 00); 19: glvertex3f( 05, 05, 00); 20: glvertex3f( 05, -05, 00); 21: glend(); 22: glflush(); 23: sleep (10); 24:

12 12 OpenGL OpenGL include 3 OpenGL OpenGL (CompleXcope )OpenGL aux library include aux library OpenGL CompleXcope include main aux library (1) (2) RGB RGB Red, Green, Blue (0,0) (500, 500) (X Window ) +x +y auxinitwindow() \gl" OpenGL glclearcolor() R, G, B, A 0 1 A Alpha RGBA 0 color buer depth buer stencil buer (R; G; B) =(1:0; 1:0; 1:0) glortho() ( ) (glbegin glend ) glbegin() GL_POLYGON x,y,z (-05, -05, 00) glend() glflush() 4 (OpenGL ) C (glflush ) ( ) sleep(10) 10 sleep 3 /usr/local/include/gl/glh 4 OpenGL

13 25 OpenGL OpenGL OpenGL \gl" ( \glclearcolor") \GL_" \glcolor3f()" ( \3f") 3 \glcolor4f()" \3f" \f" oat \3f" OpenGL b 8 GLbyte i 32 GLint f 32 GLfloat d 64 GLdouble C int oat GLint GLoat OpenGL OpenGL \v" \v" ( ) OpenGL float color_array[] = {00, 00, 10; /* */ glcolor3f(10, 10, 00); /* */ glcolor3fv(color_array); /* */ 26 OpenGL OpenGL \ " \ " \ " \ " \ " \glcolor3f" \simplec" 16 glbegin() 21 glend() \draw_rectangle()"

14 14 OpenGL glcolor3f(10, 10, 10); draw_rectangle(); /* */ glcolor3f(10, 00, 00); draw_rectangle(); /* */ draw_rectangle(); /* */ glcolor3f(10, 10, 00); draw_rectangle(); /* */ glcolor3f() \ " \ " 27 OpenGL (vertex) z = simple2c #include <GL/glh> #include <mathh> /* (sin, cos) */ #include "auxh" main() { float pi; float x0, x1, x2, x3, x4, x5; float y0, y1, y2, y3, y4, y5; auxinitdisplaymode (AUX_SINGLE AUX_RGB); auxinitposition (0, 0, 500, 500);

15 27 15 auxinitwindow ("simple2c"); glclearcolor (00, 00, 00, 00); /* */ glclear (GL_COLOR_BUFFER_BIT); /* */ glcolor3f(00, 10, 00); /* */ glpointsize (50); /* 5 */ glmatrixmode (GL_PROJECTION); glloadidentity (); glortho (-15, 15, -15, 15, -15, 15); /* */ pi = ; x0 = cos(0*pi/3); y0 = sin(0*pi/3); x1 = cos(1*pi/3); y1 = sin(1*pi/3); x2 = cos(2*pi/3); y2 = sin(2*pi/3); x3 = cos(3*pi/3); y3 = sin(3*pi/3); x4 = cos(4*pi/3); y4 = sin(4*pi/3); x5 = cos(5*pi/3); y5 = sin(5*pi/3); glbegin(gl_points); glvertex3f(x0, y0, 00); /* o o */ glvertex3f(x1, y1, 00); /* */ glvertex3f(x2, y2, 00); /* o o */ glvertex3f(x3, y3, 00); /* */ glvertex3f(x4, y4, 00); /* o o */ glvertex3f(x5, y5, 00); /* */ glend(); glflush(); sleep (10); n end of simple2c / \glbegin" \glend" \glvertex()" glbegin glend glbegin(gl_points); for (i=0; i<6; i++) { x = cos(i*pi/3); y = sin(i*pi/3); glvertex3f(x, y, 00); glend(); simple3c

16 16 OpenGL #include <GL/glh> #include <mathh> /* (sin, cos) */ #include "auxh" main() { float pi, x, y; int i; auxinitdisplaymode (AUX_SINGLE AUX_RGB); auxinitposition (0, 0, 500, 500); auxinitwindow ("simple3c"); glclearcolor (00, 00, 00, 00); /* */ glclear (GL_COLOR_BUFFER_BIT); /* */ glcolor3f(00, 10, 00); /* */ glpointsize (50); /* 5 */ glmatrixmode (GL_PROJECTION); glloadidentity (); glortho (-15, 15, -15, 15, -15, 15); /* */ pi = ; glbegin(gl_points); for (i=0; i<6; i++) { x = cos(i*pi/3); y = sin(i*pi/3); glvertex3f(x, y, 00); glend(); glflush(); sleep (10); n end of simple3c / \glbegin()" \GL_POINTS" \GL_POLYGON"

17 simple4c #include <GL/glh> #include <mathh> #include "auxh" main() { int i; float pi, x, y; auxinitdisplaymode (AUX_SINGLE AUX_RGB); auxinitposition (0, 0, 500, 500); auxinitwindow ("simple4c"); glclearcolor (00, 00, 00, 00); /* */ glclear (GL_COLOR_BUFFER_BIT); /* */ glcolor3f(00, 10, 00); /* */ glmatrixmode (GL_PROJECTION); glloadidentity (); glortho (-15, 15, -15, 15, -15, 15); /* */ pi = ; glbegin(gl_polygon); /* <---- */ for (i=0; i<6; i++) { x = cos(i*pi/3); y = sin(i*pi/3); glvertex3f(x, y, 00); glend(); glflush(); sleep (10); n end of simple4c / GL_POLYGON GL_POLYGON 28 \glbegin()" \GL_POINTS" \GL_POLYGON" \GL_POLYGON" \GL_POLYGON" v0, v1,, v7 x y z

18 18 OpenGL float v0[] = {-10, -10, -10; float v1[] = { 10, -10, -10; /* v4 v5 */ glbegin(gl_polygon); /* */ glvertex3fv(v0); /* / / */ glvertex3fv(v1); /* v v7 */ glvertex3fv(v3); /* v3 / */ glvertex3fv(v2); /* / */ glend(); /* */ /* v0 v1 */ glbegin(gl_polygon); glvertex3fv(v2); glvertex3fv(v3); glvertex3fv(v5); glvertex3fv(v4); glend(); /* glbegin() glend() */ \GL_POLYGON" GL_POINTS GL_LINES GL_POLYGON GL_TRIANGLES GL_QUADS GL_LINE_STRIP GL_LINE_LOOP GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUAD_STRIP glbegin() 5 5 \ " \ " :::

19 28 19 v0 v0 v2 v1 v2 x / / / v3 / v3 x x v1 / / v1 v0 x v2 v4 v5 v3 GL_POINTS GL_LINES GL_LINE_STRIP v2 v3 v2 v3 v0 v1 / v1 / v /+++/ v5 \ /+++/ v4 v5 /\ \++++/ v v0 / \ v4 \++/ v3 v2 /++++++/ \/ GL_LINE_LOOP v0 v7 v6 GL_POLYGON GL_QUADS v1 v3 v5 v6 v0 v \+++++/ v5 v4 / / \+++/ ++++/ / / \+/ +++/ / / + ++/ v1 +/ v0 v2 v4 v5 v3 / GL_QUAD_STRIP GL_TRIANGLES v4 v3 v v1 v3 v5 \ /+\ v \ /+++\ /+\+++++/+\+++++/ \ /+++/ /+++\+++/+++\+++/ \++ ++/++/ /+++++\+/+++++\+/ \+ +/+/ \ // v0 v2 v4 v0 GL_TRIANGLE_STRIP GL_TRIANGLE_FAN glbegin() glend() glvertex3f glvertex3fv(v0), glvertex3fv(v1), glvertex3fv(v2), glvertex3fv(v3), 111 glbegin()

20 20 OpenGL glbegin(gl_quad_strip); glvertex3fv(v0); glvertex3fv(v1); glvertex3fv(v2); glvertex3fv(v3); glvertex3fv(v4); glvertex3fv(v5); glvertex3fv(v6); glvertex3fv(v7); glvertex3fv(v0); glvertex3fv(v1); glend(); glbegin(gl_quads); glvertex3fv(v0); glvertex3fv(v4); glvertex3fv(v1); glvertex3fv(v5); glend(); glvertex3fv(v2); glvertex3fv(v6); glvertex3fv(v3); glvertex3fv(v7); 29 3 CG 1 2 ( ) 3 OpenGL OpenGL 2 CG 6 OpenGL OpenGL 6

21 CG OpenGL ( ) 210 OpenGL 8 o=================================== 36 o======================== 24 o================== 18 o============== 14 o=========== 11 depth buffer 3D OBJECT o========= 9 o======== 8 o======== 8 o========= 9 (depth buer) 9 (= ) (OBJ-X ) OBJ-X ( ) OBJ-X 10 (1) OBJ-X (P ) D (2) P (I,J) (3) (I,J) D D ( P ) P D 7 \ " 8 9 Z 10

22 22 OpenGL o x=========== 36 --> 11 o x============ 24 --> 12 o----x============= 18 --> 13 X============== 14 X o=========== 11 OBJ-X X o========= 9 X o======== 8 X o======== 8 X o========= 9 OpenGL ( ) glenable(gl_depth_test); ( OFF )GL_DEPTH_TEST ON glenable() OpenGL ON 11 ( ) glclear(gl_depth_buffer_bit) ( ) ( ) glclear(gl_color_buffer_bit); glclear(gl_depth_buffer_bit); glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glenable() glclear() aux library auxinitdisplaymode ( simplec (p11) ) (AUX_SINGLE AUX_RGB AUX_DEPTH) 11 glenable(gl FOG) ( ) ON glenable(gl LIGHTING) ON (p25)

23 ON glnormal3f(); ( ) glnormal3fv(); 3 ( (2) ) (1) (2) 1 (3) float n0[] = {00, 00, 10; /* */ float n1[] = {00, 00, 10; /* */ float n2[] = {00, 00, 10; /* */ float v0[] = {10, 00, 00; /* */ float v1[] = {00, 00, 00; /* */ float v2[] = {00, 15, 00; /* */ glbegin(gl_poylgon); /* n1 */ glnormal3fv(n0); /* n0 */ glvertex3fv(v0); /* */ glnormal3fv(n1); /* + n2 */ glvertex3fv(v1); /* + */ glnormal3fv(n2); /* */ glvertex3fv(v2); /* + */ glend(); sqrt() glnormal OpenGL

24 24 OpenGL OpenGL ( ) OpenGL OpenGL CompleXcope o ( ) o o OFF glcolor CompleXcope \ " ( ) ( ) \ " CompleXcope (\Welcome to CompleXcope" )

25 o glcolor ( ) o ( ) 2122 OpenGL glenable(gl_ligthting); glenable(gl_ligtht0); glenable() OpenGL ON glenable() ON OpenGL glenable(gl_light0) 0 glenable(gl_ligthting); glenable(gl_ligtht0); glenable(gl_ligtht1); ( ) (GL_LIGHT0 ) ( ) OpenGL o o RGB o ( ) o o ( RGB ) o o RGB o RGB CG \ "

26 26 OpenGL 2123 (ambient light) 14 RGB \ / \ / \ / ---- OBJ ---- / \ / \ / \ (diuse light) ( ) ( ) ~s ~n ~s ~n ( ) ~s ~n ( ) 15 \ / \ / -- S S -- / \ / \ / / / / / / / / / / / / / / / / ( ) ( )

27 (specular light) ~s ~n ~v ~s + ~v ~n \ / V1 ( ) -- S -- / \ V2 ( ) / / V3 ( ) / / / / / / CG CG (0; 0; 0) 1 ( ) +z 16 x +1 ( ) 17 ( ) \ " (0; 0; 1) (1; 0; 0) (x < 0) ( ) ( ) ( ) \ " ( ) 16 OpenGL 17 OpenGL

28 28 OpenGL ( ) ( ) ( ) (CompleXcope ) OpenGL 0 1( ) gllightf() gllightfv() GLfloat light_position[] = {100, 50, 30, 10; /* */ gllightfv(gl_light0, GL_POSITION, light_position); glenable(gl_lighting); /* ON */ glenable(gl_light0); /* 0 ON */ ( light_position ) x; y; z 1:0 x; y; z gllightfv() (lx; ly; lz; lw) (lx=lw; ly=lw; lz=lw) 00 (lx; ly; lz) OpenGL 00 10

29 GLfloat light_position[] = {100, 50, 30, 00; /* */ GLfloat light_diffuse[] = {10, 10, 10, 00; /* */ GLfloat light_ambient[] = {03, 03, 03, 00; /* */ GLfloat light_specular[] = {08, 08, 08, 00; /* */ gllightfv(gl_light0, GL_POSITION, light_position); /* */ gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); /* */ gllightfv(gl_light0, GL_SPECURAR, light_specular); /* */ gllightfv(gl_light0, GL_AMBIENT, light_ambient); /* */ glenable(gl_lighting); /* ON */ glenable(gl_light0); /* 0 ON */ 213 (R,G,B) glmaterialfv() ( ) ( ) GLfloat light_position[] = {100, 50, 30, 00; /* */ GLfloat light_diffuse[] = {10, 10, 10, 00; GLfloat light_ambient[] = {03, 03, 03, 00; GLfloat light_specular[] = {08, 08, 08, 00; GLfloat ball_1_diffuse[] = {10, 00, 00, 00; /* 1 */ GLfloat ball_1_ambient[] = {10, 00, 00, 00; GLfloat ball_1_specular[] = {08, 08, 08, 00; GLfloat ball_2_diffuse[] = {00, 10, 00, 00; /* 2 */

30 30 OpenGL GLfloat ball_2_ambient[] = {00, 10, 00, 00; GLfloat ball_2_specular[] = {00, 00, 00, 00; gllightfv(gl_light0, GL_POSITION, light_position); /* */ gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); /* */ gllightfv(gl_light0, GL_SPECURAR, light_specular); /* */ gllightfv(gl_light0, GL_AMBIENT, light_ambient); /* */ glenable(gl_lighting); /* ON */ glenable(gl_light0); /* 0 ON */ glenable(gl_depth_test); /* ( ) ON */ glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); /* */ /* */ glmaterialfv(gl_front, GL_DIFFUSE, ball_1_diffuse); glmaterialfv(gl_front, GL_AMBIENT, ball_1_amnient); glmaterialfv(gl_front, GL_SPECULAR, ball_1_specular); glmaterialf(gl_front, GL_SHININESS, 1100); /* */ make_ball_1(); /* */ /* */ glmaterialfv(gl_front, GL_DIFFUSE, ball_2_diffuse); glmaterialfv(gl_front, GL_AMBIENT, ball_2_amnient); glmaterialfv(gl_front, GL_SPECULAR, ball_2_specular); make_ball_2(); GL_SHININESS glmaterialfv() glmaterialf() ( 1100)

31 (a) ( )x(r,g,b) (b) (c) OpenGL ( ) (1) (a)-(c) RGB (2) RGB ( ) ( ) 215 OpenGL CG OpenGL \ " ( ) AVS CG OpenGL X Window 21 aux aux 216 aux aux (auxinitdisplaymode ) (auxinitwindow) OpenGL 19 aux auxwiresphere(gldouble radius); auxsolidsphere(gldouble radius); Wire Solid Wire Solid 19

32 32 OpenGL auxwirecube(gldouble size); auxsolidcube(gldouble size); auxwirebox(gldouble width, GLdouble height, GLdouble depth); auxsolidbox(gldouble width, GLdouble height, GLdouble depth); auxwiretorus(gldouble minorradius, GLdouble majorradius); auxsolidtorus(gldouble minorradius, GLdouble majorradius); auxwirecylinder(gldouble radius, GLdouble height); auxsolidcylinder(gldouble radius, GLdouble height); auxwirecone(gldouble radius); auxsolidcone(gldouble radius); auxwiretetrahedron(gldouble radius); auxsolidtetrahedron(gldouble radius); auxwireoctahedron(gldouble radius); auxsolidoctahedron(gldouble radius); auxwiredodecahedron(gldouble radius); auxsoliddodecahedron(gldouble radius); auxwireicosahedron(gldouble radius); auxsolidicosahedron(gldouble radius);

33 217 glu library 33 auxwireteapot(gldouble size); auxsolidteapot(gldouble size); "auxh" include 217 glu library aux aux \ " ( ) glu glu glu GLUquadricObj* glunewquadric(void); \Quadric" glu library 2 a 1 x 2 + a 2 y 2 + a 3 z 2 + a 4 xy + a 5 yz + a 6 zx + a 7 x + a 8 y + a 9 z + a 10 =0 glu ( a 1 a 10 ) gluneqquadric glu void glusphere(gluquadricobj *qobj, GLdouble radius, GLinit slices, GLint stacks); glunewquadric slices stacks glu void glucylinder(gluquadricobj *qobj, GLdouble baseradius, GLdouble topradius, GLdouble height, GLinit slices, GLint stacks); glu void gludisk(gluquadricobj *qobj, GLdouble innerradius, GLdouble outerradius, GLinit slices, GLint stacks);

34 34 OpenGL OpenGL Programming Gluid, Second Edition [4], p431 glusphere (Xballc; p72) 218 (viewing) CG CG CG \ " x{y z ( ) x{y \ " x v OpenGL ( t = 0 ) t x = vt (glvertex3f x vt \( ) " OpenGL (x; y; z; w) w

35 ( ) ( ) OpenGL <-----> <-----> v(x,y,z,w) M v 0 = Mv v 0 P v 00 = Pv 0 = PMv v 00 (x; y; z; x) CG 21 (x; y; z) x y z z ' 0 1 C A cos ' 0 sin ' 0 0 sin ' cos ' gluperspective(f,aspect,znear,zfarr) 0 1 C A cot (f=2) aspect cot (f=2) zFar3zNear znear0zfar zfar+znear 0 0 znear0zfar C A 219 x{y \F" F \ " x=20 21 OpenGL

36 36 OpenGL y y= x x=0 x=20 (x=0) F F \ " drawf() drawf(): (` ') x=0, y=0 F y=0 x=0 drawf() x=20 F (1) (2) OpenGL (1) (2) K' - - K" -

37 gltranslatef(glfloat x, GLfloat y, GLfloat z) gltranslatef(200, 00, 00) K x 20 K' ' y y' y= x x' x=0 x=20 glrotatef(glfloat angle, GLfloat axis_y, GLfloat axis_y, GLfloat axis_z) glrotatef(300, 00, 00, 10) z 30 x-y 030: = 330:0 K' (K ) z " y x" y= x y" x=0 x=20 K"

38 38 OpenGL x=20 F (1) K" (2) K" y" F K" drawf() 1 x 20 K' 2 z +90 K" 3 K" F OpenGL glpushmatrix(); gltranslatef(200, 00, 00); glrotatef(900, 00, 00, 10); drawf(); glpopmatrix(); glpushmatrix glpopmatrix ( ) ( ) CompleXcope CompleXcope 23 CompleXcope CAVE library 24 void gluortho(gldouble left, GLdouble right, GLdouble top, GLdouble bottom, GLdouble near, GLdouble far); CompleXcope 24

39 z 0z void gluperspective(gldouble fovy, GLdouble aspect, GLdouble znear, GLdouble zfar); 25 (0,0,0) 0z fovy fovy=2 fovy=2 (0 fovy 180:0) aspect / (0; 0; 0) (0; 0; 0) z ( ) gluperspective fovy aspect zfar zfar zfar znear ( ) zfar \ " znear zfar 221 CompleXcope CAVE library X Window OpenGL CG OpenGL OpenGL - gluperspective - z -z - 26 glviewport aux library Window aux library X Window OpenGL \ " 25 glu library OpenGL glu 26

40 40 OpenGL 222 ( ) z 05 auxwireteapot (p31) (0; 0:0) 0z 5 OpenGL 0z gluperspective znear zfar 3:0 10: wire teapotc /* * wire_teapotc \* An OpenGL sample program - A wire teapot by the aux library - No lighting - Perspective view by the glu library - No animation */ #include <GL/glh> #include <GL/gluh> #include "auxh" void display (void) { glclear(gl_color_buffer_bit); glcolor3f (10, 10, 10); glpushmatrix(); gltranslatef (00, 00, -50); auxwireteapot(10); /* */ glpopmatrix(); glflush(); void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 100;

41 223 aux library 41 glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char** argv) { auxinitdisplaymode (AUX_SINGLE AUX_RGB); auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); auxreshapefunc (reshape); auxmainloop(display); n end of wire teapotc / 223 aux library wire teapotc aux library main auxinitdisplaymode ( ) auxinitdisplaymode(aux_single AUX_RGB); ( CG ) [ ] auxinitdisplaymode(aux_single AUX_RGB AUX_DEPTH); ( 27 ) ( CG ) [ ] auxinitdisplaymode(aux_double AUX_RGB AUX_DEPTH); auxinitposition auxinitwindow 27 ( 229 )

42 42 OpenGL auxinitposition(glint x, GLint y, GLsize width, GLsize height) (x; y) ( ) (width; height) ( ) auxinitwindow(glbyte *titlestring) auxreshapefunc(void (*function)(glsizei, GLsizei)) auxreshapefuc function function auxmainloop(void (*displayfunc)(void)) ( ) displayfunc 224 ( ) torusc

43 224 ( ) 43 /* * torusc \* An OpenGL sample program - A torus by the aux library - With the lighting - Perspective view by the glu library - No animation */ #include <GL/glh> #include <GL/gluh> #include "auxh" void initial(void) { GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glenable(gl_lighting); glenable(gl_light0); gldepthfunc(gl_less); glenable(gl_depth_test); void display (void) { GLfloat mat_diffuse[] = { 10, 10, 10, 10 ; GLfloat mat_ambient[] = { 01, 01, 01, 10 ; GLfloat mat_specular[] = { 09, 09, 09, 10 ; glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); glmaterialfv(gl_front, GL_DIFFUSE, mat_diffuse); glmaterialfv(gl_front, GL_AMBIENT, mat_ambient); glmaterialfv(gl_front, GL_SPECULAR, mat_specular); glmaterialf (GL_FRONT, GL_SHININESS, 640); glpushmatrix(); gltranslatef (00, 00, -50); auxsolidtorus(02,10); /* */ glpopmatrix(); glflush(); void reshape(int width, int height) {

44 44 OpenGL GLdouble ang = 600; GLdouble near = 30; GLdouble far = 100; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char **argv) { auxinitdisplaymode (AUX_SINGLE AUX_RGB AUX_DEPTH); auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxmainloop(display); n end of torusc / 45 torus2c gltranslate 76 (2; 1; 09) /* * torus2c \* An OpenGL sample program - Two tori (see torusc) - No animation */

45 224 ( ) 45 #include <GL/glh> #include <GL/gluh> #include "auxh" void initial(void) { GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glenable(gl_lighting); glenable(gl_light0); gldepthfunc(gl_less); glenable(gl_depth_test); void display (void) { GLfloat mat_diffuse[] = { 10, 10, 10, 10 ; GLfloat mat_ambient[] = { 01, 01, 01, 10 ; GLfloat mat_specular[] = { 09, 09, 09, 10 ; glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); glmaterialfv(gl_front, GL_DIFFUSE, mat_diffuse); glmaterialfv(gl_front, GL_AMBIENT, mat_ambient); glmaterialfv(gl_front, GL_SPECULAR, mat_specular); glmaterialf (GL_FRONT, GL_SHININESS, 640); glpushmatrix(); gltranslatef (00, 00, -50); auxsolidtorus(02,10); gltranslatef (20, 10, -40); auxsolidtorus(02,10); glpopmatrix(); glflush(); void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 100; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity ();

46 46 OpenGL gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char **argv) { auxinitdisplaymode (AUX_SINGLE AUX_RGB AUX_DEPTH); auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxmainloop(display); n end of torus2c / 225 ( ) ( ) glrotate torus rotatedc torusc display glpushmatrix glpopmatrix glpushmatrix(); gltranslatef (00, 00, -50); glrotatef (-600, 10, 00, 00); auxsolidtorus(02,10); glpopmatrix(); gltranslatef glrotatef ( )2( ) 6= ( )2( )

47 226 ( ) ( ) torus2 rotatedc torusc display glpushmatrix glpopmatrix glpushmatrix(); gltranslatef (00, 00, -50); glrotatef(-600, 10, 00, 00); auxsolidtorus(02,10); gltranslatef (00, 40, 00); auxsolidtorus(02,10); glpopmatrix(); 1 ( ) 0z 2 x y OpenGL ( ) glpushmatrix glpopmatix()

48 48 OpenGL 28 current matrix current matrix glpushmatrix push current matrix push current matrix glpopmatrix pop current matrix glpushmatrix current matrix OpenGL ( ) glpushmatrix glpopmatrix OpenGL glpushmatrix glpopmatrix \ " OpenGL glpushmatrix glpopmatrix 29 push pop torus2 rotatedc torus2 rotated2c torusc display glpushmatrix glpopmatrix gltranslatef (00, 00, -50); glpushmatrix(); glrotatef(-600, 10, 00, 00); auxsolidtorus(02,10); glpopmatrix(); glpushmatrix(); gltranslatef (00, 10, 00); 28 UNIX 29 glmatrixmode

49 228 ( ) 49 auxsolidtorus(02,10); glpopmatrix(); 228 ( ) push pop linkc /* * linkc \* An OpenGL sample program - Three linked tori (with a ball) - No animation */ #include <GL/glh> #include <GL/gluh> #include "auxh" void initial(void) { GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glenable(gl_lighting); glenable(gl_light0);

50 50 OpenGL gldepthfunc(gl_less); glenable(gl_depth_test); void set_mat_color(glfloat *diffuse, GLfloat *ambient, GLfloat *specular) { glmaterialfv(gl_front, GL_DIFFUSE, diffuse); glmaterialfv(gl_front, GL_AMBIENT, ambient); glmaterialfv(gl_front, GL_SPECULAR, specular); void display (void) { GLfloat diffuse0[] = { 10, 10, 10, 10 ; GLfloat ambient0[] = { 01, 01, 01, 10 ; GLfloat specular0[] = { 09, 09, 09, 10 ; GLfloat diffuse1[] = { 10, 10, 00, 10 ; GLfloat ambient1[] = { 01, 01, 00, 10 ; GLfloat specular1[] = { 09, 09, 00, 10 ; GLfloat diffuse2[] = { 10, 00, 10, 10 ; GLfloat ambient2[] = { 01, 00, 01, 10 ; GLfloat specular2[] = { 09, 00, 09, 10 ; GLfloat diffuse3[] = { 00, 10, 10, 10 ; GLfloat ambient3[] = { 00, 01, 01, 10 ; GLfloat specular3[] = { 00, 09, 09, 10 ; glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); glmaterialf (GL_FRONT, GL_SHININESS, 640); gltranslatef(00, 00, -50); glrotatef(-700, 10, 00, 00); glpushmatrix(); set_mat_color(diffuse0, ambient0, specular0); auxsolidtorus(02,10); glpushmatrix(); gltranslatef(10, 00, 00); glrotatef(900, 10, 00, 00); set_mat_color(diffuse1, ambient1, specular1); auxsolidtorus(015,05); glpushmatrix(); glrotatef(300, 00, 00, 10); gltranslatef(05, 00, 00); glrotatef(-500, 00, 10, 00); gltranslatef(02, 00, 00); set_mat_color(diffuse3, ambient3, specular3); auxsolidsphere(005); glpopmatrix(); glpopmatrix(); glpushmatrix(); glrotatef(1200, 00, 00, 10); gltranslatef(10, 00, 00); glrotatef(900, 10, 00, 00); set_mat_color(diffuse2, ambient2, specular2);

51 auxsolidtorus(015,05); glpopmatrix(); glpushmatrix(); glrotatef(2400, 00, 00, 10); gltranslatef(10, 00, 00); glrotatef(900, 10, 00, 00); set_mat_color(diffuse3, ambient3, specular3); auxsolidtorus(015,05); glpopmatrix(); glpopmatrix(); glflush(); void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 100; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char **argv) { auxinitdisplaymode (AUX_SINGLE AUX_RGB AUX_DEPTH); auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxmainloop(display); n end of linkc / 229 ( ) CG ( A ) OpenGL ( B ) A B A ( A) B B OpenGL

52 52 OpenGL 1 main auxinitdisplaymode() AUX_DOUBLE 2 main auxidlefunc() 3 auxidlefunc() auxmainloop() 4 glflush() glxswapbuffers() glxswapbuers glx glxswapbuers glflush glflush glxswapbuers swing torusc /* * swing_torusc \* An OpenGL sample program - Animation - A rotating torus (see torusc) */ #include <GL/glh> #include <GL/gluh> #include "auxh" static GLdouble spin=00; void initial(void) { GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; gllightfv(gl_light0, GL_AMBIENT, light_ambient);

53 gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glenable(gl_lighting); glenable(gl_light0); glenable(gl_depth_test); void display (void) { GLfloat mat_diffuse[] = { 10, 10, 10, 10 ; GLfloat mat_ambient[] = { 01, 01, 01, 10 ; GLfloat mat_specular[] = { 09, 09, 09, 10 ; glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); glmaterialfv(gl_front, GL_DIFFUSE, mat_diffuse); glmaterialfv(gl_front, GL_AMBIENT, mat_ambient); glmaterialfv(gl_front, GL_SPECULAR, mat_specular); glmaterialf (GL_FRONT, GL_SHININESS, 640); glpushmatrix(); gltranslatef (00, 00, -50); glrotatef (spin, 10, 00, 00); glrotatef (spin, 00, 10, 10); auxsolidtorus(02,10); glpopmatrix(); glxswapbuffers(auxxdisplay(), auxxwindow()); void rotation(void) { spin += 15; if (spin > 3600) spin -= 3600; display(); void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 100; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char **argv) { auxinitdisplaymode (AUX_DOUBLE AUX_RGBA AUX_DEPTH);

54 54 OpenGL auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxidlefunc(display); auxmainloop(rotation); n end of swing torusc / link animec linkc ( ) ( ) /* * link_anmimec \* An OpenGL sample program - Animation */ #include <GL/glh> #include <GL/gluh> #include "auxh" static GLdouble toroidal_spin = 00; static GLdouble ball1_spin = 00; static GLdouble ball2_spin = 00; static GLdouble ball3_spin = 00; void initial(void) {

55 GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glenable(gl_lighting); glenable(gl_light0); gldepthfunc(gl_less); glenable(gl_depth_test); void set_mat_color(glfloat *diffuse, GLfloat *ambient, GLfloat *specular) { glmaterialfv(gl_front, GL_DIFFUSE, diffuse); glmaterialfv(gl_front, GL_AMBIENT, ambient); glmaterialfv(gl_front, GL_SPECULAR, specular); void display (void) { GLfloat diffuse0[] = { 10, 10, 10, 10 ; GLfloat ambient0[] = { 01, 01, 01, 10 ; GLfloat specular0[] = { 09, 09, 09, 10 ; GLfloat diffuse1[] = { 10, 10, 00, 10 ; GLfloat ambient1[] = { 01, 01, 00, 10 ; GLfloat specular1[] = { 09, 09, 00, 10 ; GLfloat diffuse2[] = { 10, 00, 10, 10 ; GLfloat ambient2[] = { 01, 00, 01, 10 ; GLfloat specular2[] = { 09, 00, 09, 10 ; GLfloat diffuse3[] = { 00, 10, 10, 10 ; GLfloat ambient3[] = { 00, 01, 01, 10 ; GLfloat specular3[] = { 00, 09, 09, 10 ; glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); glmaterialf (GL_FRONT, GL_SHININESS, 640); glpushmatrix(); gltranslatef(00, 00, -50); glrotatef(-700, 10, 00, 00); glrotatef(toroidal_spin, 00, 00, 10); glpushmatrix(); set_mat_color(diffuse0, ambient0, specular0); auxsolidtorus(02,10); glpushmatrix(); gltranslatef(10, 00, 00); glrotatef(900, 10, 00, 00); set_mat_color(diffuse1, ambient1, specular1); auxsolidtorus(015,05); glpushmatrix();

56 56 OpenGL glrotatef(ball1_spin, 00, 00, 10); gltranslatef(05, 00, 00); glrotatef(ball1_spin*5, 00, 10, 00); gltranslatef(018, 00, 00); set_mat_color(diffuse3, ambient3, specular3); auxsolidsphere(005); glpopmatrix(); glpopmatrix(); glpushmatrix(); glrotatef(1200, 00, 00, 10); gltranslatef(10, 00, 00); glrotatef(900, 10, 00, 00); set_mat_color(diffuse2, ambient2, specular2); auxsolidtorus(015,05); glpushmatrix(); glrotatef(ball2_spin, 00, 00, 10); gltranslatef(05, 00, 00); glrotatef(ball2_spin*5, 00, 10, 00); gltranslatef(018, 00, 00); set_mat_color(diffuse1, ambient1, specular1); auxsolidsphere(005); glpopmatrix(); glpopmatrix(); glpushmatrix(); glrotatef(2400, 00, 00, 10); gltranslatef(10, 00, 00); glrotatef(900, 10, 00, 00); set_mat_color(diffuse3, ambient3, specular3); auxsolidtorus(015,05); glpushmatrix(); glrotatef(ball3_spin, 00, 00, 10); gltranslatef(05, 00, 00); glrotatef(ball3_spin*5, 00, 10, 00); gltranslatef(030, 00, 00); set_mat_color(diffuse2, ambient2, specular2); auxsolidcube(020); glpopmatrix(); glpopmatrix(); glpopmatrix(); glpopmatrix(); glxswapbuffers(auxxdisplay(), auxxwindow()); void rotation(void) { toroidal_spin += 10; ball1_spin += 80; ball2_spin += 40; ball3_spin += 10; display();

57 void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 100; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char **argv) { auxinitdisplaymode (AUX_DOUBLE AUX_RGB AUX_DEPTH); auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxidlefunc(display); auxmainloop(rotation); n end of link animec / 231 OpenGL \ " OpenGL ( ) \ " (gltranslatef ) (gluperspective ) CompleXcope p15 simple3c glbegin(gl_points); for (i=0; i<6; i++) { x = cos(i*pi/3); y = sin(i*pi/3); glvertex3f(x, y, 00); glend();

58 58 OpenGL ( ) OpenGL ( ) OpenGL OpenGL glnewlist glendlist OpenGL GLuint int list_no = 1; glnewlist(list_no, GL_COMPILE); glendlist(); glcalllist(1); (1) (2) (3) (4)

59 circlesc /* * circlesc \* An OpenGL sample program - No Lighting - Display List */ #include <mathh> #include <GL/glh> #include <GL/gluh> #include "auxh" #define PI #define TWOPI (2*PI) GLuint list1 = 1; void initial(void) { int i; GLfloat x,y; glnewlist(list1, GL_COMPILE); glcolor3f(10, 10, 00); gltranslatef(15, 00, 00); glbegin(gl_line_loop); for (i=0; i<100; i++) { x = 08*cos(TWOPI*i/1000); y = 08*sin(TWOPI*i/100); glvertex3f(x,y,00); glend(); gltranslatef(-15, 00, 00); glrotatef(200, 00, 00, 10); gltranslatef(00, 00, -10); glendlist(); glshademodel(gl_flat); void display (void) { int i; glclear(gl_color_buffer_bit); gltranslatef (00, 00, -50); glpushmatrix(); for (i=0; i<200; i++) glcalllist(list1); glpopmatrix(); glflush();

60 60 OpenGL void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 10000; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char** argv) { auxinitdisplaymode (AUX_SINGLE AUX_RGB); auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxmainloop(display); n end of circlesc / OpenGL OpenGL GLuint glgenlists(1); n n GLuint glgenlists(n); n ` ` +1, ` +2, 111, ` + n p24 OpenGL ( ) CG

61 RGB GLubyte image[width][height][3] RGB (0 255) R,G,B WIDTH 2 HEIGHT WIDTH HEIGHT 2 64 OpenGL pict gif AVS (*x) AVS width height ARGB AVS width height ( A) Appendix D ( \texturesample256x256") OpenGL OpenGL Programming Guide [4, 5] width height texturec

62 62 OpenGL /* * texturec \* An OpenGL sample program - Texuture Mapping */ #include <stdioh> #include <GL/glh> #include <GL/gluh> #include "auxh" #define IMAGEWIDTH 256 #define IMAGEHEIGHT 256 char image[imagewidth][imageheight][3]; GLuint texidx = 1; void initial(void) { FILE *fp; fp = fopen("texturesample256x256","r"); if (fp==null) { printf(" open err; image file\n"); exit(9); fread(image, 1, IMAGEWIDTH*IMAGEHEIGHT*3, fp); fclose(fp); glpixelstorei(gl_unpack_alignment, 1); gltexenvf(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_DECAL); gltexparameterf(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gltexparameterf(gl_texture_2d, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gltexparameterf(gl_texture_2d, GL_TEXTURE_WRAP_S, GL_CLAMP); gltexparameterf(gl_texture_2d, GL_TEXTURE_WRAP_T, GL_CLAMP); glnewlist(texidx, GL_COMPILE); glteximage2d(gl_texture_2d, 0, 3, IMAGEWIDTH, IMAGEHEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, &image[0][0][0]); glpushmatrix(); glbegin(gl_quads); gltexcoord2f(00, 10); glvertex3f(-10, -10, 00); gltexcoord2f(10, 10); glvertex3f( 10, -10, 00); gltexcoord2f(10, 00); glvertex3f( 10, 10, 00); gltexcoord2f(00, 00); glvertex3f(-10, 10, 00); glend(); glpopmatrix(); glendlist();

63 glclearcolor(0, 0, 0, 0); void display (void) { int i; glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); gldisable(gl_lighting); glenable(gl_texture_2d); gltranslatef (00, -25, -50); for (i=2; i>=-2; i--) { glpushmatrix(); glrotatef(i*200, 00, 00, 10); gltranslatef(00, 30, 00); glcalllist(texidx); glpopmatrix(); glflush(); void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 150; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char **argv) { auxinitdisplaymode (AUX_SINGLE AUX_RGB AUX_DEPTH); auxinitposition (0, 0, 500, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxmainloop(display); n end of texturec /

64 64 OpenGL

65 3 CAVE 31 CompleXcope CompleXcope OpenGL CAVE CAVE x SGI ONYX, 4 x CPU R4400, Main mem 512MB, 3 x Reality Engine II Ascention Technology "Flock of Bird" 9 32 CompleXcope VR ONYX CAVE CAVE CAVE CAVE /usr/local/cave 65

66 66 CAVE /usr/local/cave/include /usr/local/cave/lib /usr/local/cave/bin 34 CAVE CAVE +x +y +z / y / / / / / / x / / / / / / / / z / / / / / / CompleXcope -5 <= x <= +5 0 <= y <= <= z <= CompleXcope

67 36 Conguration File 67 1 display process (1) 2 display process (2) 3 display process (3) 4 application computation process 5 tracking process display process CompleXcope display process application computation process CAVE tracking process ONYX (shared memorry) 36 Conguration File CAVE caverc conguration le # sample of caverc simulator y DisplayMode mono conguration le CAVE simulator on VR CompleXcope ONYX DisplayMode mono CompleXcope CAVE con- guration le 1 ( ) /usr/local/cave/etc/caveconfig /usr/local/cave/etc/asoconfig ~/caverc /caverc (CompleXcope ) ~/caverc /caverc (# ) 37 CompleXcope (1) (Optional) CompleXcope CompleXcope CAVE ( ) 1 aso CompleXcope ONYX host name

68 CAVE (2) (Required) CAVE conguration CAVE conguration le conguration le (3) (Optional) (4) (Required) CAVE (5) (Optional) OpenGL display process application computation process tracking process fork CAVE 76 OpenGL ( ) 4 fork ( ) display process CAVE 5 (6) (Required) display (7) (Optional) computation 7 OpenGL display process CAVE (8) (Required) CAVE 7 38 CAVE CompleXcope CompleXcope CAVE CAVE CAVE X Window CAVE conguration le simulator y 2 CAVE CompleXcope CAVE 2 on

69 39 69 CAVE left arrow right arrow Up arrow Down arrow Shift + up arrow Shift + donw arrow Alt + left arrow Alt + right arrow Alt + up arrow Alt + down arrow p move left move right move forward move backward move up move down rotate left rotate right rotate up rotate down reset head and wand to initial CAVE Cntl + mouse movement move wnad left/right/forward/back Shift + mouse movement move wand left/right/up/down Alt + mouse movement rotate wand/left/right/up/down < and > rotate wand about Z Home reset wand to be in front of user F1/F2/F3/ select wand 1/2/3/ as the current wand CAVE mouse left button mouse middle button mouse right button Space + mouse movement wand left button wand middle button wand right button joystick CAVE 1 CAVE 2 CAVE w / u / INSERT CAVE / 39 p42 OpenGL torusc ( ) CompleXcope VR

70 CAVE Xtorusc /* * Xtorusc \* A CompleXcope sample program - A torus by aux lib; 4 feet off the floor - Copied and changed from /usr/local/cave/src/ogl/ballc - No animation - No interaction - No navigation */ #include <cave_oglh> /* init_gl - GL initialization function This function will be called exactly once by each of the drawing processes, at the beginning of the next frame after the pointer to it is passed to CAVEInitApplication It defines and binds the light and material data for the rendering */ void init_gl(void) { GLfloat mat_diffuse[] = { 10, 10, 10, 10 ; GLfloat mat_ambient[] = { 01, 01, 01, 10 ; GLfloat mat_specular[] = { 09, 09, 09, 10 ; GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; glclearcolor(0, 0, 0, 0); gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glmaterialfv(gl_front_and_back, GL_DIFFUSE, mat_diffuse); glmaterialfv(gl_front_and_back, GL_AMBIENT, mat_ambient); glmaterialfv(gl_front_and_back, GL_SPECULAR, mat_specular); glmaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 640); glenable(gl_light0); /* draw_torus - the display function This function is called by the CAVE library in the rendering processes' display loop It draws a torus 4 feet off the floor */ void draw_torus(void) { glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT);

71 39 71 glenable(gl_lighting); glpushmatrix(); gltranslatef(00, 40, -20); auxsolidtorus(02,10); glpopmatrix(); gldisable(gl_lighting); main(int argc,char **argv) { /* Initialize the CAVE */ CAVEConfigure(&argc,argv,NULL); CAVEInit(); /* Give the library a pointer to the GL initialization function */ CAVEInitApplication(init_gl,0); /* Give the library a pointer to the drawing function */ CAVEDisplay(draw_torus,0); /* Wait for the escape key to be hit */ while (!CAVEgetbutton(CAVE_ESCKEY)) sginap(10); /* Nap so that this busy loop doesn't waste CPU time */ /* Clean up & exit */ CAVEExit(); n end of Xtorusc / \CAVE" CAVE CAVEConfigure() Configuration CAVEInit() CAVE fork CAVEInitApplication() OpenGL init_gl() ( ) OpenGL CAVEDisplay() draw_torus() ( )OpenGL

72 72 CAVE CAVEgetbutton(CAVE_ESCKEY) ESC hit sginap() CAVEExit() 310 Xtoursc \auxsolidtorus" \auxsolidsphere" Xballc aux 7 glu (p33 ) /* * Xballc \* A CompleXcope sample program - A ball by the glu lib; 1 feet radius, 4 feet off the floor - Copied and changed from /usr/local/cave/src/ogl/ballc - No animation - No interaction - No navigation */ #include <cave_oglh> #include <GL/gluh> static GLUquadricObj *sphereobj; /* init_gl - GL initialization function This function will be called exactly once by each of the drawing processes, at the beginning of the next frame after the pointer to it is passed to CAVEInitApplication It defines and binds the light and material data for the rendering, and creates a quadric object to use when drawing the sphere */ void init_gl(void) { GLfloat mat_diffuse[] = { 10, 10, 10, 10 ; GLfloat mat_ambient[] = { 01, 01, 01, 10 ; GLfloat mat_specular[] = { 09, 09, 09, 10 ; GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ;

73 GLfloat light_position[] = { 10, 10, 10, 00 ; glclearcolor(0, 0, 0, 0); gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glmaterialfv(gl_front, GL_DIFFUSE, mat_diffuse); glmaterialfv(gl_front, GL_AMBIENT, mat_ambient); glmaterialfv(gl_front, GL_SPECULAR, mat_specular); glmaterialf (GL_FRONT, GL_SHININESS, 640); glenable(gl_light0); sphereobj = glunewquadric(); /* draw_ball - the display function This function is called by the CAVE library in the rendering processes' display loop It draws a ball 1 foot in radius, 4 feet off the floor, and 2 foot in front of the front wall (assuming a 10' CAVE) */ void draw_ball(void) { glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT); glenable(gl_lighting); glpushmatrix(); gltranslatef(00, 40, -30); glusphere(sphereobj, 10, 16, 16); glpopmatrix(); gldisable(gl_lighting); main(int argc,char **argv) { /* Initialize the CAVE */ CAVEConfigure(&argc,argv,NULL); CAVEInit(); /* Give the library a pointer to the GL initialization function */ CAVEInitApplication(init_gl,0); /* Give the library a pointer to the drawing function */ CAVEDisplay(draw_ball,0); /* Wait for the escape key to be hit */ while (!CAVEgetbutton(CAVE_ESCKEY)) sginap(10); /* Nap so that this busy loop doesn't waste CPU time */ /* Clean up & exit */ CAVEExit(); n end of Xballc /

74 74 CAVE ( ) p52 swing torusc CompleXcope 7 6 /* \* */ * Xswing_torusc A CompleXcope sample program 4 5 Xswing torusc - Copied and changed from /usr/local/cave/src/ogl/bouncec - A rotating torus - Calculation of their movements are performed in the main process - It is communicated to the three drawing processes through the shared memory - No interaction - No navigation #include <cave_oglh> #include <GL/gluh> /* The data that will be shared between processes */ struct _torusdata { float angle1; float angle2; ; void init_gl(void),draw(struct _torusdata *); struct _torusdata *init_shmem(void); void compute(struct _torusdata *); main(int argc, char **argv) { struct _torusdata *torus; CAVEConfigure(&argc,argv,NULL); torus = init_shmem(); CAVEInit(); CAVEInitApplication(init_gl,0); CAVEDisplay(draw,1,torus); while (!CAVEgetbutton(CAVE_ESCKEY)) { compute(torus); sginap(1); CAVEExit(); struct _torusdata *init_shmem(void) { struct _torusdata *torus; torus = CAVEMalloc(sizeof(struct _torusdata)); bzero(torus,sizeof(struct _torusdata)); return torus;

75 311 3( ) 75 void compute(struct _torusdata *torus) { float t = CAVEGetTime(); torus->angle1 = t*50; torus->angle2 = t*73; void init_gl(void) { GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; glenable(gl_light0); glclearcolor(0, 0, 0, 0); gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); void draw(struct _torusdata *torus) { glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT); glenable(gl_lighting); gltranslatef(00, 40, -30); glpushmatrix(); glrotatef(torus->angle1, 10, 00, 00); glrotatef(torus->angle2, 00, 10, 10); auxsolidtorus(02, 10); glpopmatrix(); gldisable(gl_lighting); n end of Xswing torusc / Xtorusc Xballc main while() compute() (angle1 angle2) comupte() (application computation process) application computation process 3 CAVE shared memory torus torus shared memory shared memory init shmem() CAVEMalloc()

76 76 CAVE CAVE shared memory 8MB CAVESetOption(CAVE_SHMEM_SIZE, size_in_bytes) CAVEConfigure() Xbouncec /* * Xbouncec \* A CompleXcope sample program - Copied and changed from /usr/local/cave/src/ogl/bouncec - Two bouncing balls - Calculation of their movements are performed in the main process - It is communicated to the three drawing processes through the shared memory - No interaction - No navigation */ #include <cave_oglh> #include <GL/gluh> /* The data that will be shared between processes */ struct _balldata { float y; ; void init_gl(void),draw_balls(struct _balldata *); struct _balldata *init_shmem(void); void compute(struct _balldata *); main(int argc, char **argv) { struct _balldata *ball; CAVEConfigure(&argc,argv,NULL); /* Initialize shared memory */ ball = init_shmem(); CAVEInit(); CAVEInitApplication(init_gl,0); /* Give the library a pointer to the drawing function, plus one argument */ CAVEDisplay(draw_balls,1,ball);

77 while (!CAVEgetbutton(CAVE_ESCKEY)) { /* Update the balls' positions */ compute(ball); sginap(1); CAVEExit(); /* init_shmem - initializes shared memory The data is allocated from a shared memory arena, and so will be common to all processes forked after this is called */ struct _balldata *init_shmem(void) { struct _balldata *ball; ball = CAVEMalloc(2*sizeof(struct _balldata)); bzero(ball,2*sizeof(struct _balldata)); return ball; /* compute - compute new positions for the balls The height of the balls is a function of the current CAVE time */ void compute(struct _balldata *ball) { float t = CAVEGetTime(); ball[0]y = fabs(sin(t)) * 5 + 1; ball[1]y = fabs(sin(t*12)) * 3 + 1; static GLuint redmat, bluemat; static GLUquadricObj *sphereobj; /* init_gl - initialize GL lighting & materials */ void init_gl(void) { float redmaterial[] = { 1, 0, 0, 1 ; float bluematerial[] = { 0, 0, 1, 1 ; GLfloat light_diffuse[] = { 10, 10, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 05, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; glclearcolor(0, 0, 0, 0); glenable(gl_light0); gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); /* 1st display list */ redmat = glgenlists(1);

78 78 CAVE glnewlist(redmat, GL_COMPILE); glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, redmaterial); glendlist(); /* 2nd display list */ bluemat = glgenlists(1); glnewlist(bluemat, GL_COMPILE); glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, bluematerial); glendlist(); sphereobj = glunewquadric(); /* draw_balls - draw the two balls, using the shared data for their y coordinates */ void draw_balls(struct _balldata *ball) { glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT); glenable(gl_lighting); glcalllist(redmat); glpushmatrix(); gltranslatef(30, ball[0]y, 00); glusphere(sphereobj, 10, 16, 16); glpopmatrix(); glcalllist(bluemat); glpushmatrix(); gltranslatef(00, ball[1]y, -30); glusphere(sphereobj, 10, 16, 16); glpopmatrix(); gldisable(gl_lighting); n end of Xbouncec / glenable(gl LIGHTING) OpenGL GL LIGHTING Xsnowfallc o OpenGL 7 CompleXcope /* * Xsnowfallc \* A CompleXcope sample program - Snow fall - No lighting

79 */ - No interaction - No navigation #include <cave_oglh> #include <GL/gluh> #include <stdlibh> #define NCOMMET 500 #define XMAX 200 #define YMAX 200 #define ZMAX 100 #define XMIN (-200) #define YMIN (-50) #define ZMIN (-200) /* The data that will be shared between processes */ struct _snowdata { float xpos; float ypos; float zpos; float xaxis; float yaxis; float zaxis; float spin; float vx; float vy; float vz; ; void init_gl(void),draw(struct _snowdata *); struct _snowdata *init_shmem(void); void compute(struct _snowdata *); static GLuint flake_indx; main(int argc, char **argv) { struct _snowdata *snows; CAVEConfigure(&argc,argv,NULL); snows = init_shmem(); CAVEInit(); CAVEInitApplication(init_gl,0); CAVEDisplay(draw,1,snows); while (!CAVEgetbutton(CAVE_ESCKEY)) { compute(snows); sginap(1); CAVEExit(); float ransu(void) {

80 80 CAVE float r = rand() / ; return r; struct _snowdata *init_shmem(void) { int i; struct _snowdata *snows; snows = CAVEMalloc(NCOMMET*sizeof(struct _snowdata)); bzero(snows,ncommet*sizeof(struct _snowdata)); for (i=0; i<ncommet; i++) { snows[i]xpos = XMIN + (XMAX-XMIN)*ransu(); snows[i]ypos = YMIN + (YMAX-YMIN)*ransu(); snows[i]zpos = ZMIN + (ZMAX-ZMIN)*ransu(); snows[i]xaxis = ransu(); snows[i]yaxis = ransu(); snows[i]zaxis = ransu(); return snows; void compute(struct _snowdata *snows) { intsnows

81 glvertex3f(-flake_size/2, 00, 00); glend(); glendlist(); flake_indx = glgenlists(1); glnewlist(flake_indx, GL_COMPILE); glpushmatrix(); glcalllist(tmp_indx); glpushmatrix(); glrotatef(1800, 10, 00, 00); gltranslatef(00, -flake_size/sqrt(30), 00); glcalllist(tmp_indx); glpopmatrix(); glendlist(); void draw(struct _snowdata *snows) { int i; glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT); for (i=0; i<ncommet; i++) { glpushmatrix(); gltranslatef(snows[i]xpos, snows[i]ypos, snows[i]zpos); glrotatef(snows[i]spin, snows[i]xaxis, snows[i]yaxis, snows[i]zaxis); glcalllist(flake_indx); glpopmatrix(); n end of Xsnowfallc / VR 3 ( draw) glenable(gl LIGHTING) gldisable(gl LIGHTING) 314 on CAVE p39 OpenGL ( ) CAVE CAVENear CAVE- Far global oat CAVENear = 01 ( ) CAVEFar = 100 ( ) 3

82 82 CAVE 315 CAVE CAVEMalloc() ( ) CAVEExit() 4 ( ) CAVEMalloc() ipcs {m {b active % ipcs -m -b IPC status from /dev/kmem as of Mon Jul 13 11:52: T ID KEY MODE OWNER GROUP SEGSZ Shared Memory: m 0 0x rw-r--r-- root sys 136 m 1 0x rw-rw-rw- root sys 228 m 2 0x rw-rw-rw- root sys 140 m 3 0x000007c8 --rw-rw-rw- root sys 4 m 4 0x000009a4 --rw-rw-rw- guest guest guest \ipcrm {m <ID>" aso% ipcrm -m 4 aso% ipcs -m -b IPC status from /dev/kmem as of Mon Jul 13 11:52: T ID KEY MODE OWNER GROUP SEGSZ Shared Memory: m 0 0x rw-r--r-- root sys 136 m 1 0x rw-rw-rw- root sys 228 m 2 0x rw-rw-rw- root sys 140 m 3 0x000007c8 --rw-rw-rw- root sys CompleXcope 5 x-y (jxj 1, jyj 1) 4 CAVEFree() 5 CAVE

83 /1 2 3\ / O O O \ / J \ J: \ \ / / \ / : y x CAVE 1 2 ( ) 3 (push/nonpush) 4 5 ( ) (x,y) 317 CAVE tracking process tracking process CAVEInit CAVElibrary tracking process void CAVEGetPosition(CAVEID posid, float position[3]) posid CAVE HEAD, CAVE WAND, CAVE LEFT EYE, CAVE RIGHT EYE, CAVE HEAD NAV, CAVE WAND NAV, CAVE LEFT EYE NAV, CAVE RIGHT EYE NAV CAVE_HEAD : ( ) CAVE_WAND : CAVE_LEFT_EYE : CAVE_RIGHT_EYE : CAVE_HEAD_NAV : CAVE_WAND_NAV : CAVE_LEFT_EYE_NAV : CAVE_RIGHT_EYE_NAV :

84 84 CAVE CAVE 05 x 5, 0 y 10, 05 z 5 (feet) 318 void CAVEGetVector(CAVEID vectorid, float vector[3]) vectorid CAVE_HEAD_FRONT, CAVE_HEAD_BACK, CAVE_HEAD_LEFT, CAVE_HEAD_RIGHT, CAVE_HEAD_UP, CAVE_HEAD_DOWN, CAVE_WAND_FRONT, CAVE_WAND_BACK, CAVE_WAND_LEFT, CAVE_WAND_RIGHT, CAVE_WAND_UP, CAVE_WAND_DOWN, CAVE_HEAD_FRONT_NAV, CAVE_HEAD_BACK_NAV, CAVE_HEAD_LEFT_NAV, CAVE_HEAD_RIGHT_NAV, CAVE_HEAD_UP_NAV, CAVE_HEAD_DOWN_NAV, CAVE_WAND_FRONT_NAV, CAVE_WAND_BACK_NAV, CAVE_WAND_LEFT_NAV, CAVE_WAND_RIGHT_NAV, CAVE_WAND_UP_NAV, CAVE_WAND_DOWN, CAVE WAND FRONT CAVEGetVector vector 319 ( ) ( ) int CAVEButtonChange(int button) /* button = 1,2, or 3 */ 0 1 2

85 CompleXcope CAVEBUTTON1 CAVEBUTTON2 CAVEBUTTON if (CAVEBUTTON1) { procedure to be done when button 1 (left) is pressed if (!CAVEBUTTON2) { procedure to be done when button 2 (middle) is not pressed 321 CAVE_JOYSTIC_X CAVE_JOYSTIC_Y x,y [01:0; 1:0] oat ( ) 00

86 86 CAVE if (fabs(cave_joystic_y)>02) { /* procedure to be done when joystick is pushed forward or backward */ 322 \ " interactc /* * interactc \* A CompleXcope sample program - Copied and changed from /usr/local/cave/src/ogl/interactc - A sample program for the CAVE interaction procedure - A ball appears when wand left button is pressed at the wand tip - The ball is grabbed when wand middle button is pressed - The ball is destroyed when wand right button is pressed - No navigation */ #include <cave_oglh> #include <GL/gluh> #define SQR(x) ((x)*(x)) struct _balldata { float x,y,z; float radius; int grabbed; int exist; ; static GLuint mat0, mat1; void init_gl(void);

87 void draw_ball(struct _balldata *); void check_add(struct _balldata *); struct _balldata * init_shmem(void); void update_held(struct _balldata *); void check_grab(struct _balldata *); main(int argc,char **argv) { struct _balldata *ball; CAVEConfigure(&argc,argv,NULL); ball = init_shmem(); CAVEInit(); CAVEInitApplication(init_gl, 0); CAVEDisplay(draw_ball, 1, ball); while (!CAVEgetbutton(CAVE_ESCKEY)) { check_add(ball); if ( ball->grabbed ) update_held(ball); else check_grab(ball); sginap(1); CAVEExit(); /************\ > check_add < \************/ void check_add(struct _balldata *ball) { float wandpos[3], wandfront[3]; if (CAVEButtonChange(1) == -1) { /* left button is released */ CAVEGetPosition(CAVE_WAND, wandpos); /* wand position */ CAVEGetVector(CAVE_WAND_FRONT, wandfront); /* wand direction */ ball->x = wandpos[0] + wandfront[0]*05; ball->y = wandpos[1] + wandfront[1]*05; ball->z = wandpos[2] + wandfront[2]*05; ball->radius = 1; ball->grabbed = 0; ball->exist = 1; if (CAVEButtonChange(3) == 1) ball->exist = 0; /*************\ > init_shmem < \*************/ struct _balldata * init_shmem(void) { struct _balldata *ball; ball = (struct _balldata *)CAVEMalloc(sizeof(struct _balldata)); bzero(ball, sizeof(struct _balldata));

88 88 CAVE return ball; /**************\ > update_held < \**************/ void update_held(struct _balldata *ball) { float wandpos[3]; if (!CAVEBUTTON2) { CAVEGetPosition(CAVE_WAND, wandpos); ball->x = wandpos[0]; ball->y = wandpos[1]; ball->z = wandpos[2]; ball->grabbed = 0; else { if (CAVE_JOYSTICK_Y > 5) /* Joystick pushed forward */ ball->radius *= 1005; else if (CAVE_JOYSTICK_Y < -5) /* Joystick pushed backward */ ball->radius /= 1005; /*************\ > check_grab < \*************/ void check_grab(struct _balldata *ball) { float wandpos[3]; float distsq; if (CAVEButtonChange(2) == 1) { /* wand middle button is pressed */ CAVEGetPosition(CAVE_WAND, wandpos); if (ball->exist) { distsq = SQR(ball->x - wandpos[0]) + SQR(ball->y - wandpos[1]) + SQR(ball->z - wandpos[2]); if (distsq < SQR(ball->radius)) { ball->grabbed = 1; static GLUquadricObj *sphereobj; /**********\ > init_gl < \**********/ void init_gl(void) { GLfloat diffuse0[] = { 00, 00, 10, 10 ;

89 GLfloat ambient0[] = { 00, 03, 03, 10 ; GLfloat specular0[] = { 04, 04, 04, 10 ; GLfloat diffuse1[] = { 10, 10, 00, 10 ; GLfloat ambient1[] = { 03, 03, 00, 10 ; GLfloat specular1[] = { 04, 04, 04, 10 ; GLfloat light_diffuse[] = { 10, 10, 10, 00 ; GLfloat light_ambient[] = { 03, 03, 03, 00 ; GLfloat light_specular[] = { 10, 10, 10, 00 ; GLfloat light_position[] = { 10, 10, 10, 00 ; glenable(gl_light0); glclearcolor(0, 0, 0, 0); gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); sphereobj = glunewquadric(); mat0 = glgenlists(1); glnewlist(mat0, GL_COMPILE); glmaterialfv(gl_front_and_back, GL_DIFFUSE, diffuse0); glmaterialfv(gl_front_and_back, GL_AMBIENT, ambient0); glmaterialfv(gl_front_and_back, GL_SPECULAR, specular0); glmaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 1000); glendlist(); mat1 = glgenlists(1); glnewlist(mat1, GL_COMPILE); glmaterialfv(gl_front_and_back, GL_DIFFUSE, diffuse1); glmaterialfv(gl_front_and_back, GL_AMBIENT, ambient1); glmaterialfv(gl_front_and_back, GL_SPECULAR, specular1); glmaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 1000); glendlist(); /************\ > draw_ball < \************/ void draw_ball(struct _balldata *ball) { glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT); glenable(gl_lighting); if (ball->exist) { if (ball->grabbed) { glpushmatrix(); CAVEWandTransform(); glcalllist(mat1); glusphere(sphereobj, ball->radius, 32, 32); glpopmatrix();

90 90 CAVE else { glpushmatrix(); gltranslatef(ball->x, ball->y, ball->z); glcalllist(mat0); glusphere(sphereobj, ball->radius, 32, 32); glpopmatrix(); gldisable(gl_lighting); n end of interactc / 323 CompleXCope 10 CompleXcope (x=0,y=5,z=0) CompleXcope ( x=0, y=5, z=-8) VR CompleXcope VR CompleXcope CompleXcope interactc CompleXcope ( ) (CompleXcope ) ( ) (CompleXcope ) interactc CAVEGetPosition() CAVE WAND NAV \ NAV" CAVE navigate() void CAVENavTranslate(float x,float y,float z) void CAVENavRot(float angle, char axis) navigate() applicatin computation process draw ball (display process) void CAVENavTransform(void)

91 navigatec /* * navigatec \* A CompleXcope sample program - Copied and changed from /usr/local/cave/src/ogl/navigatec - A sample program for the CAVE navigation function - A ball appears when wand left button is pressed at the wand tip - The ball is destroyed when wand right button is pressed */ #include <cave_oglh> #include <GL/gluh> struct _balldata { float x,y,z; float radius; int exist; ; static GLuint mat0, boundary; void init_gl(void); void draw_ball(struct _balldata *); void check_add(struct _balldata *); struct _balldata * init_shmem(void); void navigate(void); main(int argc,char **argv) { struct _balldata *ball; CAVEConfigure(&argc,argv,NULL); ball = init_shmem(); CAVEInit(); CAVEInitApplication(init_gl, 0); CAVEDisplay(draw_ball, 1, ball); while (!CAVEgetbutton(CAVE_ESCKEY)) { navigate(); check_add(ball); sginap(1); CAVEExit(); #define SPEED 50f /* Max navigation speed in feet per second */ /* navigate - perform the navigation calculations This checks the joystick state and uses that to move and rotate The Y position of the joystick determines the speed of motion in the direction of the wand The X position

92 92 CAVE of the joystick determines the speed of rotation about the CAVE's Y axis Joystick values in the range -2 to 2 are ignored; this provides a dead zone to eliminate noise The motion is scaled by dt, the time passed since the last call to navigate(), in order to maintain a smooth speed */ void navigate(void) { float jx=cave_joystick_x,jy=cave_joystick_y,dt,t; static float prevtime = 0; t = CAVEGetTime(); dt = t - prevtime; prevtime = t; if (fabs(jy)>02) { float wandfront[3]; CAVEGetVector(CAVE_WAND_FRONT,wandFront); CAVENavTranslate(wandFront[0]*jy*SPEED*dt, wandfront[1]*jy*speed*dt, wandfront[2]*jy*speed*dt); if (fabs(jx)>02) CAVENavRot(-jx*900f*dt,'y'); /************\ > check_add < \************/ void check_add(struct _balldata *ball) { float wandpos[3], wandfront[3]; if (CAVEButtonChange(1) == -1) { /* left button is released */ CAVEGetPosition(CAVE_WAND_NAV, wandpos); /* wand position */ CAVEGetVector(CAVE_WAND_FRONT_NAV, wandfront); /* wand direction */ ball->x = wandpos[0] + wandfront[0]*05; ball->y = wandpos[1] + wandfront[1]*05; ball->z = wandpos[2] + wandfront[2]*05; ball->radius = 1; ball->exist = 1; if (CAVEButtonChange(3) == 1) ball->exist = 0; /*************\ > init_shmem < \*************/ struct _balldata * init_shmem(void) { struct _balldata *ball; ball = (struct _balldata *)CAVEMalloc(sizeof(struct _balldata)); bzero(ball, sizeof(struct _balldata)); return ball; static GLUquadricObj *sphereobj;

93 /**********\ > init_gl < \**********/ void init_gl(void) { GLfloat diffuse0[] = { 10, 10, 10, 10 ; GLfloat ambient0[] = { 00, 03, 03, 10 ; GLfloat specular0[] = { 04, 04, 04, 10 ; GLfloat light_diffuse[] = { 10, 10, 10, 00 ; GLfloat light_ambient[] = { 03, 03, 03, 00 ; GLfloat light_specular[] = { 10, 10, 10, 00 ; GLfloat light_position[] = { 10, 10, 10, 00 ; glenable(gl_light0); glclearcolor(0, 0, 0, 0); gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); sphereobj = glunewquadric(); mat0 = glgenlists(1); glnewlist(mat0, GL_COMPILE); glmaterialfv(gl_front_and_back, GL_DIFFUSE, diffuse0); glmaterialfv(gl_front_and_back, GL_AMBIENT, ambient0); glmaterialfv(gl_front_and_back, GL_SPECULAR, specular0); glmaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 1000); glendlist(); boundary = glgenlists(1); /* boundary of the CAVE room */ glnewlist(boundary, GL_COMPILE); glcolor3f(0,1,0); glbegin(gl_line_loop); glvertex3f( 5, 0,-5); glvertex3f( 5,10,-5); glvertex3f(-5,10,-5); glvertex3f(-5, 0,-5); glend(); glcolor3f(0,0,1); glbegin(gl_line_loop); glvertex3f( 5, 0, 5); glvertex3f( 5,10, 5); glvertex3f(-5,10, 5); glvertex3f(-5, 0, 5); glend(); glcolor3f(1,0,0); glbegin(gl_lines); glvertex3f( 5, 0,-5); glvertex3f( 5, 0, 5); glvertex3f(-5, 0,-5); glvertex3f(-5, 0, 5); glvertex3f( 5,10,-5); glvertex3f( 5,10, 5); glvertex3f(-5,10,-5); glvertex3f(-5,10, 5); glend(); glendlist();

94 94 CAVE /************\ > draw_ball < \************/ void draw_ball(struct _balldata *ball) { glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT); glenable(gl_lighting); /* Apply the navigation transformation */ CAVENavTransform(); if (ball->exist) { glpushmatrix(); gltranslatef(ball->x, ball->y, ball->z); glcalllist(mat0); glusphere(sphereobj, ball->radius, 32, 32); glpopmatrix(); gldisable(gl_lighting); glcalllist(boundary); n end of navigatec / 324 CompleXcope CompleXcope CAVE CAVE OpenGL OpenGL CAVE CompleXcope Virtual LHD CompleXcope OpenGL CAVE OpenGL Iris Performer Performer Performer ( OpenGL ) OpenGL CAVE Dave Pape CAVE User's Guide CAVE EVL WEB (

95 A CAVE CompleXcope 1 2 ( ) 3 /usr/local/cave/bin/cavevars CompleXcope /usr/local/cave/bin/nifsuniversal right left right left CompleXcope 95

96 96 CAVE

97 B OpenGL OpenGL X Window SGI snapshot ( pict) OpenGL pict glreadpixels() ( ) pict pict AVS (*x) pict AVS width height alpha, red, green, blue ( ) ( ) OpenGL AVS ( p42 torusc ) glreadpixels() toavsx() /* * saveimagec \* An OpenGL sample program - Read the color buffer and make an AVS image file (*x) from it by "glreadpixels" command - An AVS image file named "picturex" is automatically generated - AVS image file has a simple data structure; int width int height char alpha <-+ 1st pixel char red char green char blue <-+ char alpha <-+ 2nd pixel 97

98 98 OpenGL */ char red char green char blue <-+ char alpha <-+ 3rd pixel char red char green char blue <-+ - Here, it is supposed that the window size is 600x500 pixels and the position of its upper-left corner is (0,0) - A torus is drawn by the aux library - With a blue lighting - Perspective view by the glu library - No animation #include <GL/glh> #include <GL/gluh> #include <stdioh> #include "auxh" void initial(void) { GLfloat light_diffuse[] = { 05, 05, 10, 10 ; GLfloat light_ambient[] = { 05, 05, 10, 10 ; GLfloat light_specular[] = { 10, 10, 10, 10 ; GLfloat light_position[] = { 10, 10, 10, 00 ; gllightfv(gl_light0, GL_AMBIENT, light_ambient); gllightfv(gl_light0, GL_SPECULAR, light_specular); gllightfv(gl_light0, GL_DIFFUSE, light_diffuse); gllightfv(gl_light0, GL_POSITION, light_position); glenable(gl_lighting); glenable(gl_light0); gldepthfunc(gl_less); glenable(gl_depth_test); glclearcolor(02, 02, 02, 10); void toavsx(void) { FILE *fp; char *file1 = "/picturex"; /* Here we supposed that (1) the window size is 600 x 500 pixels, (2) The position of the window's upper left corner is (0,0) */

99 OpenGL 99 char pic_red [600*500]; char pic_green[600*500]; char pic_blue [600*500]; char pic_alpha[600*500]; char pic_rgba [600*500*4]; /* R,G,B and Alpha */ int pic_size [2]; /* width and height */ int i; /* */ We cannot use the this (simpler) command; glreadpixels(0, 0, 600, 500, GL_RGBA, GL_UNSIGNED_BYTE, pic), since the each element of RGBA in the color buffer isn't necessarily the same as that in the AVS-X image file (which is "A-R-G-B") glreadpixels(0, 0, 600, 500, GL_RED, GL_UNSIGNED_BYTE, pic_red); glreadpixels(0, 0, 600, 500, GL_GREEN, GL_UNSIGNED_BYTE, pic_green); glreadpixels(0, 0, 600, 500, GL_BLUE, GL_UNSIGNED_BYTE, pic_blue); glreadpixels(0, 0, 600, 500, GL_ALPHA, GL_UNSIGNED_BYTE, pic_alpha); pic_size[0] = 600; /* width in pixel */ pic_size[1] = 500; /* height in pixel */ for (i=0; i<600*500; i++) { pic_rgba[4*i+0] = pic_alpha[i]; pic_rgba[4*i+1] = pic_red [i]; pic_rgba[4*i+2] = pic_green[i]; pic_rgba[4*i+3] = pic_blue [i]; fp = fopen(file1, "w"); if (fp == NULL) { printf(" open error : %s\n", file1); exit(1); fwrite(pic_size, sizeof(pic_size), 1, fp); fwrite(pic_rgba, sizeof(pic_rgba), 1, fp); fclose(fp); void display (void) { GLfloat mat_diffuse[] = { 10, 10, 10, 10 ; GLfloat mat_ambient[] = { 01, 01, 01, 10 ; GLfloat mat_specular[] = { 09, 09, 09, 10 ; glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); glmaterialfv(gl_front, GL_DIFFUSE, mat_diffuse); glmaterialfv(gl_front, GL_AMBIENT, mat_ambient);

100 100 OpenGL glmaterialfv(gl_front, GL_SPECULAR, mat_specular); glmaterialf (GL_FRONT, GL_SHININESS, 640); glpushmatrix(); gltranslatef (00, 00, -50); auxsolidtorus(02,10); glpopmatrix(); glflush(); toavsx(); /****** This is it ******/ void reshape(int width, int height) { GLdouble ang = 600; GLdouble near = 30; GLdouble far = 100; glviewport (0, 0, width, height); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective (ang, (GLdouble)width/(GLdouble)height, near, far); glmatrixmode (GL_MODELVIEW); glloadidentity (); int main(int argc, char **argv) { auxinitdisplaymode (AUX_SINGLE AUX_RGBA AUX_DEPTH); auxinitposition (0, 0, 600, 500); auxinitwindow (argv[0]); initial(); auxreshapefunc (reshape); auxmainloop(display);

101 C C (diff f c) CompleXcope C CAVE OpenGL C Appendix Fortran C C Fortran C C C C1 C C \main" \c" \cc" Fortran \aout" sample01c C /* sample01c */ #include <stdioh> int func1(int); main() { int i,j,k; i=3; j=i*i; printf("calling func1\n"); k = func1(j); /* function call */ printf(" k = %d\n",k); int func1(int k) { int m; printf("i am in func1\n"); m = 3*k; return(m); Fortran 101

102 102 C (diff f c) c c i = 3 j = i**2 write(6,*)' calling nfunc1' k = nfunc1(j) write(6,*)' k = ',k stop end function nfunc1(k) write(6,*)'i am in nfunc1' nfunc = 3*k return end C \{" \" \;" ( i=1; j=2; ) \/*" \*/" (stdio) stdioh include C2 \/*" \*/" i = 3; /* comment 1 */ /* * * * * comment 2 * * * * */ /* comment */

103 C3 103 /* * * This

104 104 C (diff f c) C5 Fortran >= /* GE */ > /* GT */ <= /* LE */ < /* LT */ == /* EQ */!= /* NE */ C6 if if Fortran if (y>=0) ; if (y==1) { /* if (y==1) */ 1; /* { 1; */ 2; /* 2; */ 3; /* 3; */ /* */ if(y!=0) { 1; 2; else { 1; 2; 3; C7 Fortran C

105 C7 105 /* sample03c */ float sum(float,float); /* */ main() { float a; a=sum(20,30); float sum(float a,float b) { return(a+b); Fortran \void" \void" \ " Fortran \ " Fortran c i=2 call sub1(i) stop end subroutine sub1(j) j=0 return end sub1 i 0 C

106 106 C (diff f c) main() { i=2; sub1(i); void sub1(int j) { j=0; sub1() i 2 Fortran C C ( ) C8 for Fortran do C for func() 10 call for (i=0; i<10; i++) { /* do i = 1, 10 */ func(); /* in Fortran */ for () ( ; ; ) C9 while C FORTRAN77 while()

107 C /* sample04c */ #include <stdioh> void func1(int); void func2(int); main() { int n = 10; puts(" "); /* "puts" is a standard function */ func1(n); puts(" "); func2(n); /* the value n is not changed */ void func1(int i) { while (i>0) { printf(" int = %d\n",i); i--; /* i = i-1 */ void func2(int i) { while (i>0) printf(" int = %d\n",i--); func1() func2() void func3(int i) { while (i) /* ( ) 0 */ printf(" inn = %d\n",i--); C10 C Fortran t[n] /* t(n) in Fortarn */ Fortran t t(1),t(2),t(3),,t(n) C t[0],t[1],t[2],,t[n-1] 0 N-1 2

108 108 C (diff f c) t[m][n] /* */ 0 M-1 0 N-1 t N*M Fortran Fortran t(3,4) t(1,1) t(2,1) t(3,1) t(1,2) t(2,2) t(3,4) C t[3][4] t[0][0] t[0][1] t[0][2] t[0][3] t[1][0] t[2][3] Fortran C ( ) t[l][m][n] C11 C 1 ( ) ap float *ap; ( ) temp[100] temp[0], temp[1], temp[2],, temp[99] 1 x &x

109 C ( ) ( )4 temp[0] 4100 temp[1], temp[2], 4104, 4108, temp 4100 temp[100] temp temp 4100 func() temp func() (100 )2(4 ) 2 ( 100 func() ) func() 4100 func() temp void func(float *); /* */ /* void func(float *t) */ /* void func(float t[]) */ /* void func(float t[100]) */ main() { float temp[100]; func(temp); void func(float *t) { /* void func(float t[]) */ /* void func(float t[100]) */ a2 = t[2]; a5 = t[5]; func() 4100 func() t[2] 4108 temp[0] (4100 ) 2 C

110 110 C (diff f c) C12 C CompleXcope VR /* j */ /* j i x */ /* j i y */ /* j i z */ /* */ /* ( ) */ draw() 10 Fortran ( 1000 ) integer nten(10) /* j */ real xpos(10,1000) /* j i x */ real ypos(10,1000) /* j i y */ real zpos(10,1000) /* j i z */ real curr(10,1000) /* */ draw ( ) C \ " magline struct magline { int nten; float xpos[1000]; float ypos[1000]; float zpos[1000]; float curr[1000]; ; magline int oat \ " magline ( ) line_1 struct magline line_1; line_1 line_1 struct magline lines[10];

111 C draw() draw(lines);

112 112 C (diff f c)

113 D 232 OpenGL C (p61) AVS (*x) (x2texture ) D1 imtools imscale AVS x imscale AVS (*x) width height (64 )2 (width height )7 6 #!/bin/csh -f # # mktexture 4 5 mktexture # To make a texture data with 256x256 pixels from # any image file, via AVS image file format # if ( $2 == "" ) then echo usage: $0 file1rgb keyword echo output: keyword256x256 exit endif /usr/sdsc_imtools/imtools/bin/imscale -xsize 256 -ysize 256 \ -infile $1 -outfile /tmp/$2x x2texture /tmp/$2x $2 # cc -o x2texure x2texturec rm /tmp/$2x D2 x2texture n end of mktexture / mktexture x2texture 113

114 x2texturec /* * x2texurec * To make a texture data from an AVS image file */ #include <stdioh> main(int argc,char **argv) { FILE *fpin,*fpout; int i; char red, green, blue, alpha; char sizeinfo[20]; int nx,ny; if (argc<3) { fprintf(stderr," usage: %s file_in file_out\n", argv[0]); exit(8); fpin = fopen(argv[1],"r"); if(fpin==null) { fprintf(stderr," infile open error\n"); exit(9); fread((char *)&nx, sizeof(int), 1, fpin); fread((char *)&ny, sizeof(int), 1, fpin); sprintf(sizeinfo,"%dx%d\0",nx,ny); printf(" size = %s\n", sizeinfo); fpout = fopen((char *)strcat(argv[2],sizeinfo),"w"); if(fpout==null) { fprintf(stderr," outfile open error\n"); exit(9); for (i=0; i<nx*ny; i++) { fread((char *)&alpha, sizeof(char), 1, fpin); fread((char *)&red, sizeof(char), 1, fpin); fread((char *)&green, sizeof(char), 1, fpin); fread((char *)&blue, sizeof(char), 1, fpin); fwrite((char *)&red, sizeof(char), 1, fpout); fwrite((char *)&green, sizeof(char), 1, fpout); fwrite((char *)&blue, sizeof(char), 1, fpout); n end of x2texturec /

115 [1] MJ Kilgard, OpenGL Programming for the X Window System, Addison-Wesley, 1996 [2] OpenGL Architecture Review Board, J Neider, T Davis and M Woo, OpenGL TM Programming Guide, Adison-Wesley, 1993 [3], OpenGL TM Programming Guide ( ),, 1993 [4] OpenGL Architecture Review Board, J Neider, T Davis and M Woo, OpenGL TM Programming Guide, Second Edition, Adison-Wesley, 1997 [5], OpenGL TM Programming Guide, Second Edition ( ),, 1997 [6] OpenGL Architecture Review Board, OpenGL TM Reference Manual, Second Edition, Adison-Wesley, 1996 [7], OpenGL TM 3D,,

116

/*p7-1-1*/

/*p7-1-1*/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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 /* e8.c Copyright (c) 2003 by T. HAYASHI and

More information

OpenGL & GLUTの基本関数の説明

OpenGL & GLUTの基本関数の説明 コンピュータグラフィックス S 演習資料 OpenGL & GLUT の基本関数の説明 1. OpenGL & GLUT 2. GLUT 2.1. GLUT void glutinit( int argc, char ** argv ); glut void glutinitdysplaymode( unsigned int mode ); mode void glutinitwindowsize(

More information

1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - >

1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 8 (240 O p e n C V ) 9 opencv_core240d.lib 10 opencv_imgproc240d.lib

More information

2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix()

2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix() 1 20 (2) OpenGL+GUI(GLUI) 3DCG TA 2008 10 27 1 OpenGL OpenGL GUI GLUI 1.1 http://www.cyber.t.u-tokyo.ac.jp/~kuni/enshu2008/ 1.2 TA 1.3 2008/12/4( ) EyeToy 2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut

More information

3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程

3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程 3. 3D ビューイング 1. 3Dグラフィックス処理の一般過程 2. 射影と射影変換 3. ビューボリュームとクリッピング 4. 陰面処理とデプスバッファ 5. ビューポート変換 6. 3Dグラフィックスを描く 7. モデルビュー変換 3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程 3D グラフィックス処理の一般過程 1. モデリング変換 座標系の異なる複数のオブジェクトを仮想世界に配置し,

More information

#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta

#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta 1 1. 1 #include 2 #include 3 #include 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 static bool KeyDownON = false; // 8 static bool KeyLeftON

More information

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t 1 22 (2) OpenGL+GUI(GLUI) 3DCG TA 2010 10 18 1 OpenGL OpenGL GUI GLUI 1.1 http://www.cyber.t.u-tokyo.ac.jp/~kuni/enshu2010/ 1.2 TA 1.3 2010/12/6( ) USB 2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height

More information

第3章 OpenGL の基礎

第3章 OpenGL の基礎 3 OpenGL April 11, 2017 1 / 28 3.1 ( ) OpenGL OpenGL 2 / 28 3.2 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc. 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh

More information

第3章 OpenGL の基礎

第3章 OpenGL の基礎 3 OpenGL April 20, 2012 1 / 23 31 ( ) OpenGL OpenGL 2 / 23 32 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh CAD

More information

1 3 2 OpenGL 4 3 OpenGL 5 4 OpenGL 6 OpenGl : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 6 : : : : : : : : : : : : : : : : : : : : :

1 3 2 OpenGL 4 3 OpenGL 5 4 OpenGL 6 OpenGl : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 6 : : : : : : : : : : : : : : : : : : : : : 1999 OpenGL S96M501 S96M596 S96M649 1 3 2 OpenGL 4 3 OpenGL 5 4 OpenGL 6 OpenGl : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 6 : : : : : : : : : : : : : : : : : : : : : 7 5 10 OpenGL :

More information

/* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLU

/* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLU OpenGL ( ) #include #include #define PI 3.14159265 void function_graph() int j; float x, y; glbegin( GL_LINE_STRIP );// sine curve by line glcolor3f( 0.0f, 1.0f, 1.0f );// line color

More information

OpenGL Programming Course OpenGL Programming Course FAQ

OpenGL Programming Course OpenGL Programming Course FAQ OpenGL NK EXA Corporation [email protected] [email protected] OpenGL FAQ (http://www.nk-exa.co.jp/mmtech/opengledu/faq.shtml) i 1 OpenGL 1{1 1.1 OpenGL : : : : : : : : : : : : : : : : : : :

More information

Fair Curve and Surface Design System Using Tangent Control

Fair Curve and Surface Design System Using Tangent Control 情報工学 2016 年度後期第 6 回 [11 月 16 日 ] 静岡大学工学研究科機械工学専攻ロボット 計測情報講座創造科学技術大学院情報科学専攻 三浦憲二郎 講義アウトライン [11 月 16 日 ] ビジュアル情報処理 3 モデリング 3.3 曲線 曲面 OpenGL 色の取り扱い シェーディング 照明モデルと照光処理 拡散光 鏡面光 環境光 ビジュアル情報処理 3-3 曲線 曲面 3-3-1

More information

2 2 OpenGL ( ) OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf

2 2 OpenGL ( ) OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf 1 24 (1) OpenGL TA 2012 10 11 1 C OpenGL (3DCG) OS Linux OS 3DCG OpenGL GUI GLUT OpenGL GLUT GLUI 3DCG 3DCG 1.1 1 3DCG 3DCG GUI 2 3DCG 10/10( ) 11/11( ) 3DCG OpenGL OpenGL+GUI(GLUI) 3DCG 3DCG 1.2 TA 2

More information

NB

NB JAPLA 研究会資料 2010/2/27 J の OpenGL グラフィックス - その 7 - フラー ドームと照光表示 - 西川利男 0. はじめに OpenGL 正多面体グラフィックスとして 今回はフラー ドームに挑戦してみた バックミンスター フラー (Richard Buckminster Fuller, 1895-1983 は多才な建築家 科学者 思想家として知られ その名前を冠した

More information

2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN, IBM UNIX Linux, FreeBSD PC UNIX Windows, Mac OS API PD

2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN, IBM UNIX Linux, FreeBSD PC UNIX Windows, Mac OS API PD 1 2015 5-1 2015 6 22 1 3DCG 3DCG 3DCG OpenGL OS Linux(Ubuntu) 1.1 TA 1.2 http://www.cyber.t.u-tokyo.ac.jp/~tani/class/mech_enshu/ 2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI)

More information

2 2 OpenGL ( ) 2 OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf blu

2 2 OpenGL ( )  2 OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf blu 1 27 (1) OpenGL TA 2015 9 29 1 C OpenGL (3DCG) OS Linux OS 3DCG OpenGL 3DCG 3DCG 1.1 1 3DCG 3DCG 2 3DCG GUI AR 9/29( ) 10/1( ) 3DCG OpenGL 3DCG 3DCG 1.2 TA 1.3 2 2 OpenGL ( ) http://www.cyber.t.u-tokyo.ac.jp/~tani/class/mech_enshu/

More information

2 2 OpenGL OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN,

2 2 OpenGL OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN, 1 20 (1) OpenGL TA 2008 10 20 1 C OpenGL (3DCG) OS Linux (Open SUSE 10.3) 3DCG OpenGL GUI GLUT OpenGL GLUT GLUI USB EyeToy 1.1 1 3DCG 2 3DCG GUI 2 USB EyeToy) 10/20( ) 10/27( ) 3DCG OpenGL OpenGL+GUI(GLUI)

More information

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t 1 24 (2) 3DCG TA 2012 10 12 1 OpenGL USB (3DCG) OpenCV 1.1 http://www.cyber.t.u-tokyo.ac.jp/~tani/class/mech_enshu/ 1.2 TA 1.3 USB (2012/11/19( ),20( )) USB 2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width

More information

JAPLAシンポジウム資料 2009/12/5

JAPLAシンポジウム資料 2009/12/5 JAPLA シンポジウム資料 2009/12/5 J の OpenGL グラフィックス - その 5 - 正 12 面体と正 20 面体を動かす - 西川利男 正 12 面体と正 20 面体との頂点座標が別報 [1] のように計算されたので それを用いて J の OpenGL により 3 D グラフィックス図形を描き いろいろ動かしてみる 1. 正 12 面体と正 20 面体の J プログラム (J402

More information

コンピュータグラフィックスS 演習資料

コンピュータグラフィックスS 演習資料 コンピュータグラフィックス S 演習資料 第 4 回シェーディング マッピング 九州工業大学情報工学部システム創成情報工学科講義担当 : 尾下真樹 1. 演習準備 今回の演習も 前回までの演習で作成したプログラムに続けて変更を行う まずは シェーディングの演習のため 描画処理で 回転する一つの四角すいを描画するように変更する 画面をクリア ( ピクセルデータと Z バッファの両方をクリア ) glclear(

More information

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena $ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a $ ls -l $ ls -l -a $ ls -la $ ls -F $ ls $ cd $ cd $ pwd $ cat

More information

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E 8 9 7 6 4 2 3 5 1 j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E a n 1 H = ae l j, j=1 l j = x j+1 x j, x n x 1 = n 1 j=1 l j, l j = ±l l > 0) n 1 H = ϵ l j, j=1 ϵ e x x

More information

double rx[natom], ry[natom], rz[natom]; 原子の座標 速度 力 ポテンシャルエ double vx[natom], vy[natom], vz[natom]; ネルギーを受ける配列を準備 double fx[natom], fy[natom], fz[natom

double rx[natom], ry[natom], rz[natom]; 原子の座標 速度 力 ポテンシャルエ double vx[natom], vy[natom], vz[natom]; ネルギーを受ける配列を準備 double fx[natom], fy[natom], fz[natom GLUI による MD の GUI 化 前提条件 :GLUI のプログラミング環境が整っていること 3 原子の MD コード ( 下図 ) viewer ウィンドウ内のマウス左クリックで MD 開始 右クリックで MD 停止 control パネルは solid/wireframe を切り替えるチェックボタン 球の滑らかさと半径を決める窓 ( スピナー ) オブジェクトを回転 移動 拡大縮小させるコントローラ

More information

コンピュータグラフィックス特論Ⅱ

コンピュータグラフィックス特論Ⅱ コンピュータグラフィックス特論 Ⅱ 第 2 回 OpenGL プログラミングの基礎 九州工業大学尾下真樹 今日の内容 OpenGL プログラミングの基礎 C 言語 +OpenGL+GLUT によるプログラミング 座標変換の基礎 アフィン変換行列を使った視野変換の設定 いずれも 学部の講義 ( レベルの内容 ) の復習 今日の内容 OpenGL&GLUTの概要 サンプルプログラムの概要 座標変換 変換行列の設定

More information

謗域・ュ逕ィppt

謗域・ュ逕ィppt 情報工学 212 年度後期第 5 回 [1 月 31 日 ] 静岡大学 創造科学技術大学院情報科学専攻工学部機械工学科計測情報講座 三浦憲二郎 講義日程 第 8 回 11 月 21 日 ( 水 ) CG パート試験 講義アウトライン [1 月 31 日 ] ビジュアル情報処理 1.3.4 投影変換 1.3.5 いろいろな座標系と変換 OpenGL 投影変換 曲線の描画 トロコイド ( 外トロコイドと内トロコイド

More information

コンピュータグラフィックス特論Ⅱ

コンピュータグラフィックス特論Ⅱ 今日の内容 コンピュータグラフィックス特論 Ⅱ 第 2 回 OpenGL プログラミングの基礎 九州工業大学尾下真樹 OpenGL プログラミングの基礎 C 言語 +OpenGL+GLUT によるプログラミング 座標変換の基礎 アフィン変換行列を使った視野変換の設定 いずれも 学部の講義 ( レベルの内容 ) の復習 今日の内容 OpenGL&GLUTの概要 サンプルプログラムの概要 座標変換 変換行列の設定

More information

Microsoft PowerPoint - info_eng3_05ppt.pptx

Microsoft PowerPoint - info_eng3_05ppt.pptx インタラクティブシステム構築法 第 5 回 OpenGL と GLUT の使い方 (3) 埼玉大学情報システム工学科小林貴訓 シェーディング 光源の設定を有効にする glenable(gl_lighting); // 光源の設定を有効にする glenable(gl_light0); //0 番目の光源を有効にする (8 個まで設定可能 ) 光源の位置 GLfloat light0pos[] = {

More information

Kageyama (Kobe Univ.) 2015.06.23 2 / 41

Kageyama (Kobe Univ.) 2015.06.23 2 / 41 2015 2015.06.23 Kageyama (Kobe Univ.) 2015.06.23 1 / 41 Kageyama (Kobe Univ.) 2015.06.23 2 / 41 [ 1, +1] [ 1, +1] [ 1, +1] Kageyama (Kobe Univ.) 2015.06.23 3 / 41 Kageyama (Kobe Univ.) 2015.06.23 4 / 41

More information

2 2 2 OpenGL Linux Linux Video for Linux(Video4Linux, v4l ) API Video4Linux USB IEEE1394 API Linux Video for Linux 2(Video4Linux2, v4l2 ) OpenCV API U

2 2 2 OpenGL Linux Linux Video for Linux(Video4Linux, v4l ) API Video4Linux USB IEEE1394 API Linux Video for Linux 2(Video4Linux2, v4l2 ) OpenCV API U 1 26 (2) 3DCG TA 2014 10 17 1 OpenGL USB (3DCG) OpenCV CG Augmented Reality ARToolKit 3DCG 1.1 http://www.cyber.t.u-tokyo.ac.jp/~tani/class/mech_enshu/ 1.2 TA 1.3 ( ) USB (2014/11/10( ),11( ),13( )) (2012/11/17(

More information

PowerPoint Presentation

PowerPoint Presentation 8-1 8. テクスチャマッピング 8.1. テクスチャマッピングの原理 狭義には, 図のように, 与えられた画像を物体に貼り付ける方法. マッピングには投影法, 極座標変換, パラメータマッピングなどがある (1 年 コンピュータ グラフィックス ). 広義にはバンプマッピングなども含まれる. t y s z x 8-2 8.2. テクスチャマッピングの設定方法 全体の流れ 1) 原図ビットマップデータを内部形式に変換

More information

JAPLA研究会資料 2013/5/25

JAPLA研究会資料  2013/5/25 JAPLA 研究会資料 2013/5/25 J-OpenGL による 4 進フラクタル立体木のグラフィックス 西川利男 今年の大学センター試験の出題をきっかけとして 3 進法およびそれを活用した 3 進フラクタル木の J プログラムについて先に報告した [1][2] 図形表示の値を 3 進法で表すことで フラクタル木のグラフィックスが ごく自然に行われた それでは 4 進法ではどうだろうか? 同じ発想を展開すると

More information

WebGL OpenGL GLSL Kageyama (Kobe Univ.) Visualization / 57

WebGL OpenGL GLSL Kageyama (Kobe Univ.) Visualization / 57 WebGL 2014.04.15 X021 2014 3 1F Kageyama (Kobe Univ.) Visualization 2014.04.15 1 / 57 WebGL OpenGL GLSL Kageyama (Kobe Univ.) Visualization 2014.04.15 2 / 57 WebGL Kageyama (Kobe Univ.) Visualization 2014.04.15

More information

Tekutama AR ~ 拡張現実感によるオーバーレイ表示と動作 ~ 情報物理研究室 渡部 修平 1

Tekutama AR ~ 拡張現実感によるオーバーレイ表示と動作 ~ 情報物理研究室 渡部 修平 1 Tekutama AR ~ 拡張現実感によるオーバーレイ表示と動作 ~ 情報物理研究室 渡部 修平 1 目次 項 1. はじめに 3 2. 開発環境 4 2-1. ARToolkit 4 2-2. OpenGL GLUT 5 2-3. Metasequoia 6 2-4. GLMetaseq 6 3. 3DCG モデルの作成 7 4. AR プログラムの構成 9 4-1. main 関数 10 4-2.

More information

Microsoft Word - opengl講義資料2013.doc

Microsoft Word - opengl講義資料2013.doc [OpenGL:1] OpenGL とは 1.OpenGL とは何か? 米国 Silicon Graphics 社 (SGI) が中心となって開発した 3 次元グラフィックスライブラリである.SGI はグラフィックスに特化したワークステーション (GWS) の開発を積極的に行い, 自社の GWS 上で稼動するグラフィックスライブラリ IRIS GL を開発したが, その後, この仕様を公開したライブラリとして

More information

コンピューターグラフィックスS

コンピューターグラフィックスS コンピューターグラフィックス S 第 12 回シェーディング マッピング システム創成情報工学科尾下真樹 2018 年度 Q2 今回の内容 前回の復習 シェーディング 光のモデル スムーズシェーディング シェーディング ( 続き ) OpenGL での光源情報の設定 ラジオシティ 影の表現 BRDF マッピング 今回の内容 シェーディング 光の効果の表現 マッピング 生成画像 表面の素材の表現 オブジェクト

More information

3. OpenGL を利用するための準備作業 1) Tao Framework をダウンロードしてインストールする. Download から taoframework setup.exe をダウン

3. OpenGL を利用するための準備作業 1) Tao Framework をダウンロードしてインストールする.   Download から taoframework setup.exe をダウン [OpenGL:1] OpenGL とは 1.OpenGL とは何か? 米国 Silicon Graphics 社 (SGI) が中心となって開発した 3 次元グラフィックスライブラリである.SGI はグラフィックスに特化したワークステーション (GWS) の開発を積極的に行い, 自社の GWS 上で稼動するグラフィックスライブラリ IRIS GL を開発したが, その後, この仕様を公開したライブラリとして

More information

準備 計算結果を可視化するために OpenGL を 利用する. 2

準備 計算結果を可視化するために OpenGL を 利用する. 2 2. 2 次元粒子法シミュレーション (+ 少しだけ OpenGL) 茨城大学工学部 教授乾正知 準備 計算結果を可視化するために OpenGL を 利用する. 2 OpenGL 3 次元コンピュータグラフィックス用の標準的なライブラリ. 特に CAD やアート, アニメーション分野 ( ゲーム以外の分野 ) で広く利用されている. OpenGL は仕様がオープンに決められており, 企業から独立した団体が仕様を管理している.

More information

adv99_4.PDF

adv99_4.PDF Advanced Graphics Programing Techniques Using OpenGL Section 6 Texture Mapping (page 40 77) 1 6 Texture Mapping(1) 2 6 Texture Mapping(2) ( ) ( ) OpenGL 3 6.1 Texture Basics 4 6.1.1 The Texture Image(1)

More information

コンピュータグラフィックスS 演習資料

コンピュータグラフィックスS 演習資料 2015/5/26 コンピュータグラフィックスS 演 習 資 料 第 2 回 ポリゴンモデルの 描 画 九 州 工 業 大 学 情 報 工 学 部 システム 創 成 情 報 工 学 科 講 義 担 当 : 尾 下 真 樹 1. 準 備 : 前 回 の 演 習 本 日 の 演 習 は 前 回 の 演 習 で 作 成 したプログラムを 引 き 続 き 修 正 していく もし 前 回 の 演 習 を 行

More information

2

2 L C -24K 9 L C -22K 9 2 3 4 5 6 7 8 9 10 11 12 11 03 AM 04 05 0 PM 1 06 1 PM 07 00 00 08 2 PM 00 4 PM 011 011 021 041 061 081 051 071 1 2 4 6 8 5 7 00 00 00 00 00 00 00 00 30 00 09 00 15 10 3 PM 45 00

More information

HIS-CCBASEver2

HIS-CCBASEver2 Information Access Interface in the Immersive Virtual World Tetsuro Ogi, *1*2*3 Koji Yamamoto, *3*4 Tadashi Yamanouchi *3 and Michitaka Hirose *2 Abstract - In this study, in order to access database server

More information

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h> 2007 12 5 1 2 2.1 ( ) 1 1: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 #define H WIN 400 // 8 #define W WIN 300 // 9

More information

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber();

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber(); : : :0757230G :2008/07/18 2008/08/17 1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include class Number Number(); // ~Number(); // void setnumber(float n); float getnumber(); private: float num; ;

More information

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1 I117 II I117 PROGRAMMING PRACTICE II 2 MEMORY MANAGEMENT 2 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara [email protected] / SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming

More information

X Window System X X &

X Window System X X & 1 1 1.1 X Window System................................... 1 1.2 X......................................... 1 1.3 X &................................ 1 1.3.1 X.......................... 1 1.3.2 &....................................

More information

10 B 3. ( ) (3)

10 B 3. ( ) (3) Augus 5, 009 10 B 3. ( ) (3) ( ) 1 OpenGL CG 1 C OpenGL 3 CG 4 OpenGL 1. 1 OpenGL CG 1 C 1.1 I C [1] es.c C es.obj es.exe *.lib *.obj C 1. C I C #include < > in main( ) { reurn 0; } { reurn ; } Hellow

More information

TA TA TA abcdefgh abcdefgh C PC Wii bluetooth 2.2 Bluetooth USB Princeton PTM-UBT3S 1 1

TA TA TA abcdefgh abcdefgh C PC Wii bluetooth 2.2 Bluetooth USB Princeton PTM-UBT3S 1 1 1 22 (2) TA: 2010 12 13 1 OpenGL Wii Wii OpenGL USB (3DCG) 1.1 http://www.cyber.t.u-tokyo.ac.jp/~kuni/enshu2010/ URL USB 2 2 1.2 TA 16 15 TA TA [email protected] 20101213 abcdefgh abcdefgh

More information

免許法認定公開講座: コンピュータグラフィックス

免許法認定公開講座:コンピュータグラフィックス 演習内容 免許法認定公開講座 : コンピュータグラフィックス 第 6 回 3 次元グラフィックス演習 基本的な3 次元グラフィックスのプログラムを作成 OpenGL を使ったポリゴン描画 視点操作 アニメーション 九州工業大学情報工学部システム創成情報工学科尾下真樹 参考書 最低限の関数は資料で説明 OpenGLの定番の本 ( 高い ) OpenGLプログラミングガイド ( 赤本 ), 12,000

More information

L C -6D Z3 L C -0D Z3 3 4 5 6 7 8 9 10 11 1 13 14 15 16 17 OIL CLINIC BAR 18 19 POWER TIMER SENSOR 0 3 1 3 1 POWER TIMER SENSOR 3 4 1 POWER TIMER SENSOR 5 11 00 6 7 1 3 4 5 8 9 30 1 3 31 1 3 1 011 1

More information

演算増幅器

演算増幅器 スペースインベーダーもどき 1000 行プログラムの参考として スペースインベーダーもどきのプログラムを配布する いくつか習って いないものもあるので 補足の説明を加えていく 文字列の描画 文字の描画は glutbitmapcharacter() を用いる これは以下のようにして利用する int i; char *str = "Display String"; glcolor3f(0.0, 0.0,

More information

1 level Level swtich ButtonPress ButtonRelease Expose Level

1 level Level swtich ButtonPress ButtonRelease Expose Level UNIX 4 2D/3D Grahpics,GUI :2-3 - 045708G 045726E 045730C 045735D 045759B 045762B 1 level1 1 11 2 12 4 13 6 14 6 2 Level2 6 21 6 211 swtich 11 212 ButtonPress 11 213 ButtonRelease 12 214 Expose 12 22 12

More information

r08.dvi

r08.dvi 19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

2

2 L C -60W 7 2 3 4 5 6 7 8 9 0 2 3 OIL CLINIC BAR 4 5 6 7 8 9 2 3 20 2 2 XXXX 2 2 22 23 2 3 4 5 2 2 24 2 2 25 2 3 26 2 3 6 0 2 3 4 5 6 7 8 9 2 3 0 2 02 4 04 6 06 8 08 5 05 2 3 4 27 2 3 4 28 2 3 4 5 2 2

More information

コンピューターグラフィックスS

コンピューターグラフィックスS コンピューターグラフィックス S 第 2 回コンピュータグラフィックスの要素技術 システム創成情報工学科尾下真樹 2018 年度 Q2 今回の内容 前回の復習 コンピュータグラフィックスの歴史と応用 3 次元グラフィックスの要素技術 3 次元グラフィックス プログラミング 教科書 ( 参考書 ) コンピュータグラフィックス CG-ARTS 協会編集 出版 (3,200 円 ) 1~5 章の概要 ビジュアル情報処理

More information

Complex Lab – Operating Systems - Graphical Console

Complex Lab – Operating Systems - Graphical Console Complex Lab Operating Systems Graphical Console Martin Küttler Last assignment Any questions? Any bug reports, whishes, etc.? 1 / 13 We are here Pong Server Paddle Client 1 Paddle Client 2 Memory Management

More information

コンピューターグラフィックスS

コンピューターグラフィックスS 前回の演習の復習 今日の内容 コンピューターグラフィックス S 第 7 回演習 (2): ポリゴンモデルの描画 システム創成情報工学科尾下真樹 前回の復習 ポリゴンの描画方法 ( 復習 ) 基本オブジェクトの描画 ポリゴンモデルの描画 演習課題 サンプルプログラム 前回の演習の復習 opengl_sample.c 地面と 枚の青い三角形が表示される マウスの右ボタンドラッグで 視点を上下に回転 前回の演習課題.

More information

C

C C 1 2 1.1........................... 2 1.2........................ 2 1.3 make................................................ 3 1.4....................................... 5 1.4.1 strip................................................

More information

ProVisionaire Control V3.0セットアップガイド

ProVisionaire Control V3.0セットアップガイド ProVisionaire Control V3 1 Manual Development Group 2018 Yamaha Corporation JA 2 3 4 5 NOTE 6 7 8 9 q w e r t r t y u y q w u e 10 3. NOTE 1. 2. 11 4. NOTE 5. Tips 12 2. 1. 13 3. 4. Tips 14 5. 1. 2. 3.

More information

1 OpenGL OpenGL OpenGL OpenGL

1 OpenGL OpenGL OpenGL OpenGL 2008 OpenGL 2009 2 27 1 OpenGL 4 1.1 OpenGL.............................. 4 1.2 OpenGL............... 4 1.2.1............... 4 1.2.2............................. 5 2 OpenGL 6 2.1.......................

More information

,,,,., C Java,,.,,.,., ,,.,, i

,,,,., C Java,,.,,.,., ,,.,, i 24 Development of the programming s learning tool for children be derived from maze 1130353 2013 3 1 ,,,,., C Java,,.,,.,., 1 6 1 2.,,.,, i Abstract Development of the programming s learning tool for children

More information

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for embedded systems that use microcontrollers (MCUs)

More information

Microsoft Word - Meta70_Preferences.doc

Microsoft Word - Meta70_Preferences.doc Image Windows Preferences Edit, Preferences MetaMorph, MetaVue Image Windows Preferences Edit, Preferences Image Windows Preferences 1. Windows Image Placement: Acquire Overlay at Top Left Corner: 1 Acquire

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション 複雑系科学演習 1 コンピュータグラフィックス 担当畔上秀幸情報科学研究科複雑系科学専攻 今日の話題 ベジェ曲線 曲面の描画 lesson9_1.c( ベジェ曲線 ) lesson9_2.c( 色付きベジェ曲線 ) lesson9_3.c( ベジェ曲面 ) NURBS 曲線 曲面の描画 lesson9_4.c(nurbs 曲線 ) lesson9_5.c(nurbs 曲線の分割 ) lesson9_6.c(nurbs

More information

GNU Emacs GNU Emacs

GNU Emacs GNU Emacs GNU Emacs 2015 10 2 1 GNU Emacs 1 1.1....................................... 1 1.2....................................... 1 1.2.1..................................... 1 1.2.2.....................................

More information