/* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLU
|
|
- ゆみか あんさい
- 6 years ago
- Views:
Transcription
1 OpenGL ( ) #include <GL/glut.h> #include <math.h> #define PI 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 for( j=0; j<100; j++ ) x = -2.0*PI+4.0*PI*(float)j/100.0; y = sin(x); glvertex2f(x, y); ; glpointsize( 3.0 ); glbegin( GL_POINTS );// cosine curve by points glcolor3f( 1.0f, 1.0f, 0.0f );// point color for( j=0; j<100; j++ ) x = -2.0*PI+4.0*PI*(float)j/100.0; y = cos(x); glvertex2f(x, y); ; glbegin( GL_LINES );/* x-axis */ glcolor3f( 1.0f, 1.0f, 1.0f ); glvertex2f( -2.0*PI, 0.0f ); glvertex2f( 2*PI, 0.0f ); glbegin( GL_LINES );/* y-axis */ glvertex2f(0.0f, 1.5f); glvertex2f(0.0f, -1.5f ); return; void init() glclearcolor( 0.0f, 0.0f, 0.0f, 1.0f);// backgound color /* window coordinate */ glmatrixmode( GL_MODELVIEW ); gluortho2d( -2.0*PI, 2.0*PI, -1.5, 1.5 ); void display(void) glclear( GL_COLOR_BUFFER_BIT ); 1
2 /* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLUT_RGB GLUT_SINGLE ); glutinitwindowsize( 500, 400 ); glutinitwindowposition( 100, 100 ); glutcreatewindow( "Sine-Cosine curve" ); init(); glutdisplayfunc( display ); glutmainloop(); return 0; 2
3 ( ) #include <GL/glut.h> #include <math.h> #define PI /* static parameter for displaylist */ static GLuint index; /* generating displaylist for drawing a function graph */ void createfunctionlist() int j; float x, y; /* generating displaylist */ index = glgenlists( 1 ); /* starting making displaylist */ glnewlist( index, GL_COMPILE_AND_EXECUTE ); glbegin( GL_LINE_STRIP );/* sine curve by line */ glcolor3f( 0.0f, 1.0f, 1.0f );// line color for( j=0; j<100; j++ ) x = -2.0*PI+4.0*PI*(float)j/100.0; y = sin(x); glvertex2f(x, y); ; glpointsize( 3.0 ); glbegin( GL_POINTS );/* cosine curve by points */ glcolor3f( 1.0f, 1.0f, 0.0f );// point color for( j=0; j<100; j++ ) x = -2.0*PI+4.0*PI*(float)j/100.0; y = cos(x); glvertex2f(x, y); ; glbegin( GL_LINES );/* x-axis */ glcolor3f( 1.0f, 1.0f, 1.0f ); glvertex2f( -2.0*PI, 0.0f ); glvertex2f( 2*PI, 0.0f ); glbegin( GL_LINES );/* y-axis */ glvertex2f(0.0f, 1.5f); glvertex2f(0.0f, -1.5f ); /* end of displaylist */ glendlist(); return; 3
4 void init() glclearcolor( 0.0f, 0.0f, 0.0f, 1.0f);// backgound color /* window coordinate */ glmatrixmode( GL_MODELVIEW ); gluortho2d( -2.0*PI, 2.0*PI, -1.5, 1.5 ); void display(void) glclear( GL_COLOR_BUFFER_BIT ); /* drawing function */ glcalllist( index );// drawing graph glflush(); int main( int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLUT_RGB GLUT_SINGLE ); glutinitwindowsize( 500, 400 ); glutinitwindowposition( 100, 100 ); glutcreatewindow( "Sine-Cosine curve" ); init(); createfunctionlist();// creating graph glutdisplayfunc( display ); glutmainloop(); return 0; 4
5 2 ( ) 2 3 f(z) = z + c M = c z 0 = 0, z n+1 = f(z n ), z n c = x + iy (α x β, γ y δ) rl, rr, ib, it α =rl, β =rr, γ =ib, δ =it Mx z n < 2 2 z n > 2 n c 1 1 #include <GL/glut.h> #define win_width 500 #define win_height 500 static double rl=-2.5, rr=0.5, ib=-1.5, it=1.5;// window area static int Mx = 200;// iteration limit static double Prl=0.0, Pim=0.0; // start point static GLuint index; struct compn double rl; double im; ; /* evaluation of iteration */ int kernel(double s_rl, double s_im, double p_rl, double p_im, int Max) struct compn z, z2, c; double absq; int itr=0; z.rl = p_rl; z.im = p_im; // start c.rl = s_rl; c.im = s_im; // parameter absq = z.rl*z.rl + z.im*z.im; while(absq < 4.0 && itr < Max) z2.rl = z.rl * z.rl - z.im * z.im + c.rl; z2.im = 2.0 * z.rl * z.im + c.im; z = z2; absq = z.rl*z.rl + z.im*z.im; itr++; return itr; /* generating displaylist */ 5
6 void createlist() int i, j, k;// iteration index double x, y;// window coordinate double rstep, istep;// iteration step int pcl;// paint color /* iteration step */ rstep = (rr-rl)/win_width; istep = (it-ib)/win_height; /* generating displaylist */ index = glgenlists( 1 ); /* making displaylist */ glnewlist( index, GL_COMPILE_AND_EXECUTE ); glpointsize(1.5); glbegin(gl_points); for (i=0; i<win_width; i++) for (j=0; j<win_height; j++) x = rl + i*rstep; y = ib + j*istep; k = kernel(x, y, Prl, Pim, Mx); pcl = k % 10; /* add to diplay list */ if (pcl < 1) glcolor3f(0.2, 0.1, 0.3); else if (1<=pcl && pcl<2) glcolor3f(0.4, 0.2, 0.6); else if (2<=pcl && pcl<3) glcolor3f(0.3, 0.4, 0.5); else if (3<=pcl && pcl<4) glcolor3f(0.5, 0.6, 0.4); else if (4<=pcl && pcl<5) glcolor3f(0.6, 0.7, 0.4); else if (5<=pcl && pcl<6) glcolor3f(0.9, 0.9, 0.9); else if (6<=pcl && pcl<7) glcolor3f(0.5, 0.6, 0.3); else if (7<=pcl && pcl<8) glcolor3f(0.7, 0.7, 0.5); else if (8<=pcl && pcl<9) glcolor3f(0.6, 0.5, 0.7); else if (9<=pcl && pcl<10) glcolor3f(0.9, 0.4,0.4); else glcolor3f(0.1, 0.0, 0.1); glvertex2f(x, y); glendlist(); void display() glclear(gl_color_buffer_bit); glcalllist(index); glflush(); void reshape(int w, int h) 6
7 glviewport(0,0,w,h); glmatrixmode( GL_MODELVIEW ); gluortho2d( rl, rr, ib, it); void init() glclearcolor(0.0, 0.0, 0.0, 1.0); glcolor3f(1.0, 1.0, 1.0); int main( int argc, char** argv ) glutinit(&argc, argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(win_width, win_height); glutinitwindowposition(100, 100); glutcreatewindow("mandelbrot"); createlist(); init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutmainloop(); return 0; 7
8 2 ( ) f(z) = z + c J c = z z 0 = z, z n+1 = f(z n ), z n c = p + iq p =Prl, q =Pim, z = x + iy (α x β, γ y δ) α =rl, β =rr, γ =ib, δ =it z, c z, c z n > 2 n z 10 #include <GL/glut.h> #define win_width 500 #define win_height 500 static double rl=-1.5, rr=1.5, ib=-1.5, it=1.5;// window area static int Mx = 500;// iteration limit static double Prl = , Pim = ; //parameter //static double Prl =-0.195, Pim = 0.656; static GLuint index; struct compn double rl; double im; ; /* evaluation of iteration */ int kernel(double s_rl, double s_im, double p_rl, double p_im, int Max) struct compn z, z2, c; double absq; int itr=0; z.rl = s_rl; z.im = s_im; // start c.rl = p_rl; c.im = p_im; // parameter absq = z.rl*z.rl + z.im*z.im; while(absq < 4.0 && itr < Max) z2.rl = z.rl * z.rl - z.im * z.im + c.rl; z2.im = 2.0 * z.rl * z.im + c.im; z = z2; absq = z.rl*z.rl + z.im*z.im; itr++; return itr; /* generating displaylist */ void createlist() int i, j, k;// iteration index double x, y;// window coordinate double rstep, istep;// iteration step // int pcl;// paint color 8
9 /* iteration step */ rstep = (rr-rl)/win_width; istep = (it-ib)/win_height; /* generating displaylist */ index = glgenlists( 1 ); /* making displaylist */ glnewlist( index, GL_COMPILE_AND_EXECUTE ); glpointsize(1.5); glbegin(gl_points); for (i=0; i<win_width; i++) for (j=0; j<win_height; j++) x = rl + i*rstep; y = ib + j*istep; k = kernel(x, y, Prl, Pim, Mx); //pcl = k % 7; /* add to diplay list */ if (k <= Mx/10) glcolor3f(0.2, 0.1, 0.3); else if (k <= Mx*2/10) glcolor3f(0.4, 0.2, 0.6); else if (k <= Mx*3/10) glcolor3f(0.3, 0.4, 0.5); else if (k <= Mx*4/10) glcolor3f(0.5, 0.6, 0.4); else if (k <= Mx*5/10) glcolor3f(0.6, 0.7, 0.4); else if (k <= Mx*6/10) glcolor3f(0.9, 0.9, 0.9); else if (k <= Mx*7/10) glcolor3f(0.5, 0.6, 0.3); else if (k <= Mx*8/10) glcolor3f(0.7, 0.7, 0.5); else if (k <= Mx*9/10) glcolor3f(0.6, 0.5, 0.7); else if (k <= Mx*9.9/10) glcolor3f(0.9, 0.4,0.4); else glcolor3f(0.1, 0.0, 0.1); glvertex2f(x, y); glendlist(); void display() glclear(gl_color_buffer_bit); glcalllist(index); glflush(); void reshape(int w, int h) glviewport(0,0,w,h); glmatrixmode( GL_MODELVIEW ); gluortho2d( rl, rr, ib, it); void init() 9
10 glclearcolor(0.0, 0.0, 0.0, 1.0); glcolor3f(1.0, 1.0, 1.0); int main( int argc, char** argv ) glutinit(&argc, argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(win_width, win_height); glutinitwindowposition(100, 100); glutcreatewindow("julia"); createlist(); init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutmainloop(); return 0; 10
11 #include <GL/glut.h> #include <math.h> #define WIN_WIDTH 400 #define WIN_HEIGHT 600 void koch(int level, double sx, double sy, double ex, double ey) double x0 = sx; double y0 = sy; double x1 = (ex+2*sx)/3; double y1 = (ey+2*sy)/3; double x3 = (2*ex+sx)/3; double y3 = (2*ey+sy)/3; double x2 = (x1+x3)/2-sqrt(3)*(y3-y1)/2; double y2 = (y1+y3)/2+sqrt(3)*(x3-x1)/2; double x4 = ex; double y4 = ey; if(level <= 0) glbegin(gl_line_strip); glvertex2f(x0,y0); glvertex2f(x1,y1); glvertex2f(x2,y2); glvertex2f(x3,y3); glvertex2f(x4,y4); return; koch(level-1, x0, y0, x1, y1); koch(level-1, x1, y1, x2, y2); koch(level-1, x2, y2, x3, y3); koch(level-1, x3, y3, x4, y4); void display() glclear(gl_color_buffer_bit); koch(0, 0.0, WIN_HEIGHT*5/7, WIN_WIDTH, WIN_HEIGHT*5/7); koch(1, 0.0, WIN_HEIGHT*4/7, WIN_WIDTH, WIN_HEIGHT*4/7); koch(2, 0.0, WIN_HEIGHT*3/7, WIN_WIDTH, WIN_HEIGHT*3/7); koch(3, 0.0, WIN_HEIGHT*2/7, WIN_WIDTH, WIN_HEIGHT*2/7); koch(6, 0.0, WIN_HEIGHT/7, WIN_WIDTH, WIN_HEIGHT/7); glflush(); void reshape(int w, int h) glviewport(0, 0, w, h); void init() 11
12 glclearcolor(0.0, 0.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 1.0); glmatrixmode(gl_modelview); gluortho2d(0.0, WIN_WIDTH, 0.0, WIN_HEIGHT); int main(int argc, char** argv) glutinit(&argc, argv); glutinitwindowsize(win_width, WIN_HEIGHT); glutinitwindowposition(100, 100); glutinitdisplaymode(glut_single GLUT_RGB); glutcreatewindow("koch curve"); init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutmainloop(); return 0; 12
13 2 1 1 time.h sleep sleepf() 0.01 Q q #include <stdio.h> #include <GL/glut.h> #include <math.h> #include <time.h> #define DEG2RAD /* 1 radian/1 degree */ int singleb, doubleb; GLfloat theta = 0.0; void sleepf(float dt) clock_t time1,time2,interval; interval=clocks_per_sec*dt; time1=time2=clock(); while(time2-time1<interval) time2=clock(); return; void displays() glcolor3f(0.0, 1.0, 1.0); glclear(gl_color_buffer_bit); glbegin(gl_polygon); glvertex2f(cos(theta*deg2rad),sin(theta*deg2rad)); glvertex2f(-sin(theta*deg2rad),cos(theta*deg2rad)); glvertex2f(-cos(theta*deg2rad),-sin(theta*deg2rad)); glvertex2f(sin(theta*deg2rad),-cos(theta*deg2rad)); glflush(); void displayd() glcolor3f(1.0, 1.0, 0.0); glclear(gl_color_buffer_bit); 13
14 glbegin(gl_polygon); glvertex2f(cos(theta*deg2rad),sin(theta*deg2rad)); glvertex2f(-sin(theta*deg2rad),cos(theta*deg2rad)); glvertex2f(-cos(theta*deg2rad),-sin(theta*deg2rad)); glvertex2f(sin(theta*deg2rad),-cos(theta*deg2rad)); glutswapbuffers(); void spindisplay(void) /* increment rotation angle */ theta += 2.0; if(theta >= 360.0) theta -= 360.0; /* draw single buffer window */ glutsetwindow(singleb); glutpostredisplay(); /* draw double buffer window */ glutsetwindow(doubleb); glutpostredisplay(); /* delay */ sleepf(0.1); void mymouse(int btn, int state, int x, int y) if(btn == GLUT_LEFT_BUTTON && state == GLUT_DOWN) glutidlefunc(spindisplay); if(btn == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN) glutidlefunc(0); void myreshape(int w, int h) glviewport(0,0,w,h); glmatrixmode(gl_projection); gluortho2d(-2.0, 2.0, -2.0, 2.0); glmatrixmode(gl_modelview); void mykey(int key, int x, int y) if(key == Q key == q ) exit(0); void quit_menu(int id) if(id == 1) exit(0); void myinit() 14
15 glclearcolor(0.0, 0.0, 0.0, 0.0); //glcolor3f(1.0, 1.0, 1.0); int main(int argc, char **argv) glutinit(&argc,argv); glutinitwindowsize(300,300); /* single buffer display */ glutinitdisplaymode(glut_single GLUT_RGB); singleb = glutcreatewindow("single buffered"); myinit(); glutdisplayfunc(displays); glutreshapefunc(myreshape); glutidlefunc(spindisplay); glutmousefunc(mymouse); glutkeyboardfunc(mykey); /* double buffer display */ glutinitdisplaymode(glut_double GLUT_RGB); doubleb = glutcreatewindow("double buffered"); myinit(); glutdisplayfunc(displayd); glutreshapefunc(myreshape); glutidlefunc(spindisplay); glutmousefunc(mymouse); glutcreatemenu(quit_menu); glutaddmenuentry("quit",1); glutattachmenu(glut_right_button); /* event loop */ glutmainloop(); 15
16 3DCG ( ) ( ) 3DCG glortho glfrustum gluperspective Z GL_DEPTH_* #include <GL/glut.h> GLfloat vertices[][3] = -1.0, -1.0, 1.0,, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0; GLfloat colors[][3] = 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0; void polygon(int a, int b, int c, int d) glcolor3fv(colors[a]); glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() polygon(0, 3, 2, 1); polygon(2, 3, 7, 6); polygon(3, 0, 4, 7); polygon(1, 2, 6, 5); polygon(4, 5, 6, 7); polygon(5, 4, 0, 1); void display() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(4.0, 4.5, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //glutwirecube(0.5);/* for emergency test */ cube(); glutswapbuffers(); void reshape(int w, int h) glmatrixmode(gl_projection); /* perspective projection (tosha-toei) 1: */ /*left, right, bottom, top, near, far */ 16
17 glfrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 10.0); /* perspective projection (tosha-toei) 2: fov, aspect, near, far */ //gluperspective(60.0, (double)w/(double)h, 1.0, 50.0); //perspective projection(tousha-touei) 2 /* parallel projection (heiko/choku-toei):*/ /* left, right, bottom, top, near, far */ //glortho(-4.0, 4.0, -4.0, 4.0, -10.0, 10.0); // parallelprojection(choku-touei) glviewport(0, 0, w, h); void init() glclearcolor(0.0, 0.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 1.0); glenable(gl_depth_test);// z-buffer test int main(int argc, char **argv) /* initilization */ glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500, 500); glutinitwindowposition(0, 0); glutcreatewindow("cube"); init(); glutdisplayfunc(display); glutreshapefunc(reshape); /* main loop */ glutmainloop(); return 0; 17
18 #include <GL/glut.h> #include <math.h> #include <time.h> GLfloat vertices[][3]=-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0, 1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0, 1.0,1.0,-1.0,1.0,-1.0,-1.0; GLfloat colors[][3]=1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0, 0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0; int dpcube; // spin object float u[] = 0.0, 0.0, 1.0; // rotation vector float theta = /360; // rotation angle float dtime = 0.1; // refresh interval/sec float rotmat[3][3]; // rotation matrix float tv[] = 2.0, 0.0, 0.0;// translation vector void mulmat(float a[][3], float b[][3], float c[][3], int msize) int i, j, k; for(i=0; i<msize; i++) for(j=0; j<msize; j++) c[i][j] = 0; for(k=0; k<msize; k++) c[i][j] = c[i][j]+a[i][k]*b[k][j]; return; void mulvec(float a[][3], float v[], float w[], int msize) int i, k; for(i=0; i<msize; i++) w[i] = 0; for(k=0; k<msize; k++) w[i] = w[i]+a[i][k]*v[k]; return; void tranmat(float u[][3], float v[][3], int msize) int i,j; for(i=0; i<msize; i++) for(j=0; j<msize; j++) v[j][i]=u[i][j]; return; void orthmat(float v[], float u[][3], int msize) float l1=0.0, l2=0.0, inner=0.0; int i; 18
19 for(i=0; i<msize; i++) l1 = l1+v[i]*v[i]; l1=sqrt(l1); for(i=0; i<msize; i++) u[i][0] = v[i]/l1; if(u[1][0]==0 && u[2][0]==0) u[0][1]=0; u[1][1]=1; u[2][1]=0; else u[0][1]=1; u[1][1]=0; u[2][1]=0; for(i=0; i<msize; i++) inner=inner+u[i][0]*u[i][1]; for(i=0; i<msize; i++) u[i][1] = u[i][1]-inner*u[i][0]; for(i=0; i<msize; i++) l2 = l2+u[i][1]*u[i][1]; l2=sqrt(l2); for(i=0; i<msize; i++) u[i][1] = u[i][1]/l2; u[0][2] = u[1][0]*u[2][1]-u[2][0]*u[1][1]; u[1][2] = u[2][0]*u[0][1]-u[0][0]*u[2][1]; u[2][2] = u[0][0]*u[1][1]-u[1][0]*u[0][1]; void rotbase(float theta, float t[][3], int msize) t[0][0]=1; t[0][1]=0; t[0][2]=0; t[1][0]=0; t[1][1]=cos(theta); t[1][2]=-sin(theta); t[2][0]=0; t[2][1]=sin(theta); t[2][2]=cos(theta); void sleepf(float dt) clock_t time1, time2, interval; interval = CLOCKS_PER_SEC*dt; time1=time2=clock(); while(time2-time1<interval) time2=clock(); return; void tranvec(float u[], float tv[], float v[], int vsize) int i; for(i=0;i<vsize;i++) v[i] = u[i]+tv[i]; void polygon(int a, int b, int c, int d) glcolor3fv(colors[a]); glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() polygon(0,3,2,1); 19
20 polygon(2,3,7,6); polygon(3,0,4,7); polygon(1,2,6,5); polygon(4,5,6,7); polygon(5,4,0,1); void display() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(5.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); //glutwirecube(1.5);/* for emergency test */ cube(); glutswapbuffers(); void spindisplay(void) int i,j; float o_tmp[3], n_tmp[3]; for(i=0; i<8; i++) for(j=0;j<3;j++) o_tmp[j]=vertices[i][j]; mulvec(rotmat, o_tmp, n_tmp, 3); for(j=0;j<3;j++) vertices[i][j]=n_tmp[j]; glutsetwindow(dpcube); glutpostredisplay(); sleepf(dtime); return; void reshape(int w, int h) glmatrixmode(gl_projection); glfrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 30.0); //gluperspective(60.0, (double)w/(double)h, 1.0, 50.0); //glortho(-4.0, 4.0, -4.0, 4.0, -10.0, 10.0); glviewport(0, 0, w, h); void init() glenable(gl_depth_test); glclearcolor(0.0, 0.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 0.5); int main(int argc, char **argv) int i; float p[3][3], q[3][3], r[3][3], tmp[3][3]; /* setting rotation Matrix */ rotbase(theta, r, 3); 20
21 orthmat(u, p, 3); tranmat(p, q, 3); mulmat(p, r, tmp, 3); mulmat(tmp, q, rotmat, 3); /* translation of object */ for(i=0;i<8;i++) tranvec(vertices[i],tv,vertices[i],3); /* Graphic tool init */ glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500, 500); glutinitwindowposition(0, 0); dpcube = glutcreatewindow("cube"); init(); glutdisplayfunc(display); glutreshapefunc(reshape); /* idling */ glutidlefunc(spindisplay); /* main loop */ glutmainloop(); return 0; 21
22 Transformation OpenGL /* Program showing an effect of rotation and translation to a cube */ /* Comp on Oct 8, 2005 by Kimio Sugita */ #include <GL/glut.h> #include <math.h> #include <time.h> GLfloat vertices[][3] = -1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0, 1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0, 1.0,-1.0,-1.0; GLfloat colors[][3] = 1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0, 0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0; GLfloat theta1 = 0.0, theta2 = 0.0; void polygon(int a,int b,int c,int d) glcolor3fv(colors[a]); glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() polygon(0,3,2,1); polygon(2,3,7,6); polygon(3,0,4,7); polygon(1,2,6,5); polygon(4,5,6,7); polygon(5,4,0,1); void sleepf(float intv) clock_t time1,time2,interval; interval = CLOCKS_PER_SEC*intv; time1 = time2 = clock(); while(time2-time1<interval) time2 = clock(); return; void mydisplay() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(5.0,5.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0); gltranslatef(3.0*cos(theta2),0.0,3.0*sin(theta2)); 22
23 glrotatef(theta1,0.0,1.0,0.0); //glutwirecube(1.5); cube(); glflush(); glutswapbuffers(); void myidle() theta1 += 1.0; if(theta1>360.0) theta1 -= 360.0; theta2 += /720.0; if(theta2>2* ) theta2 = 0.0; glutpostredisplay(); sleepf(0.01); void myreshape(int w,int h) glviewport(0,0,w,h); glmatrixmode(gl_projection); //glortho(-10.0,10.0,-10.0,10.0,-20.0,20.0); //glfrustum(-1.0,1.0,-1.0,1.0,2.0,30.0); gluperspective(60.0, (double)w/(double)h,1.0,50.0); glmatrixmode(gl_modelview); void myinit() glenable(gl_depth_test); glclearcolor(0.0,0.0,0.0,0.0); glcolor3f(1.0,1.0,1.0); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("cube"); myinit(); glutdisplayfunc(mydisplay); glutreshapefunc(myreshape); glutidlefunc(myidle); glutmainloop(); return 0; 23
24 GL_LIGHT* 3DCG shade glut #include <GL/glut.h> #include <math.h> GLUquadricObj *mysphere;//2 GLfloat position0[] = 4.0, 4.0, 4.0, 0.0;/* dx, dy, dz, 1.0*/ //3 GLfloat ambient0[] = 0.2, 0.2, 0.2, 1.0;/* R, G, B, 1.0 */ //4 GLfloat diffuse0[] = 1.0, 1.0, 1.0, 1.0;/* R, G, B, 1.0 */ //4 GLfloat specular0[] = 1.0, 1.0, 1.0, 1.0;/* R, G, B, 1.0 */ //4 void display() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(8.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); //glutwirecube(1.0); //glutwiresphere(1.0, 12, 12);//1 //glusphere(mysphere, 2.0, 24, 24);//2 glutsolidtorus(1.0, 2.0, 24, 24);//5 //glutsolidteapot(2.0);//6 glutswapbuffers(); void init() glclearcolor(0.0, 0.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 1.0); mysphere = glunewquadric();//2 gluquadricdrawstyle(mysphere, GLU_FILL);//2->GLU_LINE, 3->GLU_FILL glenable(gl_auto_normal);//3 //gluquadricnormals(mysphere,glu_smooth);//3 glshademodel(gl_smooth);//3 glenable(gl_depth_test);//2 glenable(gl_lighting);//3 glenable(gl_light0);//3 glmatrixmode(gl_modelview);//3 //3 gllightfv(gl_light0, GL_POSITION, position0);//3 gllightfv(gl_light0, GL_AMBIENT, ambient0);//4 gllightfv(gl_light0, GL_DIFFUSE, diffuse0);//4 gllightfv(gl_light0, GL_SPECULAR, specular0);//4 void reshape(int w, int h) glmatrixmode(gl_projection); glfrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 100.0); //glortho(-4.0, 4.0, -4.0, 4.0, -4.0, 4.0); glviewport(0, 0, w, h); int main(int argc, char **argv) 24
25 glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(100,100); glutcreatewindow(" Sphere "); init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutmainloop(); return 0; 25
26 shade display() lighting process OpenGL shade gllightfv translation #include <GL/glut.h> #include <math.h> #include <time.h> int rot_light;// rot object GLUquadricObj *mysphere; GLfloat position0[] = 3.0, 2.0, 1.0, 1.0;// light position GLfloat ambient0[] = 0.1, 0.1, 0.1, 0.5;// ambient light GLfloat specular0[] = 1.0, 0.0, 0.0, 1.0;// specular light GLfloat theta = 0.0; void sleepf(float intt) clock_t time1, time2, interval; interval = CLOCKS_PER_SEC*intt; time1 = time2 = clock(); while(time2-time1<interval) time2 = clock(); return; void idle() theta += 3.0; if(theta>360.0) theta -=360.0; glutsetwindow(rot_light); glutpostredisplay(); sleepf(0.2); return; void display() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); /* lighting process */ glpushmatrix(); glrotatef(theta, 1.0, 0.0, 1.0); gllightmodeli(gl_light_model_two_side, GL_TRUE); gllightmodelfv(gl_light_model_ambient, ambient0); gllightfv(gl_light0, GL_POSITION, position0); gllightfv(gl_light0, GL_SPECULAR, specular0); //gllightfv(gl_light0, GL_AMBIENT, ambient0); glpopmatrix(); /* choose your object from following list */ //glutwirecube(1.0); 26
27 //glutwiresphere(1.0, 12, 12); //glusphere(mysphere, 2.0, 24, 24); //glutsolidtorus(1.0, 2.0, 24, 24); glutsolidteapot(2.0); /* list end */ glutswapbuffers(); void init() glclearcolor(0.0, 0.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 1.0); mysphere = glunewquadric(); gluquadricdrawstyle(mysphere, GLU_FILL); glenable(gl_auto_normal); glshademodel(gl_smooth); glenable(gl_depth_test); glenable(gl_lighting); glenable(gl_light0); void reshape(int w, int h) glviewport(0, 0, w, h); glmatrixmode(gl_projection); glortho(-5.0, 5.0, -5.0, 5.0, -6.0, 6.0); int main(int argc, char **argv) glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(100,100); rot_light = glutcreatewindow(" Sphere "); init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutidlefunc(idle); glutmainloop(); return 0; 27
28 3dCG shade #include <GL/glut.h> #include <math.h> #include <time.h> GLUquadricObj *mysphere; GLfloat position0[] = 10.0, 10.0, 10.0, 0.0;// light position typedef struct materialstruct GLfloat ambient[4]; GLfloat diffuse[4]; GLfloat specular[4]; GLfloat shininess[1]; materialstruct; struct materialstruct brassmaterials = 0.33, 0.22, 0.03, 1.0, 0.78, 0.57, 0.11, 1.0, 0.99, 0.91, 0.81, 1.0, 27.8 ; struct materialstruct redplasticmaterials = 0.3, 0.0, 0.0, 1.0, 0.6, 0.0, 0.0, 1.0, 0.8, 0.6, 0.6, 1.0, 32.0 ; struct materialstruct whiteshineymaterials = 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, ; void material(struct materialstruct matlist) glmaterialfv(gl_front_and_back, GL_AMBIENT, matlist.ambient); glmaterialfv(gl_front_and_back, GL_DIFFUSE, matlist.diffuse); glmaterialfv(gl_front_and_back, GL_SPECULAR, matlist.specular); glmaterialfv(gl_front_and_back, GL_SHININESS, matlist.shininess); void display() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); material(whiteshineymaterials); glusphere(mysphere, 1.5, 24, 24); //glutsolidtorus(1.0, 2.0, 24, 24); //glutsolidteapot(2.0); glpushmatrix(); 28
29 gltranslatef(-6.0, 0.0, 0.0); material(redplasticmaterials); //glusphere(mysphere, 1.5, 24, 24); glutsolidtorus(0.6, 1.2, 24, 24); //glutsolidteapot(2.0); glpopmatrix(); glpushmatrix(); gltranslatef(6.0, 0.0, 0.0); material(brassmaterials); glusphere(mysphere, 1.5, 24, 24); //glutsolitorus(1.0, 2.0, 24, 24); //glutsolidteapot(1.5); glpopmatrix(); glutswapbuffers(); void init() glclearcolor(0.0, 0.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 1.0); mysphere = glunewquadric(); gluquadricdrawstyle(mysphere, GLU_FILL); glenable(gl_auto_normal); glshademodel(gl_smooth); glenable(gl_depth_test); glenable(gl_lighting); glenable(gl_light0); gllightmodeli(gl_light_model_two_side, GL_TRUE); gllightfv(gl_light0, GL_POSITION, position0); void reshape(int w, int h) glviewport(0, 0, w, h); glmatrixmode(gl_projection); glortho(-10.0, 10.0, -5.0, 5.0, -6.0, 6.0); int main(int argc, char **argv) glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(900,450); glutinitwindowposition(100,100); glutcreatewindow(" Material lights "); init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutmainloop(); return 0; 29
30 shade shade shade glnormal3fv /* Program showing a moving cube with shade */ /* Comp on Oct 8, 2005 by Kimio Sugita */ #include <GL/glut.h> #include <math.h> #include <time.h> GLfloat vertices[][3] = -1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0, 1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0, 1.0,1.0,-1.0,1.0,-1.0,-1.0; GLfloat normal[][3] =1.0,0.0,0.0,,-1.0,0.0,0.0,0.0,1.0,0.0, 0.0,-1.0,0.0,0.0,0.0,1.0,0.0,0.0,-1.0; GLfloat colors[][3] = 1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0, 0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0; GLfloat position0[] = 5.0,0.0,5.0,1.0; GLfloat ambient0[] = 0.5,0.5,0.5,1.0; GLfloat diffuse0[] = 1.0,1.0,1.0,1.0; GLfloat mat_diffuse[] = 0.78,0.57,0.11,1.0; GLfloat theta1 = 0.0, theta2 = 0.0; void polygon(int a,int b,int c,int d) glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() glnormal3fv(normal[4]); polygon(0,3,2,1); glnormal3fv(normal[0]); polygon(2,3,7,6); glnormal3fv(normal[3]); polygon(3,0,4,7); glnormal3fv(normal[2]); polygon(1,2,6,5); glnormal3fv(normal[5]); polygon(4,5,6,7); glnormal3fv(normal[1]); polygon(5,4,0,1); glmaterialfv(gl_front_and_back,gl_diffuse,mat_diffuse); void sleepf(float intv) clock_t time1,time2,interval; 30
31 interval = CLOCKS_PER_SEC*intv; time1 = time2 = clock(); while(time2-time1<interval) time2 = clock(); return; void mydisplay() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(5.0,5.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0); gltranslatef(0.0,2.0*cos(theta2),2.0*sin(theta2)); glrotatef(theta1,0.0,1.0,0.0); //glutwirecube(1.5); cube(); glflush(); glutswapbuffers(); void myidle() theta1 += 1.0; if(theta1>360.0) theta1 -= 360.0; theta2 += /720.0; if(theta2>2* ) theta2 = 0.0; glutpostredisplay(); sleepf(0.01); void myreshape(int w,int h) glviewport(0,0,w,h); glmatrixmode(gl_projection); //glortho(-10.0,10.0,-10.0,10.0,-20.0,20.0); //glfrustum(-1.0,1.0,-1.0,1.0,2.0,30.0); gluperspective(60.0, (double)w/(double)h,1.0,50.0); glmatrixmode(gl_modelview); void myinit() glenable(gl_depth_test); glclearcolor(0.0,0.0,0.0,0.0); glcolor3f(1.0,1.0,1.0); glenable(gl_lighting); glenable(gl_light0); glshademodel(gl_flat); glmatrixmode(gl_modelview); gllightfv(gl_light0,gl_position,position0); gllightfv(gl_light0,gl_ambient,ambient0); gllightfv(gl_light0,gl_diffuse,diffuse0); 31
32 int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("cube"); myinit(); glutdisplayfunc(mydisplay); glutreshapefunc(myreshape); glutidlefunc(myidle); glutmainloop(); return 0; 32
33 ( ) #include <GL/glut.h> #include <math.h> GLfloat vertices[][3] = 0.0,0.0,2.0,0.0,2.0,2.0,2.0,2.0,2.0, 2.0,0.0,2.0,0.0,0.0,0.0,0.0,2.0,0.0,2.0,2.0,0.0, 2.0,0.0,0.0; GLfloat colors[][3] = 1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0, 0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0; GLfloat theta1 = 0.0, theta2 = 0.0; void polygon(int a,int b,int c,int d) glcolor3fv(colors[a]); glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() polygon(0,3,2,1); polygon(2,3,7,6); polygon(3,0,4,7); polygon(1,2,6,5); polygon(4,5,6,7); polygon(5,4,0,1); void axises() glcolor3f(1.0,1.0,1.0); glpointsize(3.0); glbegin(gl_lines); glvertex3f(-4.0,0.0,0.0); glvertex3f(4.0,0.0,0.0); glvertex3f(0.0,-4.0,0.0); glvertex3f(0.0,4.0,0.0); glvertex3f(0.0,0.0,-5.0); glvertex3f(0.0,0.0,5.0); void mydisplay() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(0.0,0.0,8.0,0.0,0.0,0.0,0.0,1.0,0.0); cube(); axises(); glflush(); 33
34 glutswapbuffers(); void myreshape(int w,int h) int i; GLfloat oblique[16]; for(i=0;i<16;i++) oblique[i]=0.0; oblique[0]=oblique[5]=oblique[10]=oblique[15]=1.0; oblique[8]=-0.5;oblique[9]=-0.5; glviewport(0,0,w,h); glmatrixmode(gl_projection); glortho(-1.0,10.0,-1.0,10.0,-20.0,20.0); glmultmatrixf(oblique); glmatrixmode(gl_modelview); void myinit() glenable(gl_depth_test); glclearcolor(0.0,0.0,0.0,0.0); glcolor3f(1.0,1.0,1.0); int main(int argc, char **argv) glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("oblique projection"); myinit(); glutdisplayfunc(mydisplay); glutreshapefunc(myreshape); glutmainloop(); return 0; 34
35 Shadow shade( ) shadow shadow OpenGL shadow shadow shadow() shadow /* Program showig a moving cube and following shadow */ /* Com p on Oct 10, 2005 by Kimio Sugita */ #include <GL/glut.h> #include <math.h> #include <time.h> /* object */ GLfloat vertices[][3] = -1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0, 1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0, 1.0,1.0,-1.0,1.0,-1.0,-1.0; GLfloat normal[][3] =1.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.0, 0.0,-1.0,0.0,0.0,0.0,1.0,0.0,0.0,-1.0; /* shadow object */ GLfloat pn[4] = 0.0,1.0,0.0,2.0; /* plane equation pn[0]x+pn[1]y+pn[2]z+pn[3] */ GLfloat ambient0[] = 1.0,1.0,1.0,1.0; GLfloat diffuse0[] = 1.0,1.0,1.0,1.0; GLfloat mat_diffuse[] = 0.78,0.57,0.11,1.0; GLfloat lt[] = 5.0,5.0,1.0,1.0; /* light position (lt[0],lt[1],lt[2]) */ GLfloat theta1 = 0.0, theta2 = 0.0; void polygon(int a,int b,int c,int d) glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() glnormal3fv(normal[4]); polygon(0,3,2,1); glnormal3fv(normal[0]); polygon(2,3,7,6); glnormal3fv(normal[3]); polygon(3,0,4,7); glnormal3fv(normal[2]); polygon(1,2,6,5); glnormal3fv(normal[5]); polygon(4,5,6,7); glnormal3fv(normal[1]); polygon(5,4,0,1); void sleepf(float intv) 35
36 clock_t time1,time2,interval; interval = CLOCKS_PER_SEC*intv; time1 = time2 = clock(); while(time2-time1<interval) time2 = clock(); return; void shadow() /* shadow projection matrix */ int i; GLfloat shadowm[16]; for(i=0;i<16;i++) shadowm[i] = 0.0; shadowm[0] = shadowm[10] = shadowm[15] = 1.0; shadowm[4] = -lt[0]/lt[1]; shadowm[6] = -lt[2]/lt[1]; shadowm[12] = -pn[3]*lt[0]/lt[1]; shadowm[13] = -pn[3]; shadowm[14] = -pn[3]*lt[2]/lt[1]; glpushmatrix(); glpushattrib(gl_current_bit); gldisable(gl_light0); glmultmatrixf(shadowm); /* defining shadow object */ gltranslatef(0.0,cos(theta2),sin(theta2)); glrotatef(theta1,0.0,1.0,0.0); glcolor3f(0.0,0.0,0.0); cube(); glpopattrib(); glpopmatrix(); void object() glenable(gl_light0); glmaterialfv(gl_front_and_back,gl_diffuse,mat_diffuse); glpushmatrix(); glpushattrib(gl_current_bit); gltranslatef(0.0,cos(theta2),sin(theta2)); glrotatef(theta1,0.0,1.0,0.0); cube(); glpopattrib(); glpopmatrix(); void mydisplay() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(5.0,5.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0); object(); shadow(); glflush(); glutswapbuffers(); 36
37 void myidle() theta1 += 1.0; /* for rotation use degree */ if(theta1>360.0) theta1 -= 360.0; theta2 += /720.0; /* for translation use radian */ if(theta2>2* ) theta2 = 0.0; glutpostredisplay(); sleepf(0.02); void myreshape(int w,int h) glviewport(0,0,w,h); glmatrixmode(gl_projection); glortho(-5.0,5.0,-5.0,5.0,-20.0,20.0); //glfrustum(-1.0,1.0,-1.0,1.0,2.0,30.0); //gluperspective(60.0, (double)w/(double)h,1.0,50.0); glmatrixmode(gl_modelview); void myinit() glenable(gl_depth_test); glclearcolor(0.7,0.7,0.7,1.0); glenable(gl_lighting); glshademodel(gl_flat); gllightfv(gl_light0,gl_position,lt); gllightfv(gl_light0,gl_ambient,ambient0); gllightfv(gl_light0,gl_diffuse,diffuse0); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("cube"); myinit(); glutdisplayfunc(mydisplay); glutreshapefunc(myreshape); glutidlefunc(myidle); glutmainloop(); return 0; 37
38 Shadow shade( ) shadow shadow() shadow /* Program showig a moving cube and following shadow */ /* Com p on Oct 10, 2005 by Kimio Sugita */ #include <GL/glut.h> #include <math.h> #include <time.h> /* object */ GLfloat vertices[][3] = -1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0, 1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0, 1.0,1.0,-1.0,1.0,-1.0,-1.0; GLfloat normal[][3] =1.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.0, 0.0,-1.0,0.0,0.0,0.0,1.0,0.0,0.0,-1.0; /* shadow object */ GLfloat pn[4] = 0.0,1.0,0.0,2.0; /* plane equation pn[0]x+pn[1]y+pn[2]z+pn[3] */ GLfloat ambient0[] = 1.0,1.0,1.0,1.0; GLfloat diffuse0[] = 1.0,1.0,1.0,1.0; GLfloat mat_diffuse[] = 1.0,0.1,0,1,1.0; GLfloat lt[] = 15.0,15.0,15.0,1.0; /* light position (lt[0],lt[1],lt[2]) */ GLfloat theta1 = 0.0, theta2 = 0.0; void polygon(int a,int b,int c,int d) glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() glnormal3fv(normal[4]); polygon(0,3,2,1); glnormal3fv(normal[0]); polygon(2,3,7,6); glnormal3fv(normal[3]); polygon(3,0,4,7); glnormal3fv(normal[2]); polygon(1,2,6,5); glnormal3fv(normal[5]); polygon(4,5,6,7); glnormal3fv(normal[1]); polygon(5,4,0,1); void sleepf(float intv) 38
39 clock_t time1,time2,interval; interval = CLOCKS_PER_SEC*intv; time1 = time2 = clock(); while(time2-time1<interval) time2 = clock(); return; void shadow() /* shadow projection matrix */ int i; GLfloat shadowm[16]; for(i=0;i<16;i++) shadowm[i] = 0.0; shadowm[0] = shadowm[5] = shadowm[10] = 1.0; shadowm[7] = -1.0/(lt[1]+pn[3]); glpushmatrix(); glpushattrib(gl_current_bit); gldisable(gl_light0); gltranslatef(lt[0],lt[1],lt[2]); glmultmatrixf(shadowm); gltranslatef(-lt[0],-lt[1],-lt[2]); /* defining shadow object */ gltranslatef(0.0,cos(theta2),sin(theta2)); glrotatef(theta1,0.0,1.0,0.0); glcolor3f(0.0,0.0,0.0); cube(); glpopattrib(); glpopmatrix(); void object() glenable(gl_light0); glmaterialfv(gl_front_and_back,gl_diffuse,mat_diffuse); glpushmatrix(); glpushattrib(gl_current_bit); gltranslatef(0.0,cos(theta2),sin(theta2)); glrotatef(theta1,0.0,1.0,0.0); cube(); glpopattrib(); glpopmatrix(); void mydisplay() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(5.0,4.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0); object(); shadow(); glflush(); glutswapbuffers(); 39
40 void myidle() theta1 += 1.0; /* for rotation use degree */ if(theta1>360.0) theta1 -= 360.0; theta2 += /720.0; /* for translation use radian */ if(theta2>2* ) theta2 = 0.0; glutpostredisplay(); sleepf(0.05); void myreshape(int w,int h) glviewport(0,0,w,h); glmatrixmode(gl_projection); glortho(-5.0,5.0,-5.0,5.0,-20.0,20.0); //glfrustum(-1.0,1.0,-1.0,1.0,2.0,30.0); //gluperspective(60.0, (double)w/(double)h,1.0,50.0); glmatrixmode(gl_modelview); void myinit() glenable(gl_depth_test); glclearcolor(0.7,0.7,0.7,1.0); glenable(gl_lighting); glshademodel(gl_flat); gllightfv(gl_light0,gl_position,lt); gllightfv(gl_light0,gl_ambient,ambient0); gllightfv(gl_light0,gl_diffuse,diffuse0); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("cube"); myinit(); glutdisplayfunc(mydisplay); glutreshapefunc(myreshape); glutidlefunc(myidle); glutmainloop(); return 0; 40
41 shadow OpnGL shadow /* Program showig a moving light and following shadow */ /* Com p on Oct 10, 2005 by Kimio Sugita */ #include <GL/glut.h> #include <math.h> #include <time.h> /* object */ GLfloat vertices[][3] = -1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0, 1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0, 1.0,1.0,-1.0,1.0,-1.0,-1.0; GLfloat normal[][3] =1.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.0, 0.0,-1.0,0.0,0.0,0.0,1.0,0.0,0.0,-1.0; /* shadow plane */ GLfloat pn[] = 0.0,1.0,0.0,1.0; /* plane equation pn[0]x+pn[1]y+pn[2]z+pn[3]=0 */ /* light source */ GLfloat ambient0[] = 1.0,1.0,1.0,1.0; GLfloat diffuse0[] = 1.0,1.0,1.0,1.0; GLfloat mat_diffuse[] = 0.8,0.7,0,0.1,1.0; GLfloat lt[] = 10.0,10.0,0.0,1.0; /* light position (lt[0],lt[1],lt[2],lt[3]) */ /* idle parameter */ GLfloat theta1 = 0.0, slide = -15.0; void polygon(int a,int b,int c,int d) glbegin(gl_polygon); glvertex3fv(vertices[a]); glvertex3fv(vertices[b]); glvertex3fv(vertices[c]); glvertex3fv(vertices[d]); void cube() glnormal3fv(normal[4]); polygon(0,3,2,1); glnormal3fv(normal[0]); polygon(2,3,7,6); glnormal3fv(normal[3]); polygon(3,0,4,7); glnormal3fv(normal[2]); polygon(1,2,6,5); glnormal3fv(normal[5]); polygon(4,5,6,7); glnormal3fv(normal[1]); polygon(5,4,0,1); 41
42 /* timer */ void sleepf(float intv) clock_t time1,time2,interval; interval = CLOCKS_PER_SEC*intv; time1 = time2 = clock(); while(time2-time1<interval) time2 = clock(); return; void shadow() /* shadow projection matrix */ int i; GLfloat shadowm[16]; for(i=0;i<16;i++) shadowm[i] = 0.0; shadowm[0] = shadowm[5] = shadowm[10] = 1.0; shadowm[7] = -1.0/(lt[1]+pn[3]); glpushmatrix(); glpushattrib(gl_current_bit); gldisable(gl_light0); gltranslatef(0.0,0.0,slide); //glrotatef(theta1,0.0,1.0,0.0); /* Shadow projection by light source */ gltranslatef(lt[0],lt[1],lt[2]); glmultmatrixf(shadowm); gltranslatef(-lt[0],-lt[1],-lt[2]); /* defining shadow object */ //glrotatef(-theta1,0.0,1.0,0.0); gltranslatef(0.0,0.0,-slide); glcolor3f(0.0,0.0,0.0); cube(); glpopattrib(); glpopmatrix(); void object() glenable(gl_light0); glmaterialfv(gl_front_and_back,gl_diffuse,mat_diffuse); glpushmatrix(); //glrotatef(theta1,0.0,1.0,0.0); gltranslatef(0.0,0.0,slide); gllightfv(gl_light0,gl_position,lt); glpopmatrix(); cube(); void mydisplay() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glulookat(3.0,4.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0); 42
43 object(); shadow(); glflush(); glutswapbuffers(); void myidle() theta1 += 1.0; /* for rotation use degree */ if(theta1>360.0) theta1 -= 360.0; slide += 0.1; if(slide>15.0) sleepf(3.0); slide = -15.0; ; glutpostredisplay(); sleepf(0.05); void myreshape(int w,int h) glviewport(0,0,w,h); glmatrixmode(gl_projection); glortho(-8.0,8.0,-8.0,8.0,-20.0,20.0); //glfrustum(-1.0,1.0,-1.0,1.0,2.0,30.0); //gluperspective(60.0, (double)w/(double)h,1.0,50.0); glmatrixmode(gl_modelview); void myinit() glenable(gl_depth_test); glclearcolor(0.7,0.7,0.7,1.0); glenable(gl_lighting); glshademodel(gl_flat); gllightfv(gl_light0,gl_position,lt); gllightfv(gl_light0,gl_ambient,ambient0); gllightfv(gl_light0,gl_diffuse,diffuse0); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("shadow"); myinit(); glutdisplayfunc(mydisplay); glutreshapefunc(myreshape); glutidlefunc(myidle); glutmainloop(); return 0; 43
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/*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#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 informationlibaux.dvi
AUX OpenGL 1 OpenGL (AUX libaux.a) OpenGL Programming Guide () OpenGL 1 OpenGL OS (API) OS OS OS OpenGL Windows Windows X X OpenGL Programming Guide AUX toolkit AUX OS OpenGL SGI OpenGL OS OpenGL AUX Windows
More information第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 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 information3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程
3. 3D ビューイング 1. 3Dグラフィックス処理の一般過程 2. 射影と射影変換 3. ビューボリュームとクリッピング 4. 陰面処理とデプスバッファ 5. ビューポート変換 6. 3Dグラフィックスを描く 7. モデルビュー変換 3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程 3D グラフィックス処理の一般過程 1. モデリング変換 座標系の異なる複数のオブジェクトを仮想世界に配置し,
More informationj 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$ 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 information2 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 information2 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 information2 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謗域・ュ逕ィppt
情報工学 2017 年度後期第 5 回 [11 月 1 日 ] 静岡大学 工学研究科機械工学専攻ロボット 計測情報講座創造科学技術大学院情報科学専攻 三浦憲二郎 講義日程 第 6 回 11 月 8 日画像処理パート第 1 回 第 7 回 11 月 15 日 CGパート第 6 回 第 8 回 11 月 22 日 CGパート第 7 回 第 9 回 11 月 29 日 CGパート試験 講義アウトライン [11
More informationdouble 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 informationOpenGL Programming Course OpenGL Programming Course FAQ
OpenGL NK EXA Corporation OpenGL@dst.nk-exa.co.jp OpenGL@dst.nk-exa.co.jp OpenGL FAQ (http://www.nk-exa.co.jp/mmtech/opengledu/faq.shtml) i 1 OpenGL 1{1 1.1 OpenGL : : : : : : : : : : : : : : : : : : :
More informationOpenGL & 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 information2 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演算増幅器
コンピュータグラフィックス 2 前回は GLUT を使った簡単な 2 次元グラフィックスについて習った 今週は以下の項目について 補足していく イベント駆動型プログラムの動作について コンピュータグラフィックスの座標系 イベント駆動型プログラム従来のプログラムとの違いこれまでに学習してきたプログラムは上から下に順次実行され 条件分岐や繰り返し処理によって プログラムの流れ (flow: フロー )
More informationmanual.dvi
' & VR CompleXcope $ % 1 2 509{5292 322{6 1) kage@tokitheorynifsacjp 2) sato@tokitheorynifsacjp CompleXcope Programming Guide, Ver 1, by A Kageyama and T Sato, August 1998 1 CompleXcope 5 11 : : : : :
More informationuntitled
2004/12/21 2/2 (11/16) DT-MRI (11/30) /OpenGL 12/7 12/14 (12/21) 1/11 (1/18) OpenGL ~ ~ OpenGL Silicon Graphics, OpenGL ~ ~ OpenGL OpenGL Utility Library (GLU) OpenGL. OpenGL. OpenGL Utility Toolkit (GLUT)
More information第7章 レンダリング
7 May 18, 2012 1 / 60 71 ( ) CG 3 ( ) 2 / 60 72 71 ( ) 3 (rendering) 1 / (hidden line/surface calculation) a (outer normal algorithm) b Z (Z-buffer algorithm) c (scan-line algorithm) 2 (shading) a (flat
More information第7章 レンダリング
7 April 11, 2017 1 / 59 7.1 ( ) CG 3 ( ) 2 / 59 7.2 7.2.1 ( ) 3 (rendering) 1 / (hidden line/surface calculation) a (outer normal algorithm) b Z (Z-buffer algorithm) c (scan-line algorithm) 2 (shading)
More information2 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 information2 : 2008/12/ /01/ G :
2 : 2008/12/08 2008/01/16 075730G : 1 project draw main.cpp 1 draw main.cpp /* * main.cpp * draw * * Created by C-T on 08/12/08. * Copyright 2008 MyCompanyName. All rights reserved. * */ #include
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>
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 information2 T ax 2 + 2bxy + cy 2 + dx + ey + f = 0 a + b + c > 0 a, b, c A xy ( ) ( ) ( ) ( ) u = u 0 + a cos θ, v = v 0 + b sin θ 0 θ 2π u = u 0 ± a
2 T140073 1 2 ax 2 + 2bxy + cy 2 + dx + ey + f = 0 a + b + c > 0 a, b, c A xy u = u 0 + a cos θ, v = v 0 + b sin θ 0 θ 2π u = u 0 ± a cos θ, v = v 0 + b tan θ π 2 < θ < π 2 u = u 0 + 2pt, v = v 0 + pt
More information2 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 information1 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$ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a
$ 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 informationXMPによる並列化実装2
2 3 C Fortran Exercise 1 Exercise 2 Serial init.c init.f90 XMP xmp_init.c xmp_init.f90 Serial laplace.c laplace.f90 XMP xmp_laplace.c xmp_laplace.f90 #include int a[10]; program init integer
More informationMicrosoft PowerPoint - info_eng3_05ppt.pptx
インタラクティブシステム構築法 第 5 回 OpenGL と GLUT の使い方 (3) 埼玉大学情報システム工学科小林貴訓 シェーディング 光源の設定を有効にする glenable(gl_lighting); // 光源の設定を有効にする glenable(gl_light0); //0 番目の光源を有効にする (8 個まで設定可能 ) 光源の位置 GLfloat light0pos[] = {
More information準備 計算結果を可視化するために OpenGL を 利用する. 2
2. 2 次元粒子法シミュレーション (+ 少しだけ OpenGL) 茨城大学工学部 教授乾正知 準備 計算結果を可視化するために OpenGL を 利用する. 2 OpenGL 3 次元コンピュータグラフィックス用の標準的なライブラリ. 特に CAD やアート, アニメーション分野 ( ゲーム以外の分野 ) で広く利用されている. OpenGL は仕様がオープンに決められており, 企業から独立した団体が仕様を管理している.
More information1) 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 informationFair 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演算増幅器
スペースインベーダーもどき 1000 行プログラムの参考として スペースインベーダーもどきのプログラムを配布する いくつか習って いないものもあるので 補足の説明を加えていく 文字列の描画 文字の描画は glutbitmapcharacter() を用いる これは以下のようにして利用する int i; char *str = "Display String"; glcolor3f(0.0, 0.0,
More information2 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 informationMicrosoft Word - opengl講義資料ha.doc
[OpenGL:1] OpenGL とは 1.OpenGL とは何か? 米国 Silicon Graphics 社 (SGI) が中心となって開発した 3 次元グラフィックスライブラリである.SGI はグラフィックスに特化したワークステーション (GWS) の開発を積極的に行い, 自社の GWS 上で稼動するグラフィックスライブラリ IRIS GL を開発したが, その後, この仕様を公開したライブラリとして
More information謗域・ュ逕ィppt
情報工学 217 年度後期第 4 回 [1 月 25 日 ] 静岡大学 工学研究科機械工学専攻ロボット 計測情報講座創造科学技術大学院情報科学専攻 三浦憲二郎 ローカル座標系による移動 講義アウトライン [1 月 25 日 ] ビジュアル情報処理 1.3.4 投影変換 1.3.5 いろいろな座標系と変換 OpenGL 投影変換 曲線の描画 トロコイド ( 外トロコイドと内トロコイド ) 頂点変換の手順
More information謗域・ュ逕ィppt
情報工学 212 年度後期第 5 回 [1 月 31 日 ] 静岡大学 創造科学技術大学院情報科学専攻工学部機械工学科計測情報講座 三浦憲二郎 講義日程 第 8 回 11 月 21 日 ( 水 ) CG パート試験 講義アウトライン [1 月 31 日 ] ビジュアル情報処理 1.3.4 投影変換 1.3.5 いろいろな座標系と変換 OpenGL 投影変換 曲線の描画 トロコイド ( 外トロコイドと内トロコイド
More information1 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 informationMicrosoft Word - opengl講義資料2013.doc
[OpenGL:1] OpenGL とは 1.OpenGL とは何か? 米国 Silicon Graphics 社 (SGI) が中心となって開発した 3 次元グラフィックスライブラリである.SGI はグラフィックスに特化したワークステーション (GWS) の開発を積極的に行い, 自社の GWS 上で稼動するグラフィックスライブラリ IRIS GL を開発したが, その後, この仕様を公開したライブラリとして
More information3. OpenGL を利用するための準備作業 1) Tao Framework をダウンロードしてインストールする. Download から taoframework setup.exe をダウン
[OpenGL:1] OpenGL とは 1.OpenGL とは何か? 米国 Silicon Graphics 社 (SGI) が中心となって開発した 3 次元グラフィックスライブラリである.SGI はグラフィックスに特化したワークステーション (GWS) の開発を積極的に行い, 自社の GWS 上で稼動するグラフィックスライブラリ IRIS GL を開発したが, その後, この仕様を公開したライブラリとして
More informationMicrosoft Word - mediaJikkenCG_no2_2007.doc
2007 年度メディア情報学実験 1 CG テキスト第 2~4 週 :OpenGL ライブラリを使った 3 次元 CG プログラミング立命館大学情報理工学部メディア情報学科 1. 実験の目的と手順本実験は,(1)OpenGLライブラリを用いたCGプログラミングの手法を学ぶ,(2) プログラミングを通して, CGの基礎技術を体験的に学ぶ,(3) インタラクティブな3 次元 CGアニメーションを作成する方法について学ぶ,
More information(7) u 1 θ A {u 1, u, u 3 } U = (u 1, u, u 3 ) A = UT (θ) + tu t UAU = T (θ) + () θ x z cos θ 0 sin θ cos θ sin θ 0 X(θ) = 0 cos θ sin θ, Y (θ) =
Mathematics for Computer Graphics 1 1.1 a = (a x, a, a z ), b = (b x, b, b z ) c = (c x, c, c z ) a, b a, b a, b, c x,, z ( ) c a, b (vector product) (outer product) a b c = ( a b a z b z, a z b z a x
More informationNB
JAPLA 研究会資料 2010/2/27 J の OpenGL グラフィックス - その 7 - フラー ドームと照光表示 - 西川利男 0. はじめに OpenGL 正多面体グラフィックスとして 今回はフラー ドームに挑戦してみた バックミンスター フラー (Richard Buckminster Fuller, 1895-1983 は多才な建築家 科学者 思想家として知られ その名前を冠した
More information沼津工業高等専門学校
VisualStudio2010 を用いた OpenGL(Glut) コンソール アプリケーションの作成方法 初版 : 2007.01.06 藤尾 改訂 : 2010.08.24 秋山 - 1 - - 目次 - Ⅰ. プログラミングの準備 3 Ⅰ.1 はじめに 3 Ⅰ.2 OpenGL の環境設定 3 Ⅱ. プログラミングの第 1 歩 ( 簡単なプログラムの作成 ) 3 Ⅱ.1 プロジェクトの作成と保存
More informationTekutama 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 informationMicrosoft Word - mediaJikkenCG_no2_2012.doc
2012 年度メディア情報学実験 1 CG テキスト第 2~5 週 :OpenGL ライブラリを使った 3 次元 CG プログラミング立命館大学情報理工学部メディア情報学科 1. 実験の目的と手順本実験は,(1)OpenGLライブラリを用いたCGプログラミングの手法を学ぶ,(2) プログラミングを通して, CGの基礎技術を体験的に学ぶ,(3) インタラクティブな3 次元 CGアニメーションを作成する方法について学ぶ,
More information[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±
[1] #include printf("hello, world."); (G1) int -32768 32767 long int -2147483648 2147483647 float ±3.4 10 38 ±3.4 10 38 double ±1.7 10 308 ±1.7 10 308 char [2] #include int a, b, c, d,
More information£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡
(2018) 2018 5 17 0 0 if switch if if ( ) if ( 0) if ( ) if ( 0) if ( ) (0) if ( 0) if ( ) (0) ( ) ; if else if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 (0) 2 if else
More informationコンピュータ概論
4.1 For Check Point 1. For 2. 4.1.1 For (For) For = To Step (Next) 4.1.1 Next 4.1.1 4.1.2 1 i 10 For Next Cells(i,1) Cells(1, 1) Cells(2, 1) Cells(10, 1) 4.1.2 50 1. 2 1 10 3. 0 360 10 sin() 4.1.2 For
More information2 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 informationr07.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 information1 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 informationohp07.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イントロダクション
プログラミング演習 IV 第 8 回 OpenCV とテクスチャマッピング物体の発光や透過 埼玉大学情報システム工学科 小林貴訓 OpenCV PC で画像処理を行うライブラリ インテル社の画像処理ライブラリが起源 2000 年頃に最初のバージョン CPU でも画像処理ができることを見せたかった? Open 化して, 現在は Willow Garage( ウィロー ガレージ ) が開発を行っている
More informationx h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i )
1 f(x) a b f(x)dx = n A(x i ) (1) ix [a, b] n i A(x i ) x i 1 f(x) [a, b] n h = (b a)/n y h = (b-a)/n y = f (x) h h a a+h a+2h a+(n-1)h b x 1: 1 x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x
More information2017 p vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = 0 (79) J s flux (67) J (79) J( r, t) = k δf δs s( r,
27 p. 47 7 7. vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = (79) J s flux (67) J (79) J( r, t) = k δf δs s( r, t) t = k δf δs (59) TDGL (8) (8) k s t = [ T s s 3 + ξ
More informationKrylov (b) x k+1 := x k + α k p k (c) r k+1 := r k α k Ap k ( := b Ax k+1 ) (d) β k := r k r k 2 2 (e) : r k 2 / r 0 2 < ε R (f) p k+1 :=
127 10 Krylov Krylov (Conjugate-Gradient (CG ), Krylov ) MPIBNCpack 10.1 CG (Conjugate-Gradient CG ) A R n n a 11 a 12 a 1n a 21 a 22 a 2n A T = =... a n1 a n2 a nn n a 11 a 21 a n1 a 12 a 22 a n2 = A...
More informationC言語によるアルゴリズムとデータ構造
Algorithms and Data Structures in C 4 algorithm List - /* */ #include List - int main(void) { int a, b, c; int max; /* */ Ÿ 3Ÿ 2Ÿ 3 printf(""); printf(""); printf(""); scanf("%d", &a); scanf("%d",
More informationMicrosoft PowerPoint - 04.pptx
初期化 コールバック関数の登録 glutmainloop() 描画関数 マウス処理関数 キーボード処理関数などの関数ポインタを登録する イベント待ちの無限ループ 再描画? no マウス入力? no キーボード入力? no yes yes yes 描画関数の呼び出し マウス処理関数の呼び出し キーボード処理関数の呼び出し void keyboard(unsigned char key, int x,
More informationC B
C 095707B 2010 6 8 1 LEVE1 2 1.1 LEVEL 1.1................................................ 2 1.1.1 1................................................ 2 1.1.2 1.2..............................................
More informationJAPLA研究会資料 2012/8/2
JAPLA 研究会資料 2012/8/2 ローレンツなどカオスの 3D グラフィックス J-OpenGL により カオスの実行を段階的に観察する 西川利男 ローレンツ レスターなどカオスの図形は 志村氏により J の簡便かつ強力なグラフィックス機能を示す例としてたびたび紹介されている これらのカオス現象の物理は それ自身私にとってもおおいに興味をそそられるテーマである J の OpenGL グラフィックスを用いて
More informationjoho09.ppt
s M B e E s: (+ or -) M: B: (=2) e: E: ax 2 + bx + c = 0 y = ax 2 + bx + c x a, b y +/- [a, b] a, b y (a+b) / 2 1-2 1-3 x 1 A a, b y 1. 2. a, b 3. for Loop (b-a)/ 4. y=a*x*x + b*x + c 5. y==0.0 y (y2)
More information2009 T
T060061 Wii Visual C++ 2008 Express Edition Visual C++ 2008 Express Edition ++ ++ Paint.net ++ 1 2009 T060061 2 1 4 2 4 2.1 Visual C++ 2008 Express Edition.......................... 4 2.2.....................................
More informationJAPLA研究会資料 /6/15
JAPLA 研究会資料 20013/6/15 J-OpenGL による 3D グラフィックス - その 10 * メビウスの帯へ向けて -J-OpenGL をどう理解するか - 西川 利男 J で OpenGL を利用することで高度の三次元グラフィックスの処理が可能となった 前回の例会で志村正人氏よりメビウスの帯やクラインの壷など アートとして眺めるだけでも楽しいグラフィックスがいろいろ紹介された
More informationコンピュータグラフィックスS 演習資料
コンピュータグラフィックス S 演習資料 第 4 回シェーディング マッピング 九州工業大学情報工学部システム創成情報工学科講義担当 : 尾下真樹 1. 演習準備 今回の演習も 前回までの演習で作成したプログラムに続けて変更を行う まずは シェーディングの演習のため 描画処理で 回転する一つの四角すいを描画するように変更する 画面をクリア ( ピクセルデータと Z バッファの両方をクリア ) glclear(
More informationJAPLAシンポジウム資料 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コンピュータグラフィクス論
コンピュータグラフィクス論 2015 年 4 月 9 日 高山健志 教員紹介 高山健志 ( 国立情報学研究所特任助教 ) http://research.nii.ac.jp/~takayama/ takayama@nii.ac.jp 蜂須賀恵也 ( 創造情報学専攻講師 ) http://www.ci.i.u-tokyo.ac.jp/~hachisuka/ thachisuka@siggraph.org
More informationex01.dvi
,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double
More information(search: ) [1] ( ) 2 (linear search) (sequential search) 1
2005 11 14 1 1.1 2 1.2 (search:) [1] () 2 (linear search) (sequential search) 1 2.1 2.1.1 List 2-1(p.37) 1 1 13 n
More informationGraphics Performance Tuning () Z 2
All Titles White, 54 Point, OpenGL Bold Italic, Performance Helvetica Narrow, 2 Point Leading Tuning Nihon Silicon Graphics K.K. Sales Division Graphics Grp Systems Engineer Takehiko Terada 1995/07/20
More information/ 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 yasu@jaist.ac.jp / SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming
More information5. p.1/37
5. taiji@aihara.co.jp p.1/37 dx dt dy dt dz dt = σx + σy = xz + rx y = xy bz σ = 10, b = 8/3, r = 28, x 0 = 10, y 0 = 20, z 0 = 30 t < 10000δt (δt = 0.01) p.2/37 , 1991. Numerical Recipes in C Netlib LAPACK,
More informationXACC講習会
www.xcalablemp.org 1 4, int array[max]; #pragma xmp nodes p(*) #pragma xmp template t(0:max-1) #pragma xmp distribute t(block) onto p #pragma xmp align array[i] with t(i) int array[max]; main(int argc,
More information1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return 0; 戻り値 1: main() 2.2 C main
C 2007 5 29 C 1 11 2 2.1 main() 1 FORTRAN C main() main main() main() 1 return 1 1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return
More informationJAPLA研究会資料 2013/5/25
JAPLA 研究会資料 2013/5/25 J-OpenGL による 4 進フラクタル立体木のグラフィックス 西川利男 今年の大学センター試験の出題をきっかけとして 3 進法およびそれを活用した 3 進フラクタル木の J プログラムについて先に報告した [1][2] 図形表示の値を 3 進法で表すことで フラクタル木のグラフィックスが ごく自然に行われた それでは 4 進法ではどうだろうか? 同じ発想を展開すると
More information£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –
(2018) 11 2018 12 13 2 g v dv x dt = bv x, dv y dt = g bv y (1) b v 0 θ x(t) = v 0 cos θ ( 1 e bt) (2) b y(t) = 1 ( v 0 sin θ + g ) ( 1 e bt) g b b b t (3) 11 ( ) p14 2 1 y 4 t m y > 0 y < 0 t m1 h = 0001
More information1 28 6 12 7 1 7.1...................................... 2 7.1.1............................... 2 7.1.2........................... 2 7.2...................................... 3 7.3...................................
More informationコンピューターグラフィックスS
コンピューターグラフィックス S 第 12 回シェーディング マッピング システム創成情報工学科尾下真樹 2018 年度 Q2 今回の内容 前回の復習 シェーディング 光のモデル スムーズシェーディング シェーディング ( 続き ) OpenGL での光源情報の設定 ラジオシティ 影の表現 BRDF マッピング 今回の内容 シェーディング 光の効果の表現 マッピング 生成画像 表面の素材の表現 オブジェクト
More informationfile:///D|/C言語の擬似クラス.txt
愛知障害者職業能力開発校 システム設計科 修了研究発表会報告書 題名 : C 言語の擬似クラス あらまし : C 言語でクラスを作れるという噂の真偽を確かめるために思考錯誤した まえがき : VC++ や Java その他オブジェクト指向の言語にはクラスが存在して クラスはオブジェクトの設計図である 手法 : C++ のクラスを解析して C++ のクラスを作成して C 言語に翻訳する class struct
More informationC 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in
C 1 / 21 C 2005 A * 1 2 1.1......................................... 2 1.2 *.......................................... 3 2 4 2.1.............................................. 4 2.2..............................................
More information115 9 MPIBNCpack 9.1 BNCpack 1CPU X = , B =
115 9 MPIBNCpack 9.1 BNCpack 1CPU 1 2 3 4 5 25 24 23 22 21 6 7 8 9 10 20 19 18 17 16 X = 11 12 13 14 15, B = 15 14 13 12 11 16 17 18 19 20 10 9 8 7 6 21 22 23 24 25 5 4 3 2 1 C = XB X dmat1 B dmat2 C dmat
More information211 kotaro@math.titech.ac.jp 1 R *1 n n R n *2 R n = {(x 1,..., x n ) x 1,..., x n R}. R R 2 R 3 R n R n R n D D R n *3 ) (x 1,..., x n ) f(x 1,..., x n ) f D *4 n 2 n = 1 ( ) 1 f D R n f : D R 1.1. (x,
More informationTA 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 mireport@cyber.t.u-tokyo.ac.jp 20101213 abcdefgh abcdefgh
More informationAutoTuned-RB
ABCLib Working Notes No.10 AutoTuned-RB Version 1.00 AutoTuned-RB AutoTuned-RB RB_DGEMM RB_DGEMM ( TransA, TransB, M, N, K, a, A, lda, B, ldb, b, C, ldc ) L3BLAS DGEMM (C a Trans(A) Trans(B) b C) (1) TransA:
More informationKageyama (Kobe Univ.) / 36
DrawArrays DrawElements 05 1 2015.05.19 Kageyama (Kobe Univ.) 2015.05.19 1 / 36 Kageyama (Kobe Univ.) 2015.05.19 2 / 36 Kageyama (Kobe Univ.) 2015.05.19 3 / 36 Web アプリ HTML + CSS + JavaScript + シェーダソースコード
More informationuntitled
II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}
More informationDisplay 表示の初期化が CAVE 表示の初期化に置き換わり CAVE 用のプログラムに書き換えることが出来る 表 2 1 画面 (Windows LINUX IRIX) 用の OpenGL #include<stdio.h> #include<windows.h> #include<gl/g
OpenGL による CAVE とファントムへの 3 次元表示 井門俊治 ( いどしゅんじ ) 埼玉工業大学工学部情報システム学科 利用環境 :Windows, LINUX, IRIX, AVS, AVS-MPE, OpenGL,VRML,Java3D 1. 目的 CAVE の表示するためには 従来は OpenGL によるプログラミングが行われていた これに対して 20 00 年末より AVS において
More informationコンピュータグラフィクス論
コンピュータグラフィクス論 2016 年 4 月 7 日 高山健志 教員紹介 高山健志 ( 国立情報学研究所特任助教 ) http://research.nii.ac.jp/~takayama/ takayama@nii.ac.jp 蜂須賀恵也 ( 創造情報学専攻講師 ) http://www.ci.i.u-tokyo.ac.jp/~hachisuka/ thachisuka@siggraph.org
More informationr11.dvi
19 11 ( ) 2019.4.20 1 / 1.1 ( n n O(n 2 O(n 2 ) ( 1 d n 1 n logn O(nlogn n ( n logn C 1.2 ( ( merge 2 1 1 3 1 4 5 4 2 3 7 9 7 1 2 3 4 5 7 9 1: 2 ivec merge int *ivec_new(int size) { int *a = (int*)malloc((size+1)
More informationohp11.dvi
19 11 ( ) 2019.4.20 1 / ( ) n O(n 2 ) O(n 2 ) ( ) 1 d n 1 n logn O(nlogn) n ( n logn C ) 2 ( ) ( merge) 2 1 1 3 1 4 5 4 2 3 7 9 7 1 2 3 4 5 7 9 1: 2 ivec merge 3 ( ) (2) int *ivec_new(int size) { int *a
More information卒 業 研 究 報 告.PDF
C 13 2 9 1 1-1. 1-2. 2 2-1. 2-2. 2-3. 2-4. 3 3-1. 3-2. 3-3. 3-4. 3-5. 3-5-1. 3-5-2. 3-6. 3-6-1. 3-6-2. 4 5 6 7-1 - 1 1 1-1. 1-2. ++ Lisp Pascal Java Purl HTML Windows - 2-2 2 2-1. 1972 D.M. (Dennis M Ritchie)
More informationコンピュータグラフィックス特論Ⅱ
コンピュータグラフィックス特論 Ⅱ 第 2 回 OpenGL プログラミングの基礎 九州工業大学尾下真樹 今日の内容 OpenGL プログラミングの基礎 C 言語 +OpenGL+GLUT によるプログラミング 座標変換の基礎 アフィン変換行列を使った視野変換の設定 いずれも 学部の講義 ( レベルの内容 ) の復習 今日の内容 OpenGL&GLUTの概要 サンプルプログラムの概要 座標変換 変換行列の設定
More informationc-all.dvi
III(994) (994) from PSL (9947) & (9922) c (99,992,994,996) () () 2 3 4 (2) 2 Euler 22 23 Euler 24 (3) 3 32 33 34 35 Poisson (4) 4 (5) 5 52 ( ) 2 Turbo 2 d 2 y=dx 2 = y y = a sin x + b cos x x = y = Fortran
More information/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v
1 http://www7.bpe.es.osaka-u.ac.jp/~kota/classes/jse.html kota@fbs.osaka-u.ac.jp /* do-while */ #include #include int main(void) double val1, val2, arith_mean, geo_mean; printf( \n );
More informationC による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.
C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/009383 このサンプルページの内容は, 新装版 1 刷発行時のものです. i 2 22 2 13 ( ) 2 (1) ANSI (2) 2 (3) Web http://www.morikita.co.jp/books/mid/009383
More information新版明解C言語 実践編
2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,
More informationex01.dvi
,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) { double
More information