CG Final
CG Final
“TRAIN STATION”
Submitted in Partial fulfilment of the Requirements for the VI Semester of the Degree of
Bachelor of Engineering
In
Computer Science & Engineering
By
JUDAH A (1CE20CS038)
SUBRAMANI M (1CE20CS073)
CERTIFICATE
Certified that the Computer Graphics Project work entitled “TRAIN STATION” has been
carried out by JUDAH A (1CE20CS038), SUBRAMANI M(1CE20CS073) Bonafede
students of City Engineering College in partial fulfilment for the award of Bachelor of
Engineering in Computer Science and Engineering of the Visveswaraya Technological
University, Belgaum during the year 2022-2023. It is certified that all corrections/suggestions
indicated for Internal Assessment have been incorporated in the Report deposited in the
departmental library. The CG Mini Project Report has been approved as it satisfies the
academic requirements in respect of project work prescribed for the said Degree.
External Viva
Name of the examiners Signature with date
1.
2.
ABSTRACT
Train Station is a newly designed computer graphics mini project. In this mini project, there
will be objects like trains, signals, and a place called “railway station”. There will be a train
in which it will start arriving at the railway station when the signal light “green” is turned on.
It will stop at the railway station when the red light is turned on and the train will not move
from the railway station till the user displays the green light in the traffic signal when the
green light is turned on then the train will start to depart from the railway station. In this
project, there will be night mode and day mode. This is an overview of the project.The train
arrival and departure is a brand new computer graphics mini project developed using the
OpenGL language. The project is a bit difficult to implement since there are lots of objects in
this project a train, railway station, signal light these are the main objects and some more in
the project
i
ACKNOWLEDGEMENT
The completion of the Project brings a sense of satisfaction, but it is never completed without
thanking the persons who are all responsible for its successful completion. First and foremost,
we wish to express our deep sincere feelings of gratitude to our Institution,City Engineering
College, for providing us an opportunity to do our education.
We extend our deepest sense of sincere gratitude to Dr. Thippeswamy H.N, Principal, City
Engineering College, Bengaluru, for having permitted us to carry out the project work on
TRAIN STATION.
We express our heartfelt sincere gratitude to Dr. Sowmya Naik, Professor and Head,
Department of Computer Science and Engineering, City Engineering College, Bengaluru, for
her valuable suggestions and support.
We express my special in-depth, heartfelt, sincere gratitude to Prof. Swetha A, Asst. Prof,
Dept., of CS&E, City Engineering College, Bengaluru for their constant support in
completing the project.
Finally, we would like to thank all the Teaching, Technical faculty and supporting staff
members of Department of Computer Science and Engineering, City Engineering College,
Bengaluru, for their support.
JUDAH A(1CE20CS038)
SUBRAMANI M (1CE20CS073)
ii
TABLE OF CONTENTS
1.Introduction…………………………………………………………………………………01
1.1 About Computer Graphics……………………..…………………………………01
1.2 History of Computer Graphics………………….……………….……………….02
1.3 About OpenGL…………..……………………..………………….…..…………03
1.4 Applications of Computer Graphics…………...…………………….…….……..05
1.5 Built-In Functions……...…………….……………………..…….…...….......….06
1.6 Mouse Functions……………..……….…………..…………..…….…..…..……08
2.Literature Survey……………………………….………………...…..……………..….…..09
3.System Requirement Specification……….……………………….…….….…...………….11
3.1 Hardware Requirements.……………………………….………….....…………..11
3.2 Software Requirements……………………….……………………….………….11
4. System Analysis And Design…..…………………………………………………….……12
4.1 System Analysis….………………..………………………………..…………….12
4.2 System Design.……….………………………………..………………………….12
5.Implementation…………..……………………..…………………………..………………13
5.1 Description of Implementation Modules…………………………..……………..13
5.2 List of Implementation Functions…………...……………………………………13
5.3 Description of inbuilt functions…………..……………….……………..……….14
6.Snapshots…………………….…………………………………………..…………………15
Appendix…………………………………………………………………..………………….19
Conclusion…………………………...………………………….……………………………25
Future scope………….……...……………………………….……………………………….25
References…………………….………………………………..……………………………..26
iii
LIST OF FIGURES
iv
CHAPTER 1
INTRODUCTION
1.1 About Computer Graphics
The term computer graphics has been used in a broad sense to describe almost everything on
computers that is not text or sound. Typically, the term computer graphics refers to several
different things:
• The representation and manipulation of image data by a computer
• The various technologies used to create and manipulate images
• The sub-field of Computer Science which studies methods for digitally synthesising and
manipulating visual content.
Today, computer graphics are widespread. Such imagery is found in and on television,
newspapers, weather reports, and in a variety of medical investigations and surgical
procedures. A well-constructed graph can present complex statistics in a form that is easier to
understand and interpret. In the media such graphs are used to illustrate papers, reports and
other presentation material. Graphics provides one of the most natural means of
communicating with a computer, since our highly developed 2D and 3D pattern-recognition
abilities allow us to perceive and process pictorial data rapidly and efficiently. Interactive
computer graphics is the most important means of producing pictures since the invention of
photography and television. It has the added advantage that, with the computer, we can make
pictures not only of concrete real-world objects but also of abstract, synthetic objects, such as
mathematical surfaces and of data that have no inherent geometry, such as survey results.
Using this editor, you can draw and paint using the mouse. It can also perform a host of other
functions like drawing lines, circles, and polygons and so on. Interactive picture construction
techniques such as basic positioning methods, rubber-band methods, dragging and drawing
are used. Block operations like cut, copy and paste are supported to edit large areas of the
workspace simultaneously. It is user friendly and intuitive to use.
Graphics provides one of the most natural means of communicating with a computer, since
our highly developed 2D Or 3D pattern-recognition abilities allow us to perceive and process
pictorial data rapidly. Computers have become a powerful medium for the rapid and
• Graphics pipeline: Each object comprises a set of graphical primitives. Each primitive
comprises a set of vertices.
• Vertex processing: The assignment of vertex colour scan is as simple as program specifying
a colour or as complex as computation of a colour from a physically realistic lightning model
that incorporates the surface properties of the object and the characteristic light sources in the
scene.
• Clipping and primitive assembly: We must do clipping because of the limitations of that
no imaging system can see the whole world at once. The human retina has a limited size
corresponding to an approximately 90-degree field of view.
OpenGL Available Everywhere: Supported on all UNIX® workstations, and shipped standard
with every Windows 95/98/2000/NT and Mac OS PC, no other graphics API operates on a
wider range of hardware platforms and software environments. OpenGL runs on every major
operating system including Mac OS, OS/2, UNIX, Windows 95/98, Windows 2000, Windows
NT, Linux, Open Step, and BeOS; it also works with every major windowing system,
including Win32, Mac OS, Presentation Manager, and X-Window System. OpenGL is
callable from Ada, C, C++, FORTRAN, Python, Perl and Java and offers complete
independence from network protocols and topologies. The OpenGL interface: Our application
will be designed to access OpenGL directly through functions in three libraries namely-
❖ GL
❖ GLU
❖ Glut
(2) gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top):-
Which defines a two-dimensional viewing rectangle in the plane z=0.
(17) glutMainLoop() :-
Cause the program to enter an event-processing loop. It should be the last statement in the
main function.
1.6 Mouse Functions
Right button: controls the below options.
➢ Airplane option: makes a plane fly actress the sky.
➢ Comet option: makes a comet fly across the sky.
➢ Computer graphics started with the display of data on hardcopy plotters and cathode ray
tube (CRT) screens soon after the introduction of computers.
➢ Computer graphics today largely interactive, the user controls the contents, structure, and
appearance of objects and of displayed images by using input devices, such as keyboard
mouse, or touch-sensitive panel on the screen. Graphics based user interfaces allow millions
of new users to control simple, low- cost application programs, such as spreadsheets, word
processors, and drawing programs.
➢ OpenGL (Open Graphics Library) is a standard specification defining a cross-language,
cross platform API for writing applications that produce 2D and 3D computer graphics. The
interface consists of over 250 different function calls which can be used to draw complex
three-dimensional scenes from simple primitives. OpenGL was developed by Silicon
Graphics Inc. (SGI) in 1992 and is widely used in CAD, virtual reality, scientific
visualisation, information visualisation, and flight simulation. It is also used in video games,
where it competes with Direct3D on Microsoft Windows platforms (see Direct3D vs.
OpenGL). OpenGL is managed by the non-profit technology consortium, the Khronos Group.
➢ In the 1980s, developing software that could function with a wide range of graphics
hardware was a real challenge. By the early 1990s, Silicon Graphics (SGI) was a leader in 3D
graphics for workstations. SGI's competitors (including Sun Microsystems, Hewlett- Packard
and IBM) were also able. In addition, SGI had a large number of software customers; by
changing to the OpenGL API they planned to keep their customers locked onto SGI (and
IBM) hardware for a few years while market support for OpenGL matured to bring to market
3D hardware, supported by extensions made to the PHIGS standard. In 1992, SGI led the
creation of the OpenGL architectural review board (OpenGL ARB), the group of companies
that would maintain.
➢ OpenGL specification took for years to come. On 17 December 1997, Microsoft and SGI
initiated the Fahrenheit project, which was a joint effort with the goal of unifying the OpenGL
and Direct3D interfaces(and adding a scene-graph API too). In 1998 Hewlett- Packard joined
the project. It initially showed some promise of bringing order to the world of interactive 3D
computer graphics APIs, but on account of financial constraints at SGI, strategic reasons at
Microsoft, and general lack of industry support, it was abandoned in 1999.
In this project a thirsty crow is created using “OpenGL” functional API by the help of built in
functions present in the Opengl lib. These functions provide us with an efficient way to design
the project. In this chapter we are describing the functionality of our project using these
functions, such as Opengl translation and other geometric transformations.
glutInit():
Initialises GLUT. The arguments from main are passed in and can be used by the application.
glutInitWindowSize():
glutCreateWindow():
Creates the window on the display. The string can be used to label the window.
glutDisplayFunc():
Registers the display function that is executed when the window needs to redraw.
glutMainLoop():
myinit():
Fig 6.6 Shows a comet flying after selection from the menu
Fig 6.8 Shows the menu after right mouse button is clicked
case 2:
if(index==2)
{
comet=1; c=0.0;
}
break;
}
}
void mouse(int btn,int state,int x,int y)
{
if(btn==GLUT_LEFT_BUTTON && state==GLUT_UP)exit(0);
}
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(1100.0,700.0);
glutInitWindowPosition(0,0);
glutCreateWindow("Traffic Control");
glutDisplayFunc(display);
Dept., of CSE, CEC 2022-23 23
glutIdleFunc(idle);
glutKeyboardFunc(keyboardFunc);
glutMouseFunc(mouse);
myinit();
c_menu=glutCreateMenu(main_menu);
glutAddMenuEntry("Aeroplane",1);
glutAddMenuEntry("Comet",2);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMainLoop();
return 0;
}
Conclusion:
OpenGL software was used to develop the “INTERACTION BETWEEN LAYERS OF OSI
MODEL” project which provided various commands to specify objects and operations in
two-dimensional space. The very purpose of developing this project is to exploit the strength
of OpenGL graphic capabilities and to illustrate the character movement.
This project helped me learn a lot about the proper utilisation of various graphics library
functions that are defined in GLUT, GLU and GL. The package can be used for educational
purposes to demonstrate the various curves, area filling algorithm, non-convex polygon and
other OpenGL Primitives.
In this project, there are two modes in it namely day mode and night mode. To make it day
mode and night mode and to display the signal light to train the controls will be provided
from the keyboard and mouse.
When the train approaches the station then the red signal will be displayed then the train will
stop at the railway station and then after displaying the green light, the train will depart from
the station.
Future scope:
The following features were thought of and will be implemented to enhance the project.
1. https://timetoprogram.com/train-arrival-departure-cg-mini-project
4. The Official Guide to Learning OpenGL, by Jackie Neider, Tom Davis, Mason Woo
(THE REDBOOK)
We students of 6th semester BE, Computer Science and Engineering College hereby declare
that project work entitled “Train Station” has been carried out by us at City Engineering
College, Bengaluru and submitted in partial fulfillment of the course requirement for the
award of the degree of Bachelor of Engineering in Computer Science and Engineering of
Visvesvaraya Technological University, Belgaum, during the academic year 2022-2023.
We also declare that, to the best of our knowledge and belief, the work reported here does not
form the part of dissertation on the basis of which a degree or award was conferred on an
earlier occasion on this by any other student.
Date:
Place: Bangalore
JUDAH A SUBRAMANI M
(1CE20CS038) (1CE20CS073)