Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- float x = 0;
- int c = 0;
- int m,n,p;
- float angle = 0;
- void single_blade(void)
- {
- glColor3f(1,1,1);
- glBegin(GL_LINE_LOOP);
- glVertex3f(0,0,0);
- glVertex3f(.1,.05,0);
- glVertex3f(.1,.1,0);
- glVertex3f(.2,.2,0);
- glVertex3f(.2,.25,0);
- glVertex3f(.1,.25,0);
- glVertex3f(.25,.35,0);
- glVertex3f(.2,.35,0);
- glVertex3f(.3,.45,0);
- glVertex3f(.25,.45,0);
- glVertex3f(.4,.55,0);
- glVertex3f(.3,.55,0);
- glVertex3f(-.3,.55,0);
- glVertex3f(-.4,.55,0);
- glVertex3f(-.25,.45,0);
- glVertex3f(-.3,.45,0);
- glVertex3f(-.2,.35,0);
- glVertex3f(-.25,.35,0);
- glVertex3f(-.1,.25,0);
- glVertex3f(-.2,.25,0);
- glVertex3f(-.2,.2,0);
- glVertex3f(-.1,.1,0);
- glVertex3f(-.1,.05,0);
- glVertex3f(0,0,0);
- glEnd();
- }
- void full_fan(void)
- {
- single_blade();
- glRotatef(90,0,0,1);
- single_blade();
- glRotatef(180,0,0,1);
- single_blade();
- glRotatef(270,0,0,1);
- single_blade();
- }
- void all_fan(void)
- {
- full_fan();
- glPushMatrix();
- glTranslatef(-0.7,-0.7, 0);
- glScalef(.3 , .3 , 1);
- full_fan();
- glPopMatrix();
- glPushMatrix();
- glTranslatef(0.7,0.7,0);
- glScalef(.3 , .3 , 1);
- full_fan();
- glPopMatrix();
- glPushMatrix();
- glTranslatef(-0.7,0.7,0);
- glScalef(.3 , .3 , 1);
- full_fan();
- glPopMatrix();
- glPushMatrix();
- glTranslatef(0.7,-0.7,0);
- glScalef(.3 , .3 , 1);
- full_fan();
- glPopMatrix();
- }
- void display(void)
- {
- glClearColor(0.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glLoadIdentity();
- gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
- glRotatef(angle+=0.5,0,0,1);
- all_fan();
- glFlush();
- //find a way to make 4 projections of the complete fan in four different corner of the screen.
- }
- void reshape(int w, int h) {
- glViewport(0, 0, (GLsizei)w, (GLsizei)h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(30, 1, 1.0, 100.0);
- glMatrixMode(GL_MODELVIEW);
- }
- int main(int argc, char **argv) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE); // single buffering.. (double buffering for animation)
- // full screen is 1000,1000
- // this 0,0 or 1000,1000 are world co ordinates
- glutInitWindowSize(700, 700);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("A basic OpenGL Window");
- // registering callback functions
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutIdleFunc(display);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement