Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<windows.h>
- #include<mmsystem.h>
- #include<GL\glut.h>
- #include <GL/glu.h>
- #include<math.h>
- #include <stdlib.h>
- #include<stdio.h>
- #define PI 3.1416
- GLint i, j, k,x=0,y=0,speed=0,alt=0,n1=1000,n2=1100,s1=0,s2=1,s3=1;
- GLfloat sun_spin=0, sun_x=0, sun_y=0,reduce=10;
- GLfloat ax=0,bx=0,cx=0,dx=0,str=500.0,mn=500.0;
- GLfloat sr=0.0,sg=0.749,sb=1.0;
- GLfloat spin = 0.0;
- bool condition=false;
- GLfloat position = 0.0f;
- GLfloat _move =5.0f;
- GLfloat position1 = 0.0f;
- GLfloat _move1 =3.0f;
- GLfloat position2 = 900.0f;
- GLfloat _move2 =3.0f;
- void init(void)
- {
- glClearColor(.40, .110, 1.0, 0.0);
- glMatrixMode(GL_PROJECTION);
- gluOrtho2D(0.0, 1000.0, 0.0, 700.0);
- }
- float r(int a){
- return x=4,y=8;
- }
- float r(int a,int b){
- return x=0,y=0;
- }
- void updatey(int value) {
- y= 8.0f;
- glutPostRedisplay();
- glutTimerFunc(100, updatey, 0);
- }
- void updatex(int value) {
- x=4.0f;
- glutPostRedisplay();
- glutTimerFunc(100, updatex, 0);
- }
- ///============================================================================================================///
- ///=================///
- ///*** All_Model ***///
- ///=================///
- /*void sound()
- {
- PlaySound(TEXT("fire.wav"), NULL, SND_ASYNC|SND_FILENAME);
- }*/
- ///*** Circle_Model***///
- void circle(GLdouble rad)
- {
- glBegin(GL_POLYGON);
- {
- for(int i=0;i<50;i++)
- {
- float pi=3.1416;
- float A=(i*2*pi)/50;
- float r=rad;
- float x = r * cos(A);
- float y = r * sin(A);
- glVertex2f(x,y );
- }
- }
- glEnd();
- }
- void circle1(GLdouble rad)
- {
- glBegin(GL_POLYGON);
- {
- for(int i=0;i<200;i++)
- {
- float pi=3.1416;
- float A=(i*2*pi)/200;
- float r=rad;
- float x = r * cos(A);
- float y = r+10 * sin(A);
- glVertex2f(x,y );
- }
- }
- glEnd();
- }
- /// *** Sun_Model **///
- void Sun_Model(){
- glPushMatrix();
- glTranslatef(600,1100,0);
- circle(33);
- glPopMatrix();
- }
- void update2(int value) {
- //position2 -= 5;
- if(position2 <-1.3)
- {
- position2 -= _move2;
- }
- glutPostRedisplay(); //Notify GLUT that the display has changed
- glutTimerFunc(20, update2, 0); //Notify GLUT to call update again in 25 milliseconds
- }
- ///*** Cloud_Model***///
- void cloud_model_one(){
- glColor3f(1.25, 0.924, 0.930);
- ///Top_Left
- glPushMatrix();
- glTranslatef(320,210,0);
- circle(15);
- glPopMatrix();
- ///Top
- glPushMatrix();
- glTranslatef(340, 225, 0);
- circle(16);
- glPopMatrix();
- ///Right
- glPushMatrix();
- glTranslatef(360,210,0);
- circle(16);
- glPopMatrix();
- ///middle_Fill
- glPushMatrix();
- glTranslatef(355,210,0);
- circle(16);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(350,210,0);
- circle(16);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(345,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(340,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(335,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(330,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(325,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(320,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(315,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(310,204,0);
- circle(10);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(305,204,0);
- circle(10);
- glPopMatrix();
- ///****Fill End****
- }
- void cloud_model_Two(){
- glColor3f(1.25, 0.924, 0.930);
- ///Left_Part
- glPushMatrix();
- glTranslatef(305,205,0);
- circle(10);
- glPopMatrix();
- ///Top
- glPushMatrix();
- glTranslatef(320,210,0);
- circle(15);
- glPopMatrix();
- ///Right_Part
- glPushMatrix();
- glTranslatef(334,207,0);
- circle(10);
- glPopMatrix();
- ///Bottom_Part
- glPushMatrix();
- glTranslatef(320,207,0);
- circle(10);
- glPopMatrix();
- }
- void cloud_model_Three(){
- glColor3f(1.25, 0.924, 0.930);
- ///Left_Part
- glPushMatrix();
- glTranslatef(300,200,0);
- circle(15);
- glPopMatrix();
- ///Top_Left
- glPushMatrix();
- glTranslatef(320,210,0);
- circle(15);
- glPopMatrix();
- ///Top
- glPushMatrix();
- glTranslatef(340,220,0);
- circle(16);
- glPopMatrix();
- ///Top_Right
- glPushMatrix();
- glTranslatef(360,210,0);
- circle(15);
- glPopMatrix();
- ///Right_Part
- glPushMatrix();
- glTranslatef(380,200,0);
- circle(15);
- glPopMatrix();
- ///Bottom_Right
- glPushMatrix();
- glTranslatef(360,190,0);
- circle(20);
- glPopMatrix();
- ///Bottom_Left
- glPushMatrix();
- glTranslatef(320,190,0);
- circle(20);
- glPopMatrix();
- ///Bottom
- glPushMatrix();
- glTranslatef(340,190,0);
- circle(20);
- glPopMatrix();
- ///****Fill End****
- }
- ///*** House_Model ***///
- void house2(){
- glPushMatrix();
- glTranslatef(100, 170,0); //deploy Postition
- glScalef(0.18,0.35,0);
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(0.0f, 128.0f, 128.0f); // Red
- glVertex2f(150.0f, 30.0f); // x, y
- glVertex2f(150.0f, 200.0f); // x, y
- glVertex2f(450.0f, 200.0f);
- glVertex2f(450.0f, 30.0f);
- glEnd();
- glBegin(GL_POLYGON); // Each set of 4 vertices form a quad
- glColor3ub(165.0f, 42.0f, 42.0f); // Red
- glVertex2f(100.0f, 200.0f); // x, y
- glVertex2f(300.0f, 300.0f); // x, y
- glVertex2f(500.0f, 200.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(250.0f, 30.0f); // x, y
- glVertex2f(250.0f, 120.0f); // x, y
- glVertex2f(320.0f, 120.0f);
- glVertex2f(320.0f, 30.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(350.0f, 120.0f); // x, y
- glVertex2f(350.0f, 145.0f); // x, y
- glVertex2f(395.0f, 145.0f);
- glVertex2f(395.0f, 120.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(175.0f, 120.0f); // x, y
- glVertex2f(175.0f, 145.0f); // x, y
- glVertex2f(220.0f, 145.0f);
- glVertex2f(220.0f, 120.0f);
- glEnd();
- glPopMatrix();
- }
- void house1(){
- glPushMatrix();
- glTranslatef(440, 230,0);
- glScalef(0.18,0.35,0);
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(0.0f, 128.0f, 128.0f); // Red
- glVertex2f(150.0f, 30.0f); // x, y
- glVertex2f(150.0f, 200.0f); // x, y
- glVertex2f(450.0f, 200.0f);
- glVertex2f(450.0f, 30.0f);
- glEnd();
- glBegin(GL_POLYGON); // Each set of 4 vertices form a quad
- glColor3ub(165.0f, 42.0f, 42.0f); // Red
- glVertex2f(100.0f, 200.0f); // x, y
- glVertex2f(300.0f, 300.0f); // x, y
- glVertex2f(500.0f, 200.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(250.0f, 30.0f); // x, y
- glVertex2f(250.0f, 120.0f); // x, y
- glVertex2f(320.0f, 120.0f);
- glVertex2f(320.0f, 30.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(350.0f, 120.0f); // x, y
- glVertex2f(350.0f, 145.0f); // x, y
- glVertex2f(395.0f, 145.0f);
- glVertex2f(395.0f, 120.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(175.0f, 120.0f); // x, y
- glVertex2f(175.0f, 145.0f); // x, y
- glVertex2f(220.0f, 145.0f);
- glVertex2f(220.0f, 120.0f);
- glEnd();
- glPopMatrix();
- }
- void house3(){
- glPushMatrix();
- glTranslatef(240, 385,0);
- glScalef(0.18,0.35,0);
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(0.0f, 128.0f, 128.0f); // Red
- glVertex2f(150.0f, 30.0f); // x, y
- glVertex2f(150.0f, 200.0f); // x, y
- glVertex2f(450.0f, 200.0f);
- glVertex2f(450.0f, 30.0f);
- glEnd();
- glBegin(GL_POLYGON); // Each set of 4 vertices form a quad
- glColor3ub(165.0f, 42.0f, 42.0f); // Red
- glVertex2f(100.0f, 200.0f); // x, y
- glVertex2f(300.0f, 300.0f); // x, y
- glVertex2f(500.0f, 200.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(250.0f, 30.0f); // x, y
- glVertex2f(250.0f, 120.0f); // x, y
- glVertex2f(320.0f, 120.0f);
- glVertex2f(320.0f, 30.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(350.0f, 120.0f); // x, y
- glVertex2f(350.0f, 145.0f); // x, y
- glVertex2f(395.0f, 145.0f);
- glVertex2f(395.0f, 120.0f);
- glEnd();
- glBegin(GL_QUADS); // Each set of 4 vertices form a quad
- glColor3ub(128.0f, 0.0f, 0.0f); // Red
- glVertex2f(175.0f, 120.0f); // x, y
- glVertex2f(175.0f, 145.0f); // x, y
- glVertex2f(220.0f, 145.0f);
- glVertex2f(220.0f, 120.0f);
- glEnd();
- glPopMatrix();
- }
- ///*** Field_Model ***///
- void field(){
- ///Field
- glBegin(GL_POLYGON);
- glColor3ub(0, 153, 51);
- glVertex2i(0, 30);
- glVertex2i(0, 440);
- glVertex2i(1000, 440);
- glVertex2i(1000, 420);
- glEnd();
- ///river
- glBegin(GL_POLYGON);
- glColor3ub(0, 143, 179);
- glVertex2i(0,0);
- glVertex2i(0,30);
- glVertex2i(1000,420);
- glVertex2i(1000,0);
- glEnd();
- }
- ///Boat///////////////*****************
- void Boat(){
- glPushMatrix();
- glTranslatef(position,0.0f,0.0f);
- glTranslatef(770,40.0f,0.0f);
- glBegin(GL_POLYGON);
- glColor3f(0.0, 0.0, 0.0);
- glVertex2i(225,75);
- glVertex2i(175, 100);
- glVertex2i(325,100);
- glVertex2i(275,75);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3ub(165.0, 42.0, 42.0);
- glVertex2i(220,100);
- glVertex2i(220, 130);
- glVertex2i(280,130);
- glVertex2i(280,100);
- glEnd();
- glPopMatrix();
- }
- void update(int value) {
- if(position <-700.0)
- _move = -5.0f;
- else if(position >230.0)
- _move = 5.0f;
- position -= _move;
- glutPostRedisplay();
- glutTimerFunc(50, update, 0);
- }
- ///*** Tree_Model ***///
- void Tree_Model(){
- glBegin(GL_POLYGON);
- glVertex2f(110, 153);
- glVertex2f(133, 215);
- glVertex2f(156, 153);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3ub(27, 38, 49);
- glVertex2f(130, 120);
- glVertex2f(130, 154);
- glVertex2f(136, 154);
- glVertex2f(136, 120);
- glEnd();
- }
- void update1(int value) {
- if(position1 <-650.0)
- position1 = 1200.0f;
- position1 -= _move1;
- glutPostRedisplay();
- glutTimerFunc(22, update1, 0);
- }
- void cloud_three(){
- glPushMatrix();
- glColor3ub(46, 204, 13.0);
- glTranslatef(position1,0,0);
- glTranslatef(180,330,0);
- cloud_model_Three();
- glPopMatrix();
- }
- ///*** Cloud_Four_Model_Two ***///
- void cloud_four(){
- glPushMatrix();
- glTranslatef(position1,0,0);
- glTranslatef(300,275,0);
- cloud_model_Two();
- glPopMatrix();
- }
- void star(){
- if ( condition==true)
- {
- glBegin(GL_POINTS); // Each set of 4 vertices form a quad
- glColor3ub(247, 249, 249); // Red
- glVertex2f(500.1f, 500.3f); // x, y
- glVertex2f( 550.1f, 504.0f);
- glVertex2f( 150.1f, 504.0f);
- glVertex2f( 310.1f, 504.0f);
- glVertex2f( 261.0f, 505.0f);
- glVertex2f( 453.1f, 506.0f);
- glVertex2f( 616.1f, 507.0f);
- glVertex2f( 763.1f, 508.0f);
- glVertex2f( 587.1f, 524.0f);
- glVertex2f( 954.1f, 574.0f);
- glVertex2f( 231.1f, 585.0f);
- glVertex2f( 275.1f, 566.0f);
- glVertex2f( 852.1f, 557.0f);
- glVertex2f( 476.1f, 548.0f);
- glVertex2f( 140.1f, 509.0f);
- glVertex2f( 350.1f, 510.0f);
- glVertex2f( 061.1f, 511.0f);
- glVertex2f( 463.1f, 512.0f);
- glVertex2f( 822.1f, 513.0f);
- glVertex2f( 110.1f, 514.0f);
- glVertex2f( 966.1f, 515.0f);
- glVertex2f( 211.1f, 516.0f);
- glVertex2f( 313.1f, 517.0f);
- glVertex2f( 869.1f, 518.0f);
- glVertex2f( 639.1f, 519.0f);
- glVertex2f( 106.1f, 520.0f);
- glVertex2f( 140.1f, 709.0f);
- glVertex2f( 350.1f, 810.0f);
- glVertex2f( 061.1f, 911.0f);
- glVertex2f( 463.1f, 412.0f);
- glVertex2f( 822.1f, 713.0f);
- glVertex2f( 110.1f, 614.0f);
- glVertex2f( 966.1f, 815.0f);
- glVertex2f( 211.1f, 916.0f);
- glVertex2f( 313.1f, 1017.0f);
- glVertex2f( 869.1f, 718.0f);
- glVertex2f( 639.1f, 919.0f);
- glVertex2f( 106.1f, 902.0f);
- glVertex2f( 106.1f, 908.0f);
- glVertex2f( 106.1f, 620.0f);
- glVertex2f( 250.1f, 630.0f);
- glVertex2f( 106.1f, 906.0f);
- glVertex2f( 116.1f, 530.0f);
- glVertex2f( 980.1f, 980.0f);
- glVertex2f( 900.1f, 930.0f);
- glVertex2f( 858.1f, 666.0f);
- glVertex2f( 845.1f, 642.0f);
- glVertex2f( 900.1f, 900.0f);
- glVertex2f( 910.1f, 903.0f);
- glVertex2f( 915.1f, 908.0f);
- glVertex2f( 919.1f, 920.0f);
- glVertex2f( 930.1f, 903.0f);
- glVertex2f( 935.1f, 905.0f);
- glVertex2f( 940.1f, 905.0f);
- glVertex2f( 945.1f, 910.0f);
- glVertex2f( 600.1f, 525.0f);
- glVertex2f( 650.1f, 535.0f);
- glVertex2f( 690.1f, 490.0f);
- glVertex2f( 550.1f, 600.0f);
- glVertex2f( 500.1f, 600.0f);
- glEnd();
- }
- }
- bool con(){
- return condition=true;
- }
- ///*** Tree_10 ***///
- void Tree_Ten(){
- glColor3ub(46, 204, 13.0);
- glPushMatrix();
- glTranslatef(-20,90,0);//-2
- Tree_Model();
- glPopMatrix();
- }
- ///*** Tree_11 ***///
- void Tree_Eleven(){
- glColor3ub(46, 204, 13.0);
- glPushMatrix();
- glTranslatef(125,200,0);
- Tree_Model();
- glPopMatrix();
- }
- ///*** Tree_12 ***///
- void Tree_Twelve(){
- glColor3ub(46, 204, 13.0);
- glPushMatrix();
- glTranslatef(408,178,0);//-22
- Tree_Model();
- glPopMatrix();
- }
- void tree(){
- glColor3f(0.11, 0.23, 0.36);
- glPushMatrix();
- glTranslatef(-120,-110,0);//-90;
- glPopMatrix();
- }
- ///Object_End
- ///=========================================================================================================///
- ///========================///
- ///*** Display Function ***///
- ///========================///
- void display(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0.0, 0.0, 1.0);
- cloud_three();
- cloud_four();
- field();
- Tree_Ten();
- Tree_Eleven();
- Tree_Twelve();
- house2();//This one
- house1();
- house3();
- Boat();
- glFlush();
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowPosition(50, 50);
- glutInitWindowSize(1800, 900);
- glutCreateWindow("CODE_GREEN");
- init();
- glutDisplayFunc(display);
- glutTimerFunc(20, update, 0);
- glutTimerFunc(20, update1, 0);
- glutMainLoop();
- }
Add Comment
Please, Sign In to add comment