-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCar_structure.cpp
More file actions
71 lines (61 loc) · 1.15 KB
/
Car_structure.cpp
File metadata and controls
71 lines (61 loc) · 1.15 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<GL\glut.h>
#include<iostream>
#include<windows.h>
using namespace std;
void myInit()
{
glClearColor(0, 0.2, 0.2, .5);
glColor3f(1.0, 0.3, 0.9);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 400.0, 0.0, 400.0);
}
void wheel(int x, int y)
{
float th;
glBegin(GL_POLYGON);
glColor3f(0, 0, 0);
for (int i = 0; i < 360; i++)
{
int th = i * (3.1416 / 180); glVertex2f(x + 20 * cos(th), y + 20 * sin(th));
}
glEnd();
}
void Polygon()
{
// Car Body
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2f(50, 50);
glVertex2f(50, 80);
glVertex2f(225, 80);
glColor3f(0.0f, 0.5f, 1.0f);
glVertex2f(225, 50);
glBegin(GL_POLYGON);
glVertex2f(75, 80);
glColor3f(0.0f, 0.5f, 1.0f);
glVertex2f(100, 100);
glVertex2f(200, 100);
glVertex2f(225, 80);
glEnd();
wheel(100, 50);
wheel(190, 50);
glFlush();
}
void myDisplay()
{
Polygon();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(1200, 740);
glutInitWindowPosition(0, 0);
glutCreateWindow("Car Structure");
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
return 0;
}