Phases of Sun and Moon
Phases of Sun and Moon
Phases of Sun and Moon
On
Submitted By
2020-2021
BASAVARAJESWARI GROUP OF INSTITUTIONS
CERTIFICATE
Sunil Varma} of B.E. VIth Semester Computer Science & Engineering bearing
A beautiful day consists of two important phases which is of Sun and Moon. There are other
important phases such as the Noon and Evening time which are all included under the Day and
This mini project has tried to simulate the two different phases of the day and night including
different objects in the environment which can be normally considered while drawing a
i
ACKNOWLEDGEMENT
The satisfactions that accompany the successful completion of my mini project on “Phases
of Sun and Moon” would be incomplete without the mention of people who made it
possible, whose noble gesture, affection, guidance, encouragement, and support crowned my
efforts with success. It is my privilege to express my gratitude and respect to all those who
inspired me in the completion of my mini project.
I am extremely grateful to our respective Guide Mr. Azhar Baig. for his noble gesture,
support co-ordination and valuable suggestions given to me in completing the mini project.
I also thank Dr. R. N. Kulkarni, H.O.D. Department of CSE, for his co-ordination and
valuable suggestions given to me in completing the mini project. I also thanks Principal,
Management and non-teaching staff for their co-ordination and valuable suggestions given
to me in completing the mini project.
Name USN
ii
TABLE OF CONTENTS
1. Introduction 7
4. Design 11
5. Implementation 12-31
7. Screenshots 35-39
8. Conclusion 40
9. Future Enhancement 41
Bibliography 42
iii
List of Figures
iv
PHASES OF SUN AND MOON
INDEX
1. Introduction 7
4. Design 11
5. Implementation 12-31
7. Screenshots 35-39
8. Conclusion 40
9. Future Enhancement 41
Bibliography 42
List of Figures
CHAPTER 1
INTRODUCTION
The ancient Chinese proverb, “a picture is worth ten thousand words” became a cliché
in our society. Graphics provides one of the most natural way of communication with the
computer, since our highly developed 2D and 3D pattern recognition ability allows us to
perceive and process pictorial data rapidly and efficiently. Interactive computer graphics thus
permits extensive, high bandwidth user computer interaction. This significantly enhances our
ability to understand data, to perceive trends and to visualize real and imaginary objects,
indeed to create a “virtual world” that we can explore from arbitrary points and views. It
makes communication more efficient, graphics makes possible higher quality and more
precise results or products, greater productivity, and lower analysis and design cost.
graphics applications. Since its introduction in 1992, OpenGL has become the industry’s
most widely used and supported 2D and 3D graphics application programming interface
rendering, texture mapping, special effects, and other powerful visualization functions.
Developers can leverage the power of OpenGL across all popular desktop and workstation
CHAPTER 2
LITERATURE SURVEY
2.1 EARLY GRAPHICS SYSTEM
Computer graphics started with pen plotter model. We had Cathode Ray Tube Display
showing the graphics. Each line drawn was a result of intense calculation which was a huge
2.2 OPENGL
applications that produce 2D and 3D graphics. It contains multiple different function calls
that help develop complex graphics with help of simple primitives. Developed by Silicon
Graphics Inc. in 1992. Now its managed by the nonprofit technology consortium, the
Khronos Group.
OpenGL has a set of library that help in various functions. They are GL, GLU and
GLUT. OpenGL Library or GL provides a powerful yet primitive set of commands. OpenGL
Utility Library or GLU contains several routines that help setting up matrices for specific
viewing orientation, mini projections and surface rendering. OpenGL Utility Toolkit Library
or GLUT contains routines that help in windowing functions and is system independent.
The existing graphics systems were the graphics header in C/C++. These graphics
system are not system independent. Moreover, the underlying hardware knowledge is
important for proper working of the code. Moreover, only 2D graphics were supported.
Complex graphics concepts like camera position, shading, 3D graphics, material properties
were absent.
hardware independence and cross platform support OpenGL became famous. OpenGL is
more streamlined than other graphics system APIs. The concept of building from primitives
made it widely accepted by developers. It even supports animations, function driven events,
callback functions. The transformation functions provide a more powerful ability to graphic
CHAPTER 3
CHAPTER 4
DESIGN
A Normal simple Day is one that everyone craves for. In this problem we get to see
the instance of a day. A day comprising of both the day time and night time along with
different objects present in the environment and the effect of color on them considering day
In this program, we get to see the day time and night time through the options
available in the menu. The initial output window contains the outlines of the different objects
The menu consists of three options which are Quit- to quit the program, night color
change- to change the mode to night mode and day color change- to change the mode to day
mode. Also using the keyboard keys we can show the different positons of the Sun during
day time. Also we can use keyboard operation to see the different phases of the moon during
different nights. The menu is controlled with the help of the Right click whereas the user can
control the movement of both sun and moon through keyboard keys.
CHAPTER 5
5. IMPLEMENTATION
/*void menu(): This function is used to create the menu consisting of different options such
as day color change to switch to day time scenery as well as night color change
to switch to night mode. It also has a quit option in order to close the output
window.*/
/*void border(): This function is used to create the outlines of the objects such as the
mountains and house in the scenery. This outlines are seen when the program
is executed.*/
void border()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINE_STRIP);
glVertex2f(1000,400);
glVertex2f(800,400);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(390,425);
glVertex2f(390,475);
glVertex2f(560,475); //top roof
glVertex2f(560,425);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(560,475); //top roof
glVertex2f(730,650);
glVertex2f(730,600);
glVertex2f(560,425);
glEnd();
glBegin(GL_LINE_STRIP); //top roof
glVertex2f(585,650);
glVertex2f(730,650);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(585,600); //top roof
glVertex2f(685,600);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(425,350); //top window
glVertex2f(425,400);
glVertex2f(510,400);
glVertex2f(510,350);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(425,50); //door
glVertex2f(425,150);
glVertex2f(525,150);
glVertex2f(525,50);
glEnd();
tree1();
glFlush();
glutSwapBuffers();
/*void tree1(): This function is used to create a tree outline with white color and is seen on
the starting output screen.*/
void tree1()
{
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINE_LOOP);
glVertex2f(100,250);
glVertex2f(175,250);
glVertex2f(175,75);
glVertex2f(100,75);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(100,250);
glVertex2f(0,250);
glVertex2f(75,350);
glVertex2f(25,350);
glVertex2f(100,425);
glVertex2f(50,425);
glVertex2f(140,500);
glVertex2f(225,425);
glVertex2f(175,425);
glVertex2f(250,350);
glVertex2f(200,350);
glVertex2f(275,250);
glVertex2f(175,250);
glEnd();
}
/*void tree2(): This function is used to show the tree in the scenery with colors in both day
and night mode.*/
void tree2()
{
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(100,250);
glVertex2f(175,250);
glVertex2f(175,75);
glVertex2f(100,75);
glEnd();
glColor3f(0.0,0.3,0.01);
glBegin(GL_POLYGON);
glVertex2f(100,250);
glVertex2f(0,250);
glVertex2f(75,350);
glVertex2f(25,350);
glVertex2f(100,425);
glVertex2f(50,425);
glVertex2f(140,500);
glVertex2f(225,425);
glVertex2f(175,425);
glVertex2f(250,350);
glVertex2f(200,350);
glVertex2f(275,250);
glVertex2f(175,250);
glEnd();
}
/*void circle1(): This function is used to create the Sun in the day mode as well as the Moon
in the night mode and also in portraying stars in the night sky. By using
different values as the argument we can create circles of different radius.*/
/*void dayColorChange(): This function is used to show the day time. When the option day
color change is clicked, this function gets executed. This function
shows the color of the objects during day time including Sun and
clouds.*/
void dayColorChange()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
/*sky*/
glColor3f(0.4,0.7,1.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,1000);
glVertex2f(0,1000);
glEnd();
/*ground*/
glColor3f(0.0,0.6,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,0);
glVertex2f(0,0);
glEnd();
/*hills*/
glColor3f(0.3,0.1,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(250,700);
glVertex2f(500,400);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(500,400);
glVertex2f(750,700);
glVertex2f(1000,400);
glEnd();
/*1floor roof*/
glColor3f(0.5,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(400,300);
glVertex2f(325,225);
glVertex2f(625,225);
glVertex2f(550,300);
glEnd();
/*roof*/
glColor3f(0.4,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(390,475);
glVertex2f(585,650);
glVertex2f(585,600);
glVertex2f(450,475);
glEnd();
/*top of roof*/
glColor3f(0.4,0.4,0.4);
glBegin(GL_POLYGON);
glVertex2f(450,475);
glVertex2f(585,600);
glVertex2f(690,600);
glVertex2f(560,475);
glEnd();
glVertex2f(560,475);
glVertex2f(730,650);
glVertex2f(730,600);
glVertex2f(560,425);
glEnd();
glColor3f(0.4,0.0,0.0);
glBegin(GL_POLYGON); //top roof
glVertex2f(585,650);
glVertex2f(730,650);
glEnd();
glColor3f(0.4,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(585,600); //top roof
glVertex2f(685,600);
glEnd();
/*window*/
glBegin(GL_POLYGON);
glVertex2f(425,350);
glVertex2f(425,400);
glVertex2f(510,400);
glVertex2f(510,350);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(425,50); //door
glVertex2f(425,150);
glVertex2f(525,150);
glVertex2f(525,50);
glEnd();
tree2();
glColor3f(0.5,0.5,0.5);
circle1(850.0,800.0,20.0);
circle1(875.0,790.0,30.0);
circle1(910.0,793.0,40.0);
circle1(950.0,790.0,30.0);
glColor3f(1.0,1.0,0.0);
/*void nightColorChange(): This function is used to change the mode to night when the
option night color change is clicked. It shows the color of the
objects during night and also some other detailing regarding
night. */
void nightColorChange()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,1000);
glVertex2f(0,1000);
glEnd(); //blue background
glColor3f(0.0,0.4,0.0);
glBegin(GL_POLYGON); //ground color
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,0);
glVertex2f(0,0);
glEnd();
glColor3f(1.0,1.0,1.0);
circle1(50.0,700.0,2.0);
circle1(150.0,750.0,1.0);
circle1(550.0,800.0,1.0);
circle1(600.0,750.0,1.0);
circle1(450.0,600.0,1.0);
circle1(400.0,850.0,2.0); //extra
circle1(350.0,850.0,1.0);
circle1(55.0,850.0,2.0);
circle1(65.0,900.0,2.0);
circle1(400.0,650.0,1.0);
circle1(200.0,800.0,2.0);
glColor3f(0.2,0.1,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400); //mountain
glVertex2f(250,700);
glVertex2f(500,400);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(500,400);
glVertex2f(750,700);
glVertex2f(1000,400);
glEnd();
glColor3f(0.8,0.8,0.4);
glBegin(GL_POLYGON);
glVertex2f(350,225); //front wall
glVertex2f(350,50);
glVertex2f(600,50);
glVertex2f(600,225);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON); //front roof
glVertex2f(400,300);
glVertex2f(325,225);
glVertex2f(625,225);
glVertex2f(550,300);
glEnd();
glColor3f(0.8,0.8,0.4);
glBegin(GL_POLYGON);
glVertex2f(400,300);
glVertex2f(550,300);
glVertex2f(550,425); //top wall
glVertex2f(400,425);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(390,475); //roof
glVertex2f(585,650);
glVertex2f(585,600);
glVertex2f(450,475);
glEnd();
glColor3f(0.2,0.3,0.3); //top of roof
glBegin(GL_POLYGON);
glVertex2f(450,475);
glVertex2f(585,600);
glVertex2f(690,600);
glVertex2f(560,475);
glEnd();
glColor3f(0.7,0.7,0.32);
glBegin(GL_POLYGON);
glVertex2f(550,425);
glVertex2f(550,300);
glVertex2f(725,475); //top side wall
glVertex2f(725,600);
glEnd();
glColor3f(0.7,0.7,0.32);
glBegin(GL_POLYGON);
glVertex2f(600,225); //side wall
glVertex2f(600,50);
glVertex2f(800,250);
glVertex2f(800,420);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(550,300); //side roof
glVertex2f(725,475);
glVertex2f(810,420);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON); //part of side roof
glVertex2f(600,223);
glVertex2f(550,300);
glVertex2f(810,420);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(585,650);
glVertex2f(585,600);
glVertex2f(700,600);
glVertex2f(730,650);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(390,425);
glVertex2f(390,475);
glVertex2f(560,475); //top roof
glVertex2f(560,425);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(560,475); //top roof
glVertex2f(730,650);
glVertex2f(730,600);
glVertex2f(560,425);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON); //top roof
glVertex2f(585,650);
glVertex2f(730,650);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(585,600); //top roof
glVertex2f(685,600);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(425,350); //top window
glVertex2f(425,400);
glVertex2f(510,400);
glVertex2f(510,350);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(425,50); //door
glVertex2f(425,150);
glVertex2f(525,150);
glVertex2f(525,50);
glEnd();
tree2();
}
/*void movesun(): This function is used to change the position of the sun thus portraying a
day time mode where sun rises from one side and sets on the other
side.*/
void movesun()
{
//glColor3f(1.0,1.0,0.0);
//circle1(120.0,700.0,30.0);
if(p<500.0)
{
p=p+20;
q=q+10;
circle1(p,q,30.0);
glFlush();
glutSwapBuffers();
}
else if(p<900)
{
p=p+20;
q=q-0.2;
circle1(p,q,30.0);
glFlush();
glutSwapBuffers();
}
else if(p>800.0||q>900)
{
p=120.0;
q=700.0;
circle1(p,q,30.0);
glFlush();
glutSwapBuffers();
/*void color(): This function is used to provide the color to the day time mode. It comes in
handy when the screen is switched from one mode to another. It is used
inside other function in order to provide an error free look to the daytime.*/
void color()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
/*sky*/
glColor3f(0.4,0.7,1.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,1000);
glVertex2f(0,1000);
glEnd();
/*ground*/
glColor3f(0.0,0.6,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,0);
glVertex2f(0,0);
glEnd();
/*hills*/
glColor3f(0.3,0.1,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(250,700);
glVertex2f(500,400);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(500,400);
glVertex2f(750,700);
glVertex2f(1000,400);
glEnd();
/*1floor roof*/
glColor3f(0.5,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(400,300);
glVertex2f(325,225);
glVertex2f(625,225);
glVertex2f(550,300);
glEnd();
/*roof*/
glColor3f(0.4,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(390,475);
glVertex2f(585,650);
glVertex2f(585,600);
glVertex2f(450,475);
glEnd();
/*top of roof*/
glColor3f(0.6,0.5,0.6);
glBegin(GL_POLYGON);
glVertex2f(450,475);
glVertex2f(585,600);
glVertex2f(690,600);
glVertex2f(560,475);
glEnd();
glVertex2f(390,475);
glVertex2f(560,475);
glVertex2f(560,425);
glEnd()
/*top roof*/;
glColor3f(0.4,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(560,475);
glVertex2f(730,650);
glVertex2f(730,600);
glVertex2f(560,425);
glEnd();
glColor3f(0.4,0.0,0.0);
glBegin(GL_POLYGON); //top roof
glVertex2f(585,650);
glVertex2f(730,650);
glEnd();
glColor3f(0.4,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(585,600); //top roof
glVertex2f(685,600);
glEnd();
/*window*/
glBegin(GL_POLYGON);
glVertex2f(425,350);
glVertex2f(425,400);
glVertex2f(510,400);
glVertex2f(510,350);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(425,50); //door
glVertex2f(425,150);
glVertex2f(525,150);
glVertex2f(525,50);
glEnd();
tree2();
glColor3f(1.0,1.0,0.0);
glColor3f(0.5,0.5,0.5);
glColor3f(1.0,1.0,0.0);
void modifynight(): This function is used to change the phases of the moon. This function is
called when a certain keyboard key is pressed.
void modifynight()
{
glColor3f(1.0,1.0,1.0);
circle1(a,b,30.0);
glColor3f(0.0,0.0,0.0);
circle1(d,e,f);
//glTranslated(80.0,90.0,0.0);
e=e+10.0;
d=d-10.0;
if(d<700||e>900)
{
f=f+15.0;
d=820.0;
e=900.0;//d=800;
//e=850.0;
if(f>85.0)
{
f=30.0;
d=800.0;
e=850.0;
}
}
glFlush();
glutSwapBuffers();
void nightmode(): This function is same as the nightColorChange() difference being the
change in the color of the house. The color of the house changes with
all the objects in the background being the same.
void nightmode()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,1000);
glVertex2f(0,1000);
glEnd(); //blue backround
glColor3f(0.0,0.4,0.0);
glBegin(GL_POLYGON); //ground color
glVertex2f(0,400);
glVertex2f(1000,400);
glVertex2f(1000,0);
glVertex2f(0,0);
glEnd();
glColor3f(1.0,1.0,1.0);
circle1(50.0,700.0,2.0); //stars
circle1(150.0,750.0,1.0);
circle1(550.0,800.0,1.0);
circle1(600.0,750.0,1.0);
circle1(450.0,600.0,1.0);
circle1(400.0,850.0,2.0);
circle1(350.0,850.0,1.0);
circle1(55.0,850.0,2.0);
circle1(65.0,900.0,2.0);
circle1(400.0,650.0,1.0);
circle1(200.0,800.0,2.0);
glColor3f(0.2,0.1,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,400); //mountain
glVertex2f(250,700);
glVertex2f(500,400);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(500,400);
glVertex2f(750,700);
glVertex2f(1000,400);
glEnd();
glColor3f(0.7,0.6,0.6);
glBegin(GL_POLYGON);
glVertex2f(350,225); //front wall
glVertex2f(350,50);
glVertex2f(600,50);
glVertex2f(600,225);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON); //front roof
glVertex2f(400,300);
glVertex2f(325,225);
glVertex2f(625,225);
glVertex2f(550,300);
glEnd();
glColor3f(0.7,0.6,0.6);
glBegin(GL_POLYGON);
glVertex2f(400,300);
glVertex2f(550,300);
glVertex2f(550,425); //top wall
glVertex2f(400,425);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(390,475); //roof
glVertex2f(585,650);
glVertex2f(585,600);
glVertex2f(450,475);
glEnd();
glColor3f(0.2,0.3,0.3); //top of roof
glBegin(GL_POLYGON);
glVertex2f(450,475);
glVertex2f(585,600);
glVertex2f(690,600);
glVertex2f(560,475);
glEnd();
glColor3f(0.7,0.5,0.5);
glBegin(GL_POLYGON);
glVertex2f(550,425);
glVertex2f(550,300);
glVertex2f(725,475); //top side wall
glVertex2f(725,600);
glEnd();
glColor3f(0.7,0.5,0.5);
glBegin(GL_POLYGON);
glVertex2f(600,225); //side wall
glVertex2f(600,50);
glVertex2f(800,250);
glVertex2f(800,420);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(550,300); //side roof
glVertex2f(725,475);
glVertex2f(810,420);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON); //part of side roof
glVertex2f(600,223);
glVertex2f(550,300);
glVertex2f(810,420);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(585,650);
glVertex2f(585,600);
glVertex2f(700,600);
glVertex2f(730,650);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(390,425);
glVertex2f(390,475);
glVertex2f(560,475); //top roof
glVertex2f(560,425);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(560,475); //top roof
glVertex2f(730,650);
glVertex2f(730,600);
glVertex2f(560,425);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON); //top roof
glVertex2f(585,650);
glVertex2f(730,650);
glEnd();
glColor3f(0.3,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(585,600); //top roof
glVertex2f(685,600);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(425,350); //top window
glVertex2f(425,400);
glVertex2f(510,400);
glVertex2f(510,350);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(425,50); //door
glVertex2f(425,150);
glVertex2f(525,150);
glVertex2f(525,50);
glEnd();
tree2();
}
void keys(): This is used to change the mode to night mode or to day mode depending on the
user requirement.
nightColorChange();
modifynight();
}
else if(key=='s')
{
color();
movesun();
}
else if(key=='S')
{
dayColorChange();
movesun();
}
}
CHAPTER 6
IMPORTANT FUNCTIONS
glutKeyboardFunc( ) : Used for calling the functions which are assigned for
Keyboard operation.
void movesun( ) : This function is used to show the movement of the sun at
day time. It ends when the sun has reached the other end of
the window while using the keyboard in order to move the
sun.
void tree1( ) : This function is used to see the tree when the output screen
is opened. It only consists of the outline of the tree.
void tree2( ) : This function is used so that we can see the tree in the day
time mode.
void nightmode( ) : This function is used to depict the night time of the
program.
void dayColorChange( ) : This function is used to depict the day time of the
program.
void modifynight( ) : In order to show the different phases of the moon. This
function can be accessed through keyboard keys.
CHAPTER 7
7. SCREENSHOTS
Figure 4.2 shows the Initial Output Window along with the menu when we Right
Click on the Screen. Figure 4.3 shows the different options available in the menu which are
Quit, Night color change and Day color change. The options available can be used to view
the different instances of a normal day.
Figure 4.4 shows the initial output screen when the day color change option is
selected from the menu. It shows the colors of the various objects with respect to day time
perspective. Also there are two added objects , Sun and Cloud, which were not present in the
initial black and white output screen.
In order to show the different positions of the Sun throughout a Day, we use ‘S’
button or Shift + S. However this movement is in the presence of cloud. Figure 4.5 shows a
particular instance of the day near to Noon.
Figure 4.6 shows the range till which the sun can travel in the Window. The Sun rose
from the Left Hand side of the window and sets at the other side of the window. Thus here it
is depicting near Evening time.
Figure 4.6 shows the initial output screen of Night Time with the stars and the Moon.
It appears when the night color change option is selected from the Menu.
Figure 4.8 to 4.10 shows different phases of the Moon on different Nights. The
phases of the Moon can be generated using Shift + M or by just pressing M key on the
keyboard. Using ‘m’ will change the color of the house. Rest all the function is same as that
of ‘M’.
CHAPTER 8
CONCLUSION
The mini mini project designed here provides the complete view of a normal day and
night scene. Here we have designed a house, mountains, trees, the sun, the moon and the
stars. We have implemented different functions in order to show the different instances of the
Sun’s position during daytime as well as the phases of the Moon in different nights. In all the
mini mini project provides a good view of the different instances of day time and night time.
This mini project helps me in learning how to use simple codes to build simple
graphic content. These simple graphic contents can help render a complex set of graphical
objects easily. It also helps me understand the mechanics of OpenGL programming, handling
CHAPTER 9
FUTURE ENHANCEMENTS
The mini mini project designed can be implemented in the future with more effects in
lighting as well as functions. The Scene can be viewed in a 3D display. Further we can
implement more user interaction as well as more functions which works according to System
timing. The mini mini project can be implemented with the actual timing of the surrounding
It can be also implemented as a Wallpaper which changes color to inform the user
about the time without looking for an actual clock. This mini project can also be implemented
with the change of surroundings with every 4 seasons i.e. Spring, Summer, Rainy and Winter
i.e. introduction of snow, rain etc. Thus in future this mini project has more scope in order to
BIBLIOGRAPHY
1. Books:
[1] Edward Angel, 2009, Interactive computer graphics A top-down approach with OpenGL,
[2] Donald Hearn and Pauline Baker : Computer Graphics – OpenGL version, 3rd edition,
[4] F.S. Hill Jr.: Computer Graphics using OpenGL, 3rd edition, PHI, 2009
2. Websites :
[1] www.opengl.org/resources/
[2] http://pyopengl.sourceforge.net/documentation/manual-3.0/
[3] www.stackoverflow.com/search?q=opengl