Report
Report
Chapter 1
                                 INTRODUCTION
1.2 OpenGL:
OpenGL is strictly defined as “a software interface to graphics hardware” In essence; it is a
3D graphics and modelling library that is highly portable and very fast. Using OpenGL, you
can create elegant and beautiful 3D and 2D graphics with exceptional visual quality. The
Greatest advantage to using OpenGL is that it is orders of magnitude faster than a ray tracer
or software rendering engine. OpenGL is intended for use with computer hardware that is
designed and optimized for the display and manipulation of 3D graphics.
       The interface between an application program and a graphics system can be specified
through a set of functions that resides in a graphics library. These specifications are called the
application programmer’s interface (API). The application program sees only the API and is
thus shielded from the details of the both softer and hardware implementation of the graphics
library. The software drivers are responsible for interpreting the output of API and converting
these data to a form that is understood by the particular hardware. From the perspective of
the application program, the functions available through the API should match the conceptual
model that the user wishes to employ to specify images
Chapter 2
                           LITERATURE SURVEY
People use the term “computer graphics” to mean different things in different context.
Computer graphics are pictures that are generated by a computer. Everywhere you look
today, you can find examples, especially in magazines and on television. Some images look
so natural you can’t distinguish them from photographs of a real scene. Others have an
artificial look, intended to achieve some visual effects.
       There are several ways in which the graphics generated by the program can be
delivered.
      Frame- by- frame: A single frame can be drawn while the user waits.
      Frame-by-frame under control of the user: A sequence of frames can be drawn, as in a
       corporate power point presentation; the user presses to move on to the next slide, but
       otherwise has no way of interacting with the slides
      Animation: A sequence of frames proceeds at a particular rate while the user watches
       with delight.
      Interactive program: An interactive graphics presentation is watched, where the user
       controls the flow from one frame to another using an input device such as a mouse or
       keyboard, in a manner that was unpredictable at the time the program was written.
       This can delight the eye.
2.1 History
       OpenGL was developed by ‘Silicon Graphics Inc’ (SGI) on 1992 and is popular in
the gaming industry where it competes with the Direct3D in the Microsoft Windows
platform. OpenGL is broadly used in CAD (Computer Aided Design), virtual reality,
scientific visualization, information visualization, flight simulation and video games
development.
       OpenGL is a standard specification that defines an API that is multi-language and
multi-platform and that enables the codification of applications that output computerized
graphics in 2D and 3D.
          The interface consists in more than 250 different functions, which can be used to
draw complex tridimensional scenes with simple primitives. It consists of many functions
that help to create a real world object and a particular existence for an object can be given.
2.2       Characteristics
         OpenGL is a better documented API.
         OpenGL is also a cleaner API and much easier to learn and program.
         OpenGL has the best demonstrated 3D performance for any API.
         Microsoft's Direct3D group is already planning a major API change called Direct
          Primitive that will leave any existing investment in learning Direct3D immediate
          mode largely obsolete.
GLU
                                GL
    Open GL
   application
                                                                                 Frame
  program                                                                        Buffer
                                                         Xlib, Xtk
                              GLUT
GLX
   1) Primitive Functions:
               Primitive functions define the low level objects or atomic entities that a
               system can display, the primitives include line segments, polygons, pixels,
               points, text and various types of curves and surfaces.
   2) Attribute Functions:
               Attribute Functions allow us to perform operations ranging from choosing the
               color to display a line segment, to packing a pattern to fill inside any solid
               figure.
   3) Viewing Functions:
               Viewing functions allow us to specify various views.
   4) Transformation Functions:
               Transformation functions allow us to carry out transformation of objects such
               as rotation, translation and scaling.
   5) Input Functions:
               Input functions allow us to deal with the diverse forms of input that
               characterize modern graphics system. It deals with devices such as keyboard,
               mouse and data tablets.
   6) Control Functions:
               Control Functions enable us to communicate with the window system, to
               initialize the programs, and to deal with any errors that occur during the
               execution of the program.
   7) Query Functions:
               Query Functions provides information about the API.
Chapter 3
                             SYSTEM REQUIREMENTS
Requirements        analysis     is   critical   for   project   development. Requirements must   be
documented, actionable, measurable, testable and defined to a level of detail sufficient for
system design. Requirements can be architectural, structural, behavioural, functional, and
non-functional. A software requirements specification (SRS) is a comprehensive description
of the intended purpose and the environment for software under development.
Chapter 4
                          ANALYSIS AND DESIGN
4.1 Description
Design is the planning that lays the basics for the making of every object or system. The
chapter involves the designing of the various aspects and different stages of the project.
When the program is made to execute, the output window is displayed first.
       In the first display, initially the fisherman will be seated on the boat and will be
moving in the running water. When he reaches display11 he doesn’t find any fishes, display2
starts where he finds the fishes, the fisherman then stops and applies the net to catch the
fishes. In the display3 the fisherman is aheading near the market along with the net and the
fishes. He reaches the market along with the fishes in display4.The boat could be initiated,
stopped and made to move at a faster pace while the boat is in motion using the keyboard
keys and the mouse button. In addition to this an option is provided to go back in the reverse
direction in the third display. Thereby the fisherman reaches his destination as per the
intention of our project. In order to provide user interaction, which will enable the user to
interact with the scenario, is done using the standard keyboard.
Mouse Input
    Left mouse button to quit.
                                              USER
                                          INTERACTION
               KEYBOARD
                                                                                MOUSE FUNCTION
               FUNCTION
                                                                                       LEFT CLICK
              ALPHABETS
                                                                                             QUIT
KEY ‘f’       KEY ‘n’       KEY‘s’        KEY‘t’       KEY ‘r’       KEY ‘q’
  TO            TO         TO STOP          TO         TO GO           TO
SPEED         APPLY          THE          START        IN             QUIT
UP THE       THE NET        BOAT           THE         REVERS
BOAT                                      BOAT         E BOAT
          The above figure shows the design of the project, where the user interaction, i.e.,
 keyboard and the mouse functions has been provided. Under the keyboard function, keys
 ‘f’,’n’,’s’,’t’ , ’r’ and ’q’ are used to increase the speed of the boat, to apply the net, to stop
 the boat, to start the boat, to go in reverse direction and to quit respectively. Under mouse
 function, left click would do the job of quitting from the program again.
Chapter 5
                               IMPLEMENTATION
This chapter includes a flowchart that depicts the flow of control of the project. The purpose
of various built-in functions and user-defined functis are also described.
5.1 source code
         The execution of the program starts from the main function. It calls various inbuilt
and user defined functions, Pseudo code is as follows:
void main(int argc , char **argv)
{
Initialize GLUT using glutInit();
Initialize the display mode to DOUBLE or RGB;
Set the window position;
Set the window size;
Create a window;
Call myinit();
Call display();
Call keyboard();
Call mouse();
Call timerfunc();
Start execution from glutMainLoop();
}
Void myinit()
{
Clear the display to white color using glClearColor();
Set the matrix mode;
Load the identity matrix;
}
Void display()
{
    Clear the color buffers;
    Call the drawm() user defined function;
    Call swapbuffers;
}
Void drawm()
{
    Based on different conditions, we call the various display functions;
}
Void mouse()
{
    Upon the click of the left mouse button, the program terminates.
}
Void drawr()
{
This function makes the fisherman move in reverse direction;
}
Void market()
{
POLYGON functions is called accordingly to construct the market;
}
Void fish1()
{
POLYGON function is called to draw the shape of purple fish;
LINE functions is called accordingly to draw the body of purple fish;
}
Void fish2()
{
POLYGON function is called to draw the shape of golden fish;
LINE functions is called accordingly to draw the body of golden fish;
}
5.2 Flowchart
       Flowchart is a pictorial representation of the program. The figure shows the different
functions used in the project.
Start
Initialization
MainLoop
Display()
                                        If(flag=                T   Drawm()             A
                                        =1)
                                                       F
                                      KeyboardFunc(
                                            )                       B
                                      MouseFunc()
                                                                    C
Myinit()
Stop
Display1()
If(a>950) Display11()
N Y
If(k>960) N Display2()
                                                                          Display3()
                                 If(b>970)
                                                  N
                                                            Y
                                                                         Display4()
                                 If(c>=290)
                                              N
                                                                            Drawr()
                                 If(flag1==1)
Exit (0)
                                          B
Dept. of CSE, DSATM, Bengaluru                    2016-17                              Page 13
Fishing Occupation
                                            Key ‘f’
                                                                        display()
                                            Key ‘r’
                                                                        drawr()
                                            Key ‘n’
                                                                           snet()
Key‘s’ Flag=0
Key‘t’ Flag=1
        The above flowchart depicts the flow control of the program, as to how it works.
Starting with the main, it enters the display function wherein if the flag is set to 1, it calls the
drawm() which in turn calls the display1 where depending on various conditions, the
functions display11, display 2, display3, display4 else keyboard keys ‘f’ used to increase the
speed of the boat calls the display(), ‘n’ calls snet(). Key ‘s’ sets flag to zero which is used to
stop the boat , key ‘r’ is used to move the boat in reverse direction ,key ‘t’ sets flag to one and
is used to start the boat and key ‘q’ to quit. Under the mouse function the left of the mouse is
used to quit from the program.
5.3 Functions
        The functions that are used in the program are discussed below. There are two types
of functions. They are in-built and user defined functions. These functions are as follows:
Chapter 6
                                        SNAPSHOT
     Initial Display screen
          Fig 6.1: The above output shows the initial display screen wherein the fisherman seated on
                  the boat is yet to start moving from the bank.
       Fig 6.2: The above output shows the boat moving with the fisherman in the display1.
               Key ‘t’ is used for starting the boat and key‘s’ for stopping the boat.
      Fig 6.3: The above output shows that the fisherman doesn’t find any fishes. Key ’s’ is
                used to stop the boat .Key ‘f’ is used to increase the speed of the boat.
Fig 6.4: The output shows the boat moving in the forward direction and the presence of fishes.
Snapshot in which the man is moving along with the net and fishes
       Fig 6.5: The above output shows the fisherman is moving along with the net to the market
                .Key ‘t’ is used to start the boat and move forward.
Fig 6.6: The above output shows the fisherman applying net on the fishes after finding them .
Key ‘s’ is used to stop the boat and then apply the net.
               Fig 6.7: The above output shows that the man has reached the destination along with the
                        fishes .He has reached the market in display4.
               Fig 6.8: The above output shows that the boat can move in reverse direction. Key ‘r’ is
                        used to move the boat in reverse direction.
Chapter 7
                                  CONCLUSION
        The mini project “FISHING OCCUPATION” has been efficiently developed with
OpenGL. This is indeed an interactive project which has efficient interactions given through
the keyboard as well as the mouse. The project shows the fisherman seated on the boat
moving forward in search of fishes. He applies the net on finding them and proceeds forward
to another bank reaching the market which is present on the other side of the bank. The boat
could be started, stopped and made to move at a faster pace while the boat is in motion using
the keyboard keys and the mouse button to quit along with an option to move in reverse
direction.
REFERENCE