Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- #include <stdlib.h>
- #include <math.h>
- void initOpenGl()
- {
- glClearColor(0.1,0.6,0.4,0);
- glMatrixMode(GL_PROJECTION);
- gluOrtho2D(0,700,0,500);
- glMatrixMode(GL_MODELVIEW);
- }
- void wheel(int x,int y)
- {
- float th;
- glBegin(GL_POLYGON);
- glColor3f(0.6,0.4,0.1);
- for(int i=0;i<360;i++)
- {
- th=i*(3.1416/180);
- glVertex2f(x+20*cos(th),y+20*sin(th));
- }
- glEnd();
- }
- void car()
- {
- //Top
- glBegin(GL_POLYGON);
- glVertex2f(150,160);
- glVertex2f(200,220);
- glVertex2f(400,220);
- glVertex2f(450,160);
- glEnd();
- //Bottom
- glBegin(GL_POLYGON);
- glVertex2f(100,100);
- glVertex2f(100,160);
- glVertex2f(455,160);
- glVertex2f(455,100);
- glEnd();
- wheel(200,100);
- wheel(380,100);
- }
- void display()
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0.6,0.1,0.4);
- car();
- glutSwapBuffers();
- glFlush();
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc,argv);
- glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE );
- glutInitWindowSize(700,500);
- glutCreateWindow("Sohag Raha - 182-15-2164");
- initOpenGl();
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement