Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
110 lines (84 loc) · 2.08 KB
/
Copy pathmain.cpp
File metadata and controls
110 lines (84 loc) · 2.08 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* GLUT Shapes Demo
*
* Written by Nigel Stewart November 2003
*
* This program is test harness for the sphere, cone
* and torus shapes in GLUT.
*
* Spinning wireframe and smooth shaded shapes are
* displayed until the ESC or q key is pressed. The
* number of geometry stacks and slices can be adjusted
* using the + and - keys.
*/
#include <bits/stdc++.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <stdlib.h>
#include <windows.h>
void display();
void reshape(int,int);
void timer(int);
void init(){
glClearColor(0.0,0.0,0.0,1.0);
}
double zeroth=15,first=10,second=5,third=0,forth=-5;
int flag=0;
int main(int argc,char**argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowPosition(((0.5*GLUT_SCREEN_WIDTH)+500),((0.5*GLUT_SCREEN_HEIGHT)));
glutInitWindowSize(500,500);
glutCreateWindow("Road");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutTimerFunc(0,timer,0);
init();
glutMainLoop();
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glLineWidth(10.0f);
glBegin(GL_LINES);
//road sides
glVertex2d(-3,10);
glVertex2d(-5,-10);
glVertex2d(3,10);
glVertex2d(5,-10);
//stripes
glVertex2d(0,zeroth);
glVertex2d(0,zeroth-4);
glVertex2d(0,first);
glVertex2d(0,first-4);
glVertex2d(0,second);
glVertex2d(0,second-4);
glVertex2d(0,third);
glVertex2d(0,third-4);
glVertex2d(0,forth);
glVertex2d(0,forth-4);
glEnd();
if(zeroth<-9.9)zeroth=15;
if(first<-9.9)first=15;
if(second<-9.9)second=15;
if(third<-9.9)third=15;
if(forth<-9.9)forth=15;
zeroth=zeroth-0.1;
first=first-0.1;
second=second-0.1;
third=third-0.1;
forth=forth-0.1;
glutSwapBuffers();
}
void reshape(int w,int h){
glViewport((GLint)0,(GLint)0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-10,10,-10,10);
glMatrixMode(GL_MODELVIEW);
}
void timer(int){
glutPostRedisplay();
glutTimerFunc(1000/60,timer,0);
}