Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //list1322.c
- #include<gl/glut.h>
- #include <math.h>
- static
- int angle=0;
- float tx=0.0;
- float ty=0.0;
- float tz=0.0;
- float sx=1.0;
- float sy=1.0;
- float sz=1.0;
- //Call back Function
- static void
- display()
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode (GL_MODELVIEW);
- glLoadIdentity();
- //eye-position, direction, x-y-z up
- gluLookAt(0.0,30.0,100.0,0.0,0.0,0.0,0.0,1.0,0.0);
- glPushMatrix();
- glRotatef(angle,1.0,0.0,0.0);
- glRotatef(angle,0.0,1.0,0.0);
- glRotatef(angle,0.0,0.0,1.0);
- glTranslatef(tx,ty,tz);
- //glScalef(sx, sy, sz);
- glEnable(GL_COLOR_MATERIAL);
- glColor3f(0.9,0.5,0.2);
- glutSolidTeapot(25.0);
- glDisable(GL_COLOR_MATERIAL);
- glPopMatrix();
- glutSwapBuffers();
- }
- //windows resize function
- static void
- reshape(int w,int h)
- {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glViewport(0,0,w,h);
- gluPerspective(40.0,(w/(double)h),1.0,1000.0);
- }
- //Call Status:Idle
- static void
- idle()
- {
- angle=(angle+1)%360;
- tx=fmodf(tx+0.01,10);
- ty=fmodf(ty+0.01,10);
- tz=fmodf(tz+0.01,10);
- sx=fmodf(sx+0.01,10);
- sy=fmodf(sy+0.01,10);
- sz=fmodf(sz+0.01,10);
- glutPostRedisplay();
- }
- int
- main(int argc, char* argv[])
- {
- //GLUT Initialization
- glutInit(&argc,argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowSize(400,300);
- glutCreateWindow(argv[0]);
- //Setting OpenGL
- glClearColor(1.0,1.0,1.0,0.0);
- glShadeModel(GL_SMOOTH);
- glCullFace(GL_FRONT);
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
- //Callback
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutIdleFunc(idle);
- glutMainLoop();
- return 0;
- }
- /*
- void drawAry(void)
- {
- int i,j;
- GLfloat txyz[12][3]=
- {
- //{0.0,0.0,0.0},
- {0.1,0.0,0.0},
- {0.0,0.0,0.0},
- {-0.1,0.0,0.0},
- {0.0,0.0,0.0},
- {0.0,0.1,0.0},
- {0.0,0.0,0.0},
- {0.0,-0.1,0.0},
- {0.0,0.0,0.0},
- {0.0,0.0,0.1},
- {0.0,0.0,0.0},
- {0.0,0.0,-0.1},
- {0.0,0.0,0.0}
- };
- for(i=0;i<12;i++)
- {
- tx=txyz[i][0];
- ty=txyz[i][1];
- tz=txyz[i][2];
- //printf("%d\n",tx);
- //printf("%d\n",ty);
- //printf("%d\n",tz);
- };
- GLfloat sxyz[11][3]=
- {
- {1.0,1.0,1.0},
- {1.1,1.1,1.1},
- {1.2,1.2,1.2},
- {1.3,1.3,1.3},
- {1.4,1.4,1.4},
- {1.5,1.5,1.5},
- {1.4,1.4,1.4},
- {1.3,1.3,1.3},
- {1.2,1.2,1.2},
- {1.1,1.1,1.1},
- {1.0,1.0,1.0},
- };
- for(j=0;j<11;j++)
- {
- sx=sxyz[j][0];
- sy=sxyz[j][1];
- sz=sxyz[j][2];
- //printf("%d\n",sx);
- //printf("%d\n",sy);
- //printf("%d\n",sz);
- };
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment