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

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

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 2 OpenGL ( ) 2 OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf blu

第3章 OpenGL の基礎

第3章 OpenGL の基礎

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 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

OpenGL Programming Course OpenGL Programming Course FAQ

OpenGL & GLUTの基本関数の説明

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

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

/*p7-1-1*/

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

( ) 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>

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

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

謗域・ュ逕ィppt

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

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

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

manual.dvi

演算増幅器

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

1 OpenGL OpenGL OpenGL OpenGL

沼津工業高等専門学校

10 B 3. ( ) (3)

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

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

1 level Level swtich ButtonPress ButtonRelease Expose Level

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

JAPLA研究会資料 2013/5/25

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

Kageyama (Kobe Univ.) / 41

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

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

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

Microsoft Word - C.....u.K...doc

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

複雑系科学演習1 コンピュータグラフィックス

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

Microsoft PowerPoint - info_eng3_05ppt.pptx

新版明解C言語 実践編

NB


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

Microsoft Word - opengl講義資料2013.doc

joho07-1.ppt

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

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

r08.dvi

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

r07.dvi

ohp07.dvi

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

PowerPoint Presentation

ex01.dvi

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

ohp03.dvi

WebGL Safari WebGL WebGL Safari Kageyama (Kobe Univ.) / 5

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

PowerPoint プレゼンテーション

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

tuat1.dvi

Transcription:

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 2 OpenGL ( ) 1.3 http://www.cyber.t.u-tokyo.ac.jp/~tani/class/mech_enshu/ 2 OpenGL ( ) 2.1 2.1.1 glclearcolor(glclampf red, GLclampf green, GLclampf blue, GLclampfalpha); GLglampf 0.0 1.0 alpha glutclearcolor(0.0, 0.0, 0.0, 0.0); 2.1.2 glclearcolor glclear(gl_color_buffer_bit); 2.1.3 glflush(); 1 2.2 glut GLUT(OpenGL Utility Toolkit) GLUT Windows X window system GLUT 3.7 GLU 3 GLUT glutinit void glutinit(int *argcp, char **argv);

2.2 glut 3 argcp main argc GLUT argv main argv GLUT X Window System GLUT -display, -geometry man X void glutinitwindowposition(int x, int y); void glutinitwindowsize(int width, int height); x, y width, height 1 OpenGL glutinitwindow* OpenGL glutinitwindow* (OpenGL ) glutinitdisplaymode void glutinitdisplaymode(unsigned int mode); mode RGBA (GLUT RGBA or GLUT INDEX)

4 2 OpenGL ( ) (GLUT DEPTH) (GLUT SINGLE or GLUT DOUBLE) RGBA glutinitdisplaymode(glut_rgba GLUT_DOUBLE GLUT_DEPTH); OpenGL int glutcreatewindow(char *titlestring); titlestring OpenGL OpenGL void glutpostredisplay(void); display 1 1 void glutmainloop(void); glutdisplayfunc 2.3 OpenGL glcolor3f(glclampf red, GLclampf green, GLclampf blue); 0.0 1.0 3 glcolor3f(1.0f, 1.0f, 0.0f); glbegin(glenum mode);

2.3 OpenGL 5 mode (GL POLYGON) (GL TRIANGLE FAN) ( ) (GL TRIANGLE STRIP) (GL LINES) (GL POINTS) glend(); glvertex3f(glfloat x, GLfloat y, GLfloat z); glvertex* 3 3 (x, y, z) f 32bit (GLfloat)

6 3 ( ) 3 ( ) 3.1 1. 2. 3. 4. OpenGL 1. ( ) 2. ( ) 3. ( ) ( ) 4. ( ) 2 OpenGL OpenGL 4x4 M v v 4 (x, y, z, w) w 1 v = Mv

3.2 OpenGL 7 w 3 OpenGL 3.2 OpenGL glmatrixmode() void glmatrixmode(glenum mode); mode GL MODELVIEW GL PROJECTION GL TEXTURE. glloadidentity() void glloadidentity(void); 4x4 3 OpenGL gltranslate*() glrotate*() glscale*() ( ) 3.

8 3 ( ) void gltranslate{fd(type x, TYPE y, TYPE z); x, y, z ( ) void glrotate{fd(type angle, TYPE x, TYPE y, TYPE z); (x, y, z) ( ) angle glrotatef(45.0, 0.0, 0.0, 1.0) z 45 void glscale{fd(type x, TYPE y, TYPE z); x, y, z x, y, z x, y, z (gltranslate*() glrotate*()) OpenGL Utility Library(GLU) glulookat(). void glulookat(gldouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz); eyex, eyey, eyez centerx, centery, centerz upx, upy, upz z y glfrustum() gluperspective() glortho() gluortho2d()

3.2 OpenGL 9. glmatrixmode(gl_projection); glloadidentity(); void gluperspective(gldouble fovy, GLdouble aspect, GLdouble near, GLdouble far); fovy x-z [0.0, 180.0] aspect near far z ( ) 4 glperspective() glviewport() 2 void glviewport(glint x, GLint y, GLsizei width, GLsizei height); (x, y) width height (0, 0, winwidth, winheight) winwidth, winheight

10 4 ( ) 4 ( ) 4.1 OpenGL (geometric primitive) (Vertex) 3 2 (x, y) z 0 Vertex OpenGL (convex). GLU 4.2 OpenGL OpenGL glvertex*() void glvertex{234{sifd[v](type coords) : glvertex2s(2, 3); glvertex3f(2.3, 1.1, -2.2); GLdouble dvect[3]={5.0, 9.0, 1992.0; glvertex3dv(dvect);

4.2 OpenGL 11 glvertex*() glbegin() glend() glbegin() : glbegin(gl_polygon); glvertex2f(0.0, 0.0); glvertex2f(0.0, 3.0); glvertex2f(4.0, 3.0); glvertex2f(6.0, 1.5); glvertex2f(4.0, 0.0); glend(); 5 OpenGL glbegin() glend() glvertex*()

12 4 ( ) glbegin(gl_polygon); glend(); glbegin(gl_triangle_fan); glend(); glbegin(gl_triangle_strip); glend(); glbegin(gl_lines); glend(); GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON. : glbegin(gl_points); glcolor3f(0.0, 1.0, 0.0); glvertex(...); glcolor3f(1.0, 1.0, 0.0); glvertex(...); glvertex(...); glend();. : #define PI 3.1415926535898 GLint circle_points=100; glbegin(gl_line_loop); for(i=0; i<circle_points; i++){ angle = 2*PI*i/circle_points; glvirtex2f(cos(angle), sin(angle)); glend();

4.3 13 4.3 glpointsize() void glpointsize(glfloat size); 1.0 void gllinewidth(glfloat width); void gllinestipple(glint factor, GLushort pattern); (width) pattern 16 0 1 1 0 factor pattern gllinestipple(1, 0x3F07); glenable(gl_line_stapple); 0x3f07 (2 0011111100000111 ) 3 ON 5 OFF 6 ON 2 OFF factor 2 6 ON 10 OFF 12 ON 4 OFF gllinestipple() glenable() glpolygonmode() void glpolygonmode(glenum face, GLenum mode); face GL FRONT AND BACK, GL FRONT, GL BACK mode GL POINT( ), GL LINE( ), GL FILL( )

14 4 ( ) void glfrontface(glenum mode); void glcullface(glenum mode); ( ) glfrontface() glcullface(gl BACK) glenable(gl CULL FACE). 4.4 GLUT GLUT 9 2 OpenGL void glutwiresphere(gldouble radius, GLint slices, GLint stacks); void glutsolidsphere(gldouble radius, GLint slices, GLint stacks); glutsolidsphere glutwiresphere radius radius slices Z ( ) stacks Z ( ) void glutwirecube(gldouble size); void glutsolidcube(gldouble size); glutwirecube glutsolidcube size size

4.4 GLUT 15 void glutwiretorus(gldouble innerradius, GLdouble outerradius, GLint nsides, GLint rings); void glutsolidtorus(gldouble innerradius, GLdouble outerradius, GLint nsides, GLint rings); glutsolidtorus glutwiretorus Z innerradius outerradius nsides rings void glutwireicosahedron(void); void glutsolidicosahedron(void); void glutwireoctahedron(void); void glutsolidoctahedron(void); void glutwiretetrahedron(void); void glutsolidtetrahedron(void); void glutwiredodecahedron(void); void glutsoliddodecahedron(void); glutsolidisosahedron glutwireisosahedron 1.0 20 glutsolidoctahedron glutwireoctahedron 1.0 8 glutsolidtetrahedron glutwiretetrahedron 3 4 glutsoliddodecahedron glutwiredodecahedron 3 12 void glutwirecone(gldouble radius, GLdouble height, GLint slices, GLint stacks); void glutsolidcone(gldouble radius, GLdouble height, GLint slices, GLint stacks); glutsolidcone glutwirecone Z Z=0 Z=height Z slices

16 4 ( ) Z stacks base height slices Z stacks Z void glutwireteapot(gldouble size); void glutsolidteapot(gldouble size); glutsolidteapot glutwireteapot OpenGL size

17 5 5.1 (glloadmatrix(), glmultmatrix(), glloadidentity() ) glpushmatrix() glpopmatrix() ( ) glpushmatrix() glpopmatrix() 6 void glpushmatrix(void); 1 2 glmatrixmode() void glpopmatrix(void); 2

18 5 glmatrixmode() glpopmatrix() 32 4x4 glloadidentity() 2 2 3 glmatrixmode(gl_projection); glpushmatrix(); /* save the current projection */ glloadidentity(); glortho(...); /* set up for displaying help */ display_the_help(); glpopmatrix(); 5.2 4 5 ( ) 4 5

5.2 19 7 draw_wheel_and_bolts() { long i; draw_wheel(); for(i=0;i<5;i++){ glpushmatrix(); glrotatef(72.0*i,0.0,0.0,1.0); gltranslatef(3.0,0.0,0.0); draw_bolt(); glpopmatrix();

20 5 draw_body_and_wheel_and_bolts() { draw_car_body(); glpushmatrix(); gltranslatef(40,0,30); /*move to first wheel position*/ draw_wheel_and_bolts(); glpopmatrix(); glpushmatrix(); gltranslatef(40,0,-30); /*move to 2nd wheel position*/ draw_wheel_and_bolts(); glpopmatrix();... /*draw last two wheel similarly*/ 72 3 40 30 5.3 glrotate*() gltranslate*() glutwiresphere() 2 glpushmatrix(); glutwiresphere(1.0, 20, 16); /* draw sun */ glrotatef ((GLfloat) year, 0.0, 1.0, 0.0); gltranslatef (2.0, 0.0, 0.0); glrotatef ((GLfloat) day, 0.0, 1.0, 0.0); glutwiresphere(0.2, 10, 8); /* draw smaller planet */ glpopmatrix(); glrotate*() gltranslate*()

5.3 21 glrotate*() ( ) 2 glrotate*() ( ) 8 #include <GL/glut.h> #include <stdlib.h> static int year = 0, day = 0; void init(void) { glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel (GL_FLAT); void display(void) { glclear (GL_COLOR_BUFFER_BIT); glcolor3f (1.0, 1.0, 1.0); glpushmatrix(); glutwiresphere(1.0, 20, 16); /* draw sun */ glrotatef ((GLfloat) year, 0.0, 1.0, 0.0); gltranslatef (2.0, 0.0, 0.0); glrotatef ((GLfloat) day, 0.0, 1.0, 0.0); glutwiresphere(0.2, 10, 8); /* draw smaller planet */ glpopmatrix(); glutswapbuffers();

22 5 void reshape (int w, int h) { glviewport (0, 0, (GLsizei) w, (GLsizei) h); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective(60.0, (GLfloat) w/(glfloat) h, 1.0, 20.0); glmatrixmode(gl_modelview); glloadidentity(); glulookat (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); /* ARGSUSED1 */ void keyboard (unsigned char key, int x, int y) { switch (key) { case d : day = (day + 10) % 360; glutpostredisplay(); break; case D : day = (day - 10) % 360; glutpostredisplay(); break; case y : year = (year + 5) % 360; glutpostredisplay(); break; case Y : year = (year - 5) % 360; glutpostredisplay(); break; case 27: exit(0); break; default: break;

5.4 23 int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize (500, 500); glutinitwindowposition (100, 100); glutcreatewindow (argv[0]); init (); glutdisplayfunc(display); glutreshapefunc(reshape); glutkeyboardfunc(keyboard); glutmainloop(); return 0; 5.4 2 9 gltranslate*() glrotate*() glpushmatrix() glpopmatrix() glscale*()

24 5 gltranslatef (-1.0, 0.0, 0.0); glrotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0); gltranslatef (1.0, 0.0, 0.0); glpushmatrix(); glscalef (2.0, 0.4, 1.0); glutwirecube (1.0); glpopmatrix(); 2 x x 2 gltranslatef (1.0, 0.0, 0.0); glrotatef ((GLfloat) elbow, 0.0, 0.0, 1.0); gltranslatef (1.0, 0.0, 0.0); glpushmatrix(); glscalef (2.0, 0.4, 1.0); glutwirecube (1.0); glpopmatrix(); ( ) #include <GL/glut.h> #include <stdlib.h> static int shoulder = 0, elbow = 0; void init(void) { glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel (GL_FLAT);

5.4 25 void display(void) { glclear (GL_COLOR_BUFFER_BIT); glpushmatrix(); gltranslatef (-1.0, 0.0, 0.0); glrotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0); gltranslatef (1.0, 0.0, 0.0); glpushmatrix(); glscalef (2.0, 0.4, 1.0); glutwirecube (1.0); glpopmatrix(); gltranslatef (1.0, 0.0, 0.0); glrotatef ((GLfloat) elbow, 0.0, 0.0, 1.0); gltranslatef (1.0, 0.0, 0.0); glpushmatrix(); glscalef (2.0, 0.4, 1.0); glutwirecube (1.0); glpopmatrix(); glpopmatrix(); glutswapbuffers(); void reshape (int w, int h) { glviewport (0, 0, (GLsizei) w, (GLsizei) h); glmatrixmode (GL_PROJECTION); glloadidentity (); gluperspective(65.0, (GLfloat) w/(glfloat) h, 1.0, 20.0); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef (0.0, 0.0, -5.0);

26 5 /* ARGSUSED1 */ void keyboard (unsigned char key, int x, int y) { switch (key) { case s : shoulder = (shoulder + 5) % 360; glutpostredisplay(); break; case S : shoulder = (shoulder - 5) % 360; glutpostredisplay(); break; case e : elbow = (elbow + 5) % 360; glutpostredisplay(); break; case E : elbow = (elbow - 5) % 360; glutpostredisplay(); break; case 27: exit(0); break; default: break; int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize (500, 500); glutinitwindowposition (100, 100); glutcreatewindow (argv[0]); init (); glutdisplayfunc(display); glutreshapefunc(reshape); glutkeyboardfunc(keyboard); glutmainloop(); return 0;

27 6 6.1 GLUT GLUT void glutdisplayfunc(void (*func)(void)); glutpostredisplay() void glutreshapefunc(void (*func)(void)); func 2 func glviewport() glutreshapefunc() NULL glviewport(0, 0, width, height) void glutkeyboadfunc(void (*func)(unsigned int key, int x, int y)); ASCII func key ASCII x, y ( ) void glutmousefunc(void (*func)(int button, int state, int x, int y)); func button GLUT LEFT BUTTON, GLUT MIDDLE BUTTON, GLUT RIGHT BUTTON state GLUT UP GLUT DOWN x y ( ) void glutmotionfunc(void (*func)(int x, int y));

28 6 func x y ( ) void glutpostredisplay(void); glutdisplayfunc() glutidlefunc() void glutidlefunc(void (*func)(void)); func NULL func GLUT glutmainloop() void glutmainloop(void); GLUT 6.2 OpenGL ( ) 1 OpenGL 2 (double-buffer) 2 GLUT void glutswapbuffers(void); (viewpoint)

6.2 29 #include <GL/glut.h> static GLfloat spin = 0.0; void display(void) { glclear(gl_color_buffer_bit); glpushmatrix(); glrotatef(spin, 0.0, 0.0, 1.0); glcolor3f(1.0, 1.0, 1.0); glrectf(-25.0, -25.0, 25.0, 25.0); glpopmatrix(); glutswapbuffers(); void spindisplay(void) { spin = spin + 2.0; if (spin > 360.0) spin = spin - 360.0; glutpostredisplay(); void init(void) { glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel (GL_FLAT); void reshape(int w, int h) { glviewport (0, 0, (GLsizei) w, (GLsizei) h); glmatrixmode(gl_projection); glloadidentity(); glortho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); glmatrixmode(gl_modelview); glloadidentity();

30 6 /* ARGSUSED2 */ void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) glutidlefunc(spindisplay); break; case GLUT_MIDDLE_BUTTON: if (state == GLUT_DOWN) glutidlefunc(null); break; default: break; /* * Request double buffer display mode. * Register mouse input callback functions */ int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize (250, 250); glutinitwindowposition (100, 100); glutcreatewindow (argv[0]); init (); glutdisplayfunc(display); glutreshapefunc(reshape); glutmousefunc(mouse); glutmainloop(); return 0; glutswapbuffers() GLUT

6.2 31 1 1. sample-teapot.c 2. planet.tar.gz planet ex.c glpushmatrix() glpopmatrix() 3. planet ex.c 4. planet ex.c 5. sample-robot.c ( glpushmatrix() glpopmatrix() 10

32 7 GLUI 7 GLUI 7.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix() glut glui glui 11 GLUI

7.1 GLUI 33 7.1.1 GLUI GLUI (Buttons) (Checkboxes) ON OFF (Radio Buttons) (Editable Text Boxes) (Spinners) (Listboxes) (Rotation Controls) (Translation Controls) 12 GLUI (Static Text) (Separators) Static Text (Columns)

34 7 GLUI (Panels) (Rollouts) 12 13 14 glui 13 14 GLUI *glui = GLUI_Master.create_glui( "GLUI" ); GLUI *glui = GLUI_Master.create_glui_subwindow(main_window, glui->set_main_gfx_window( main_window ); GLUI_SUBWINDOW_BOTTOM);

7.2 glut GLUI 35 GLUI SUBWINDOW BOTTOM GLUI SUBWINDOW TOP GLUI SUBWINDOW LEFT 7.2 glut GLUI teapot UI #include <stdio.h> #include <math.h> #include <GL/glut.h> void display(void) { glclear(gl_color_buffer_bit); glutwireteapot(1.5); glutswapbuffers(); glutpostredisplay(); int main(int argc, char *argv[]) { glutinit(&argc, argv); glutinitdisplaymode(glut_rgba GLUT_DOUBLE); glutcreatewindow(argv[0]); glutdisplayfunc(display); glclearcolor(0.0, 0.0, 1.0, 0.0); glutmainloop(); return 0; GLUI #include <stdio.h> #include <math.h> #include <GL/glut.h> #include <glui.h>

36 7 GLUI /*--- ---*/ float rotate[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 ; void display(void) { glclear(gl_color_buffer_bit); /*--- ---*/ glpushmatrix(); glmultmatrixf( rotate ); glutwireteapot(1.5); glpopmatrix(); /*--- ---*/ glutswapbuffers(); glutpostredisplay(); /*=== ===*/ void gluicallback(int num) { exit(0); /*=== ===*/ int main(int argc, char *argv[]) { glutinit(&argc, argv); glutinitdisplaymode(glut_rgba GLUT_DOUBLE); glutcreatewindow(argv[0]); glutdisplayfunc(display); glclearcolor(0.0, 0.0, 1.0, 0.0);

7.3 GLUI 37 /*---GLUI initialize---*/ GLUI *glui = GLUI_Master.create_glui("control"); /*---GLUI ---*/ GLUI_Rotation *view_rot= new GLUI_Rotation(glui, "Rotation",rotate); /*===GLUI ===*/ new GLUI_Button(glui, "Exit", 0, gluicallback); glutmainloop(); return 0; 15 GLUI teapot UI 7.3 GLUI GLUI example1, example2, example3, example4, example5 bin example /usr/local/src/glui-2.35/src/example/ /usr/local/src/glui-2.35/src/bin/

38 7 GLUI 2 1. sample glui.cpp sample glui teapot.cpp Makefile Teapot glutwireteapot glutsolidteapot 2. exmple5 2 Teapot Teapot 3. 1 UI ( ) 16 example5

7.3 GLUI 39 3( ) GLUI solar system ex.tar.gz 1. plant view main.cpp 2. orbit view main.cpp a Day rate b 17 3.1 18 3.1 19 3.1 20 3.2

40 7 GLUI 21 3.2 ( ) 22 3.2 ( ) 23 3.2 ( )