-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid.cpp
More file actions
71 lines (66 loc) · 1.37 KB
/
grid.cpp
File metadata and controls
71 lines (66 loc) · 1.37 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<string.h>
#include<stdio.h>
#include<iostream>
using namespace std;
int array[6];
void draw_LineGraph()
{
int p=0, space= 60, h=0;
glLineWidth(3.0f);
glBegin(GL_LINE_STRIP);
glColor3f(0.4,0.4,0.8);
while (array[p]!='\0')
{
h= (array[p]*6)+60;
glVertex2f(space, h);
p++;
space=space+60;
}
glEnd();
glFlush();
}
void display()
{
//Drawing grid lines according to the Ortho2D size..
for (int g=0; g< 660; g=g+60)
{
glLineWidth(1.0f);
glBegin(GL_LINES);
glColor3f(0.2,0.2,0.2);
glVertex2f(0, g);// Horizantal lines
glVertex2f(660, g);
glVertex2f(g, 0);// Vertical lines
glVertex2f(g, 660);
glEnd();
glFlush();
}
glLineWidth(1.0f);
glBegin(GL_LINES);// for Drawing base lines
glColor3f(0.8,0.4,0.4);
glVertex2f(0,60);
glVertex2f(660,60);
glVertex2f(60,0);
glVertex2f(60,660);
glEnd();
glFlush();
draw_LineGraph();
}
int main(int argc, char** argv)
{
printf ("Enter Values between 0 to 100");
for ( int i=0; i<6; i++)
{
scanf("%d",&array[i] );
}
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(600, 600);
glutCreateWindow("Grid");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,660,0,660);// + 60 just to have corner lines
glutDisplayFunc(display);
glutMainLoop();
}