-
Notifications
You must be signed in to change notification settings - Fork 0
/
10.c
58 lines (53 loc) · 978 Bytes
/
10.c
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
//RECTANGULAR MESH//
#include <stdlib.h>
#include <GL/glut.h>
int maxx=20;
int maxy =25;
int dx=15;
int dy=10;
int x[20];
int y[25];
int x0=50,y0=50;
int i,j;
void myinit()
{
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0,500,0,500);
}
void mesh()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
for(i=0;i<maxx;i++)
{
x[i] = x0 + i*dx;
}
for(j=0;j<maxy;j++)
{
y[j] = y0 + j*dy;
}
for(i=0;i<maxx-1;i++)
{
for(j=0;j<maxy-1;j++)
{
glColor3f(0.0, 0.0, 1.0);
glBegin(GL_LINE_LOOP);
glVertex2i(x[i],y[j]);
glVertex2i(x[i],y[j+1]);
glVertex2i(x[i+1],y[j+1]);
glVertex2i(x[i+1],y[j]);
glEnd();
glFlush();
}
}
}
void main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitWindowSize(500, 500);
glutInitWindowPosition(0,0);
glutCreateWindow("Rectangular Mesh");
glutDisplayFunc(mesh);
myinit();
glutMainLoop();
}