Uploaded by Sanjay Kumar

code

advertisement
#include<GL/glut.h>
#include<math.h>
GLfloat dy1=10,dx=10,dx2=15,dy2=50,dz,d2;
GLfloat dy13=10,dx3=10,dx23=15,dy23=50,dz3;
GLfloat dy15=10,dx5=10,dx25=15,dy25=50,dz5;
GLfloat cc=0,cc3=0,cc5=0;
GLfloat cc1=.01,cc13=.01,cc15=.01;
#define M_PI 3.14
float ry=0.0,ry3=0.0,ry5=0.0;
int flag2=0,flag23=0,flag25=0;
int flag3,flag4;
void stars(GLfloat x,GLfloat y,GLfloat radius);
void rain(float z)
{
float x,y;
glColor3f(1,1,1);
glBegin(GL_LINES);
for(y=0;y<=700;y+=35)
{
for(x=0;x<=600;x+=20)
{
glVertex3f(-300+x+z,350-y,0);
glVertex3f(-300+x+z,340-y,0);
}
}
glEnd();
glutPostRedisplay();
}
void IDLE()
{
if(cc<1) cc+=.0035;
if(cc1<1) cc1+=.0035;
if(dy1<=185.0)
dy1=dy1+0.4;
dx += 0.08; dx2+= -0.05;
dz+=0.05;
if(ry>=-150)
{
if(ry<=-75)
{
flag2=flag2?1:0;
ry=0;
}
ry-=5;
}
glutPostRedisplay();
}
void IDLE3()
{
if(cc3<1) cc3+=.0035;
if(cc13<1) cc13+=.0035;
if(dy13<=185.0)
dy13=dy13+0.4;
dx3 += 0.08; dx23+= -0.05;
dz3+=0.05;
if(ry3>=-150)
{
if(ry3<=-75)
{
flag23=flag23?1:0;
ry3=0;
}
ry3-=5;
}
glutPostRedisplay();
}
void IDLE2()
{
if(cc5<1) cc5+=.0035;
if(cc15<1) cc15+=.0035;
dx5 += 0.08; dx25+= -0.05;
dz5+=0.05;
if(d2<=185)
d2=d2+0.4;
if(ry5>=-150)
{
if(ry5<=-75)
{
flag25=flag25?1:0;
ry5=0;
}
ry5-=5;
}
glutPostRedisplay();
}
void boat()
{
glColor3f(0.4,0.2,0.2); glBegin(GL_POLYGON);
glVertex3f(-300.0,-150.0,30.0);
glVertex3f(-260.0,-150.0,30.0);
glVertex3f(-270.0,-160.0,30.0);
glVertex3f(-290.0,-160.0,30.0);
glEnd();
glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON);
glVertex3f(-270.0,-150.0,30.0);
glVertex3f(-265.0,-140.0,30.0);
glVertex3f(-270.0,-110.0,30.0);
glEnd();
}
void boat2()
{
glColor3f(0.4,0.2,0.2); glBegin(GL_POLYGON);
glVertex3f(-300.0,-150.0,30.0);
glVertex3f(-260.0,-150.0,30.0);
glVertex3f(-270.0,-160.0,30.0);
glVertex3f(-290.0,-160.0,30.0);
glEnd();
glColor3f(1.0,1.0,1.0); glBegin(GL_POLYGON);
glVertex3f(-270.0,-150.0,30.0);
glVertex3f(-260.0,-150.0,30.0);
glVertex3f(-270.0,-110.0,30.0);
glEnd();
} void birds()
{
glColor3f(0.0,0.0,0.0); glBegin(GL_LINES);
glVertex2f(-200.0,220.0);
glVertex2f(-220.0,200.0);
glVertex2f(-220.0,200.0);
glVertex2f(-240.0,220.0);
glEnd();
glColor3f(0.0,0.0,0.0); glBegin(GL_LINES);
glVertex2f(-280.0,220.0);
glVertex2f(-300.0,200.0);
glVertex2f(-300.0,200.0);
glVertex2f(-320.0,220.0);
glEnd();
glColor3f(0.0,0.0,0.0); glBegin(GL_LINES);
glVertex2f(-240.0,200.0);
glVertex2f(-260.0,180.0);
glVertex2f(-260.0,180.0);
glVertex2f(-280.0,200.0);
glEnd();
glColor3f(1.0,0.0,0.0); glBegin(GL_POINTS);
glVertex2f(-220.0,200.0);
glVertex2f(-300.0,200.0);
glVertex2f(-260.0,180.0);
glEnd();
}
void circ()
{
int i,n=80;
GLfloat delta, dy = 0,theta=0, C[80][3],r = 10;
delta = (2 * M_PI) / n;
for(i=0;i<n;i++)
{
C[i][0] = r * cos(theta);
C[i][1] = r * sin(theta);
C[i][2] = -50;
theta += delta;
}
glBegin(GL_POLYGON);
for(i=0;i<n;i++)
{
glVertex3fv(C[i]);
}
glEnd();
glFlush();
glutPostRedisplay();
}
void circle()
{
int i,n=80;
GLfloat delta, dy = 0,theta=0, C[80][3],r = 10;
delta = (2 * M_PI) / n;
for(i=0;i<n;i++)
{
C[i][0] = r * cos(theta);
C[i][1] = r * sin(theta);
C[i][2] = -50;
theta += delta;
}
glBegin(GL_POLYGON);
for(i=0;i<n;i++)
{
glVertex3fv(C[i]);
}
glEnd();
glFlush();
glutPostRedisplay();
}
void circle2()
{
int i,n=80;
GLfloat delta, dy = 0,theta=0, C[80][3],r = 10;
delta = (2 * M_PI) / n;
for(i=0;i<n;i++)
{
C[i][0] = r * cos(theta);
C[i][1] = r * sin(theta);
C[i][2] = -50;
theta += delta;
}
glBegin(GL_POLYGON);
for(i=0;i<n;i++)
{
glVertex3fv(C[i]);
}
glEnd();
glFlush();
glutPostRedisplay();
}
void cloud()
{
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glTranslatef(80.0,200.0,0.0);
glScalef(1.5,1.0,0.0);
circle();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glTranslatef(100.0,200.0,0.0);
glScalef(2.5,2.0,0.0);
circle();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glTranslatef(110.0,200.0,0.0);
glScalef(2.5,1.5,0.0);
circle();
glPopMatrix();
} void cloud1()
{
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glTranslatef(80.0,200.0,0.0);
glScalef(1.5,1.0,0.0);
circle();
glPopMatrix();
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glTranslatef(100.0,200.0,0.0);
glScalef(2.5,3.0,0.0);
circle();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glTranslatef(110.0,200.0,0.0);
glScalef(2.5,3.0,0.0);
circle();
glPopMatrix();
} void triangle1()
{
glBegin(GL_TRIANGLES);
glColor3f(0.5,0.8,0.0);
glVertex3f(-80.0,0.0,0.0);
glColor3f(0.7,0.5,0.4);
glVertex3f(-40.0,50.0,0.0);
glColor3f(0.4,0.5,0.0);
glVertex3f(0.3,0.2,0.1);
glEnd();
}
void print_text (char *, GLint,GLint);
void day()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPointSize(5.0);
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx+50,10.0,0.0);
birds();
glPopMatrix();
glPushMatrix();
glTranslatef(0,ry,0);
if(flag2)
rain(0);
glPopMatrix();
if(flag2){
glPushMatrix();
glTranslatef(0.0,dy1+20,0.0);
glScalef(1.5,2.5,0.0);
glColor3f(1.0,1.0,1.0);
circ();
glPopMatrix();}
glPushMatrix();
glTranslatef(0.0,dy1+20,0.0);
glScalef(1.5,2.5,0.0);
glColor3f(1.0,0.8,0.0);
circle();
glPopMatrix();
print_text (" ",-300,-190) ;
print_text (" ",-300,-210) ;
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glTranslatef(dx+60,0.0,0.0);
glScalef(1.5,1.0,0.0);
boat2();
glPopMatrix();
glColor3f(0.0,0.0,1.0);
print_text ("<<<<<< PROJECT BY VARSHA AND SUGAMA",-300,-270) ;
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx+50,10.0,0.0);
boat();
glPopMatrix();
glPushMatrix();
glTranslatef(dx+50,50.0,0.0);
if(flag3)
boat();
glPopMatrix();
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx+50,100.0,0.0);
if(flag4)
boat2();
glPopMatrix();
triangle1();
glPushMatrix();
glTranslatef(80.0,0.0,0.0);
glScalef(1.5,1.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(240.0,0.0,0.0);
glScalef(2.5,2.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(340.0,0.0,0.0);
glScalef(1.5,1.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(-50.0,0.0,0.0);
glScalef(2.8,1.5,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(-190.0,0.0,0.0);
glScalef(1.8,1.5,0.0);
triangle1();
glPopMatrix();
cloud();
glPushMatrix();
glTranslatef(-190.0+dx,-250.0,0.0);
glScalef(1.8,1.5,0.0);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(dx,dy1,0.0);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(-dx,dy2,0.0);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(-290.0+dx2,-20.0,0.0);
glScalef(1.2,1.5,0.0);
cloud();
glPopMatrix();
glPopMatrix();
glBegin(GL_POLYGON);
glColor3f(0.50*cc1,0.50*cc1,0.5*cc1);
glVertex3f(-300.0,0.0,-50.0);
glColor3f(0.50*cc1,0.50*cc1,0.4*cc1);
glVertex3f(-300.0,300.0,-50.0);
glColor3f(0.70*cc1,0.50*cc1,0.9*cc1);
glVertex3f(300.0,300.0,-50.0);
glColor3f(1.30*cc,1.50*cc,0.2*cc);
glVertex3f(300.0,0.0,-50.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.5*cc1,0.5*cc1,0.8*cc1);
glVertex3f(-300.0,0.0,-50.0);
glColor3f(0.5*cc1,0.6*cc1,0.8*cc1);
glVertex3f(300.0,0.0,-50.0);
glColor3f(0.6*cc1,0.7*cc1,0.7*cc1);
glVertex3f(300.0,-300.0,-50.0);
glColor3f(0.5*cc,0.6*cc,0.7*cc);
glVertex3f(-300.0,-300.0,-50.0);
glEnd();
glFlush();
glutPostRedisplay();
glutSwapBuffers();
}
void evening()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPointSize(5.0);
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx5+50,10.0,0.0);
birds();
glPopMatrix();
glPushMatrix();
glTranslatef(0,ry5,0);
if(flag2)
rain(0);
glPopMatrix();
if(flag2)
{
glPushMatrix();
glTranslatef(-10.0,200-d2+10,0.0);
glScalef(1.5,2.5,0.0);
glColor3f(1.0,1.0,1.0);
circ();
glPopMatrix();}
glPushMatrix();
glTranslatef(-10.0,200-d2+10,0.0);
glScalef(1.5,2.5,0.0);
glColor3f(3.0,0.4,0.0);
circle2();
glPopMatrix();
print_text (" ",-300,-190) ;
print_text (" ",-300,-210) ;
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glTranslatef(dx5+60,0.0,0.0);
glScalef(1.5,1.0,0.0);
boat2();
glPopMatrix();
glColor3f(0.0,0.0,1.0);
print_text ("<<<<<< PROJECT BY SUGAMA AND VARSHA",-300,-270) ;
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx5+50,10.0,0.0);
boat();
glPopMatrix();
glPushMatrix();
glTranslatef(dx5+50,50.0,0.0);
if(flag3)
boat();
glPopMatrix();
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx5+50,100.0,0.0);
if(flag4)
boat2();
glPopMatrix();
triangle1();
glPushMatrix();
glTranslatef(80.0,0.0,0.0);
glScalef(1.5,1.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(240.0,0.0,0.0);
glScalef(2.5,2.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(340.0,0.0,0.0);
glScalef(1.5,1.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(-50.0,0.0,0.0);
glScalef(2.8,1.5,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(-190.0,0.0,0.0);
glScalef(1.8,1.5,0.0);
triangle1();
glPopMatrix();
cloud();
glPushMatrix();
glTranslatef(-190.0+dx5,-250.0,0.0);
glScalef(1.8,1.5,0.0);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(dx5,dy15,0.0);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(-dx5,dy25,0.0);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(-290.0+dx25,-20.0,0.0);
glScalef(1.2,1.5,0.0);
cloud();
glPopMatrix();
glBegin(GL_POLYGON);
glColor3f(0.80*cc15,0.40*cc15,0.7*cc15);
glVertex3f(-300.0,0.0,-50.0);
glColor3f(0.80*cc15,0.0*cc15,0.0*cc15);
glVertex3f(-300.0,300.0,-50.0);
glColor3f(0.90*cc15,0.20*cc15,0.0*cc15);
glVertex3f(300.0,300.0,-50.0);
glColor3f(1.30*cc5,1.50*cc5,0.0*cc5);
glVertex3f(300.0,0.0,-50.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.8*cc15,0.4*cc15,0.5*cc15);
glVertex3f(-300.0,0.0,-50.0);
glColor3f(0.8*cc15,0.6*cc15,1.0*cc15);
glVertex3f(300.0,0.0,-50.0);
glColor3f(0.8*cc15,0.6*cc15,0.8*cc15);
glVertex3f(300.0,-300.0,-50.0);
glColor3f(0.8*cc5,0.6*cc5,0.8*cc5);
glVertex3f(-300.0,-300.0,-50.0);
glEnd();
glFlush();
glutPostRedisplay();
glutSwapBuffers();
}
void night()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
print_text (" ",-300,-190) ;
print_text (" ",-300,-210) ;
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glTranslatef(dx3+90,0.0,0.0);
glScalef(1.5,1.0,0.0);
boat2();
glPopMatrix();
glColor3f(0.0,0.0,1.0);
print_text ("<<<<<< PROJECT BY SUGAMA AND VARSHA",-300,-270) ;
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx3+50,10.0,0.0);
boat();
glPopMatrix();
glPushMatrix();
glTranslatef(0,ry3,0);
if(flag2)
rain(0);
glPopMatrix();
glPushMatrix();
glTranslatef(dx3+50,50.0,0.0);
if(flag3)
boat();
glPopMatrix();
glPushMatrix();
glRotatef(180.0,0.0,1.0,0.0);
glTranslatef(dx3+50,100.0,0.0);
if(flag4)
boat2();
glPopMatrix();
triangle1();
glPushMatrix();
glTranslatef(80.0,0.0,0.0);
glScalef(1.5,1.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(240.0,0.0,0.0);
glScalef(2.5,2.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(340.0,0.0,0.0);
glScalef(1.5,1.0,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(-50.0,0.0,0.0);
glScalef(2.8,1.5,0.0);
triangle1();
glPopMatrix();
glPushMatrix();
glTranslatef(-190.0,0.0,0.0);
glScalef(1.8,1.5,0.0);
triangle1();
glPopMatrix();
cloud1();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-250.0,180.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-180.0,240.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-150,160.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-115.0,200.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-75.0,100.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-80.0,280.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-50.0,190.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(-10.0,275.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(40.0,140.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(70.0,180.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(120.0,290.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(160.0,210.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(200.0,260.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(250.0,170.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glTranslatef(210.0,120.0,0.0);
glScalef(0.1,0.2,0.2);
circle();
glPopMatrix();
glBegin(GL_POLYGON);
glColor3f(0.0*cc13,0.0*cc13,0.0*cc13);
glVertex3f(-300.0,0.0,-50.0);
glColor3f(0.0*cc13,0.0*cc13,0.0*cc13);
glVertex3f(-300.0,300.0,-50.0);
glColor3f(0.0*cc13,0.0*cc13,0.0*cc13);
glVertex3f(300.0,300.0,-50.0);
glColor3f(0.0*cc3,0.0*cc3,0.0*cc3);
glVertex3f(300.0,0.0,-50.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.1*cc13,0.1*cc13,0.2*cc13);
glVertex3f(-300.0,0.0,-50.0);
glColor3f(0.1*cc13,0.1*cc13,0.2*cc13);
glVertex3f(300.0,0.0,-50.0);
glColor3f(0.1*cc13,0.1*cc13,0.2*cc13);
glVertex3f(300.0,-300.0,-50.0);
glColor3f(0.1*cc3,0.1*cc3,0.2*cc3);
glVertex3f(-300.0,-300.0,-50.0);
glEnd();
glFlush();
glutPostRedisplay();
glutSwapBuffers();
}
void display(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3f(1.0,1.0,1.0);
glRasterPos2i(-225,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'*');
glRasterPos2i(-215,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'*');
glRasterPos2i(-200,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'P');
glRasterPos2i(-180,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'H');
glRasterPos2i(-160,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'A');
glRasterPos2i(-140,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-120,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
glRasterPos2i(-100,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-50,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'O');
glRasterPos2i(-30,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'F');
glRasterPos2i(20,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'T');
glRasterPos2i(40,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'H');
glRasterPos2i(60,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
glRasterPos2i(110,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'D');
glRasterPos2i(130,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'A');
glRasterPos2i(150,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'Y');
glRasterPos2i(165,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'*');
glRasterPos2i(175,100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'*');
glColor3f(1.0,0.0,0.0);
glRasterPos2i(-200,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'P');
glRasterPos2i(-180,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
glRasterPos2i(-160,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
glRasterPos2i(-140,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-120,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-80,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'1');
glRasterPos2i(-40,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'F');
glRasterPos2i(-20,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'O');
glRasterPos2i(0,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
glRasterPos2i(40,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(60,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'U');
glRasterPos2i(80,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'N');
glRasterPos2i(100,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
glRasterPos2i(120,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'I');
glRasterPos2i(140,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(160,0);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
glRasterPos2i(-200,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'P');
glRasterPos2i(-180,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
glRasterPos2i(-160,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
glRasterPos2i(-140,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-120,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-80,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'2');
glRasterPos2i(-40,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'F');
glRasterPos2i(-20,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'O');
glRasterPos2i(0,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
glRasterPos2i(40,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(60,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'U');
glRasterPos2i(80,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'N');
glRasterPos2i(100,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(120,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
glRasterPos2i(140,-100);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'T');
glRasterPos2i(-200,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'P');
glRasterPos2i(-180,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
glRasterPos2i(-160,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
glRasterPos2i(-140,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-120,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
glRasterPos2i(-80,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'3');
glRasterPos2i(-40,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'F');
glRasterPos2i(-20,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'O');
glRasterPos2i(0,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
glRasterPos2i(40,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'N');
glRasterPos2i(60,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'I');
glRasterPos2i(80,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'G');
glRasterPos2i(100,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'H');
glRasterPos2i(120,-200);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'T');
glFlush();
glutPostRedisplay();
glutSwapBuffers();
}
void print_text (char *str, GLint x, GLint y)
{
GLint i;
glRasterPos2d (x,y) ;
for(i=0;str[i]!='\0';i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, str[i]) ;
}
void mykeys(unsigned char key,int x,int y)
{
if(key=='1'){
glutIdleFunc(IDLE);
glutDisplayFunc(day);
}
else if(key=='2')
{
glutIdleFunc(IDLE2);
glutDisplayFunc(evening);
}
else if(key=='3')
{
glutIdleFunc(IDLE3);
glutDisplayFunc(night);
}
else exit(0);
}
void menu(int id)
{
switch(id)
{
case 1:{
flag2=1;
rain(10);
}
break;
case 2:{
flag2=0;
break;
}
break;
case 3:{
flag3=1;
boat();
}
break;
case 4:{
flag4=1;
boat2();
}
break;
default:
exit(0);
}
}
void main(int argc, char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(1000,600);
glutInitWindowPosition(0.0,0.0);
glutCreateWindow("PHASES OF A DAY");
glutDisplayFunc(display);
glutKeyboardFunc(mykeys);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-300.0, 300.0, -300.0, 300.0, -300.0,300.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity ();
glClearColor (1.0, 1.0, 1.0, 1.0);
glutCreateMenu(menu);
glutAddMenuEntry("rainfall",1);
glutAddMenuEntry("stop rainfall",2);
glutAddMenuEntry("Add boat",3);
glutAddMenuEntry("Add ship",4);
glutAddMenuEntry("quit",5);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMainLoop();
}
Download