Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
90 views

Manhattan Network: Ntroduction

This document provides an introduction to a project titled "Manhattan Network". It discusses the objectives, scope and statement of the problem for the project. The project aims to route packets from source to destination in a network without congestion while introducing lighting and rotational effects to the nodes. The project uses OpenGL functions for graphics and the report will include chapters on the basics of computer graphics, design, implementation, snapshots and conclusions. Key concepts discussed include the history of 2D and 3D computer graphics, pixels, and graphics.

Uploaded by

vivektoocool
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Manhattan Network: Ntroduction

This document provides an introduction to a project titled "Manhattan Network". It discusses the objectives, scope and statement of the problem for the project. The project aims to route packets from source to destination in a network without congestion while introducing lighting and rotational effects to the nodes. The project uses OpenGL functions for graphics and the report will include chapters on the basics of computer graphics, design, implementation, snapshots and conclusions. Key concepts discussed include the history of 2D and 3D computer graphics, pixels, and graphics.

Uploaded by

vivektoocool
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Manhattan Network CHAPTER 1

Page | 1

INTRODUCTION
1.1Introduction
The term computer graphics includes almost everything on computers that is not text or sound. Today nearly all computers use some graphics and users expect to control their computer through icons and pictures rather than just by typing. The term Computer Graphics has several meanings:

the representation and manipulation of pictorial data by a computer the various technologies used to create and manipulate such pictorial data the images so produced, and the sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content, see study of computer graphics

Today computers and computer-generated images touch many aspects of our daily life. Computer imagery is found on television, in newspapers, in weather reports, and during surgical procedures. A well-constructed graph can present complex statistics in a form that is easier to understand and interpret. Such graphs are used to illustrate papers, reports, theses, and other presentation material. A range of tools and facilities are available to enable users to visualize their data, and computer graphics are used in many disciplines.

1.2 Objective of the problem


This project MANHATTAN NETWORK aims at the implementation of a concept related to NETWORKS wherein the packets are routed from a given source to destination in a most efficient way without any congestion. We also intend to introduce light effects and rotational effects to the nodes in such a way that our intended packets and nodes together with its light go hand in hand and are properly synchronized. Lastly, the demonstration is shown for 5 packets along with the lighting effect of nodes and also rotational effects.

1.3 Scope of the problem


A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network

Page | 2

In this project we can interact using the keyboard functions. Pressing the keys triggers the packets to be sent from source to destination.

1.4 Statement of the problem


OpenGL is a software interface to graphics hardware. This interface consists of about 150 distinct commands, which we use to specify the objects and operations needed to produce interactive 3dimensional applications. OpenGL has become a widely accepted standard for developing graphics applications Fortunately, OpenGL is easy to learn and it possesses most of the characteristics of other popular graphics systems. It can be used to implement several effects. Hence this project has become more colorful with the effects implemented using OpenGL.In this project, OpenGL functions like rotation, translation, scaling etc. were used. Fishes, sand, grass etc are drawn using OpenGL functions

1.5 Methodology
The methods used in this project are the basic knowledge about rotation, scaling, translation. This project is implemented mainly using the c/c++ programming constructs and OpenGL functions. The fishes are built mainly using the vertices and basic primitives like polygon, points, lines etc. The conditional statements and iterative statements are used to implement the various callback functions.

1.6 Organization
The first chapter of the report is the introduction. It contains the information about the introduction to the project, objective of the project, scope of the project and the method of implementation. The second chapter deals with the Basics Of Computer Graphics The third chapter is the Literature survey which includes matter from (and refer) papers/books and other sources. The fourth chapter is the Requirements which include the hardware and software requirements.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 3

The fifth chapter is the Design which includes the flow of control of the program and the modules used in the program. The sixth chapter is the Implementation which shows how the various modules in the program are implemented. The seventh chapter is the Snapshots which includes the test cases and the snapshots. The eight chapter is the Conclusion and the future scope which concludes the project And gives the future enhancements that can be made to the project. Next comes the Appendix A and Appendix B which contains the informations about functions used in the program and libraries respectively.

Next chapter is Bibliography which includes the names of referred books and websites.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network CHAPTER 2

Page | 4

BASICS OF COMPUTER GRAPHICS


2.1 History
The phrase Computer Graphics was coined in 1960 by William Fetter, a graphic designer for Boeing. The field of computer graphics developed with the emergence of computer graphics hardware. Early projects like the Whirlwind and SAGE Projects introduced the CRT as a viable display and interaction interface and introduced the light pen as an input device. In the 1980s, artists and graphic designers began to see the personal computer, particularly the Commodore Amiga and Macintosh, as a serious design tool, one that could save time and draw more accurately than other methods. In the late 1980s, SGI computers were used to create some of the first fully computer-generated short films at Pixar. The Macintosh remains a highly popular tool for computer graphics among graphic design studios and businesses. Modern computers, dating from the 1980s often use graphical user interfaces (GUI) to present data and information with symbols, icons and pictures, rather than text. Graphics are one of the five key elements of multimedia technology.

2.2 2D computer graphics

Figure-2.1:Raster graphic sprites (left) and masks (right) 2D computer graphics are the computer-based generation of digital images mostly from twodimensional models, such as 2D geometric models, text, and digital images, and by techniques

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 5

specific to them. The word may stand for the branch of computer science that comprises such techniques, or for the models themselves. 2D computer graphics are mainly used in applications that were originally developed upon traditional printing and drawing technologies, such as typography, cartography, technical drawing, advertising, etc.. In those applications, the two-dimensional image is not just a representation of a real-world object, but an independent artifact with added semantic value; twodimensional models are therefore preferred, because they give more direct control of the image than 3D computer graphics, whose approach is more akin to photography than to typography.

2.3 3D computer graphics


3D computer graphics in contrast to 2D computer graphics are graphics that use a threedimensional representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images. Such images may be for later display or for real-time viewing. Despite these differences, 3D computer graphics rely on many of the same algorithms as 2D computer vector graphics in the wire frame model and 2D computer raster graphics in the final rendered display. In computer graphics software, the distinction between 2D and 3D is occasionally blurred; 2D applications may use 3D techniques to achieve effects such as lighting, and primarily 3D may use 2D rendering techniques. 3D computer graphics are often referred to as 3D models. Apart from the rendered graphic, the model is contained within the graphical data file. However, there are differences. A 3D model is the mathematical representation of any three-dimensional object (either inanimate or living). A model is not technically a graphic until it is visually displayed. Due to 3D printing, 3D models are not confined to virtual space. A model can be displayed visually as a twodimensional image through a process called 3D rendering, or used in non-graphical computer simulations and calculations.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network 2.4 Concepts and Principles


Image

Page | 6

In common usage, an image or picture is an artifact, usually two-dimensional, that has a similar appearance to some subjectusually a physical object or a person. Images may be twodimensional, such as a photograph, screen display, and as well as a three-dimensional, such as a statue. They may be captured by optical devicessuch as cameras, mirrors, lenses, telescopes, microscopes, etc. and natural objects and phenomena, such as the human eye or water surfaces. A digital image is a representation of a two-dimensional image using ones and zeros (binary). Depending on whether or not the image resolution is fixed, it may be of vector or raster type. Without qualifications, the term "digital image" usually refers to raster images.

Pixel

Figure-2.2: In the enlarged portion of the image individual pixels are rendered as squares and can be easily seen. In digital imaging, a pixel is the smallest piece of information in an image. Pixels are normally arranged in a regular 2-dimensional grid, and are often represented using dots or squares. Each pixel is a sample of an original image, where more samples typically provide a more accurate representation of the original. The intensity of each pixel is variable; in color systems, each pixel has typically three or four components such as red, green, and blue, or cyan, magenta, yellow, and black.

Graphics
Dept Of C.S.E 2011-2012

A.P.S College Of Engineering

Manhattan Network

Page | 7

Graphics are visual presentations on some surface, such as a wall, canvas, computer screen, paper, or stone to brand, inform, illustrate, or entertain. Examples are photographs, drawings, line art, graphs, diagrams, typography, numbers, symbols, geometric designs, maps, engineering drawings, or other images. Graphics often combine text, illustration, and color. Graphic design may consist of the deliberate selection, creation, or arrangement of typography alone, as in a brochure, flier, poster, web site, or book without any other element. Clarity or effective communication may be the objective, association with other cultural elements may be sought, or merely, the creation of a distinctive style.

Rendering
Rendering is the process of generating an image from a model, by means of computer programs. The model is a description of three dimensional objects in a strictly defined language or data structure. It would contain geometry, viewpoint, texture, lighting, and shading information. The image is a digital image or raster graphics image. The term may be by analogy with an "artist's rendering" of a scene. 'Rendering' is also used to describe the process of calculating effects in a video editing file to produce final video output. 3D projection: 3D projection is a method of mapping three dimensional points to a two dimensional plane. As most current methods for displaying graphical data are based on planar two dimensional media, the use of this type of projection is widespread, especially in computer graphics, engineering and drafting. Ray tracing: Ray tracing is a technique for generating an image by tracing the path of light through pixels in an image plane. The technique is capable of producing a very high degree of photorealism; usually higher than that of typical scanline rendering methods, but at a greater computational cost.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 8

Figure-2.3: Example of shading. Shading: refers to depicting depth in 3D models or illustrations by varying levels of darkness. It is a process used in drawing for depicting levels of darkness on paper by applying media more densely or with a darker shade for darker areas, and less densely or with a lighter shade for lighter areas. There are various techniques of shading including cross hatching where perpendicular lines of varying closeness are drawn in a grid pattern to shade an area. The closer the lines are together, the darker the area appears. Likewise, the farther apart the lines are, the lighter the area appears.

2.4.5 Volume rendering

Figure-2.4: Volume rendered CT scan of a forearm with different colour schemes for muscle, fat, bone, and blood. Volume rendering is a technique used to display a 2D projection of a 3D discretely sampled data set. A typical 3D data set is a group of 2D slice images acquired by a CT or MRI scanner. Usually these are acquired in a regular pattern (e.g., one slice every millimeter) and usually have a regular number of image pixels in a regular pattern. This is an example of a regular volumetric grid, with each volume element, or voxel represented by a single value that is obtained by sampling the immediate area surrounding the voxel.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
3D modeling

Page | 9

3D modeling is the process of developing a mathematical, wireframe representation of any threedimensional object via specialized software. The product is called a "3D model". It can be displayed as a two-dimensional image through a process called 3D rendering or used in a computer simulation of physical phenomena. The model can also be physically created using 3D Printing devices. Models may be created automatically or manually. The manual modeling process of preparing geometric data for 3D computer graphics is similar to plastic arts such as sculpting.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 10

CHAPTER 3

LITERATURE SURVEY
. The combination of computers, networks and complex human visual system, through computer graphics, has led to new ways of displaying information, seeing virtual worlds and communicating with people and machine. Computer graphics is concerned with all aspects of producing pictures or image. OpenGL provides a set of commands to render a 3D scene. An OpenGL application will work on every platform, as long as there is an installed implementation. The OpenGL is a graphics software interface to the hardware which has been studied to implement the project. Because it is system independent, there are no functions to create window etc, but there are helper functions for each platform. A very useful thing is GLUT. GLUT is a complete API written by Mark Kilgard which lets you create windows and handle the messages. OpenGL also contains a standard library referred to as the OpenGL utilities(GLU).GLU contains routines for setting up viewing projection matrices and describing complex objects with lines and polygon approximation. Our approach to computer graphics is programming oriented the programming concepts geometry is used in the project. Have been studied to give the proper pseudo code. The concept of specifying simple Rigid body transformation like translation, rotation and scaling has been referred to implement this aquarium project. User interactive functions like keyboard functions have been included.

3.1 About OpenGL


OpenGL provides a set of commands to render a three dimensional scene. That means you provide the data in an OpenGL-useable form and OpenGL will show this data on the screen (render it). It is developed by many companies and it is free to use. You can develop OpenGLapplications without licensing. A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network

Page | 11

OpenGL is a hardware- and system-independent interface. An OpenGL-application will work on every platform, as long as there is an installed implementation.Because it is system independent, there are no functions to create windows etc., but there are helper functions for each platform. A very useful thing is GLUT.

3.2 About GLUT


GLUT is a complete API written by Mark Kilgard which lets you create windows and handle the messages. It exists for several platforms, that means that a program which uses GLUT can be compiled on many platforms without (or at least with very few) changes in the code.

3.3 Working of OpenGL


OpenGL bases on the state variables. There are many values, for example the color, that remain after being specified. That means, you can specify a color once and draw several polygons, lines or what ever with this color then. There are no classes like in DirectX. However, it is logically structured. Before we come to the commands themselves, here is another thing: To be hardware independent, OpenGL provides its own data types. They all begin with "GL". For example GLfloat, GLint and so on. There are also many symbolic constants, they all begin with "GL_", like GL_POINTS, GL_POLYGON. Finally the commands have the prefix "gl" like glVertex3f(). There is a utility library called GLU, here the prefixes are "GLU_" and "glu". GLUT commands begin with "glut", it is the same for every library. You want to know which libraries coexist with the ones called before? There are libraries for every system, Windows has the wgl*-Functions, Unix systems glx* and so on. A very important thing is to know, that there are two important matrices, which affect the transformation from the 3d-world to the 2d-screen: The projection matrix and the modelview matrix. The projection matrix contains information, how a vertex let's say a "point" in space shall be mapped to the screen. This contains, whether the projection shall be isometric or from a perspective, how wide the field of view is and so on. Into the other matrix you put information, how the objects are moved, where the viewer is and so on.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 12

Don't like matrices? Don't be afraid, you probably won't really see them, at least at the beginning. There are commands that do all the maths for you. Some basic commands are explained later in this tutorial.

3.4 GLUT usage


GLUT provides some routines for the initialization and creating the window (or fullscreen mode, if you want to). Those functions are called first in a GLUT application: In your first line you always write glutInit(&argc, argv). After this, you must tell GLUT, which display mode you want single or double buffering, color index mode or RGB and so on. This is done by calling glutInitDisplayMode(). The symbolic constants are connected by a logical OR, so you could use glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE). In later tutorials we will use some more constants here. After the initialization you call glCreateWindow() with the window name as parameter.Then you can (and should) pass some methods for certain events. The most important ones are "reshape" and "display". In reshape you need to (re)define the field of view and specify a new area in the window, where OpenGL is allowed to draw to. Display should clear the so called color buffer let's say this is the sheet of paper and draw our objects. You pass the methods by glut*Func(), for example glutDisplayFunc(). At the end of the main function you call glutMainLoop(). This function doesn't return, but calls the several functions passed by glut Func

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 13

CHAPTER 4

SYSTEM REQUIREMENTS
4.1 Hardware Requirements
Minimum hardware specification Processor: Dual core processor Main memory:2 GB RAM Hard Disk: 80 or 120 GB min.

4.2 Software Requirements


Minimum software specification OPENGL Library Operating System Windows Visual Studio

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 14

CHAPTER 5

DESIGN
5.1 Flowchart

Start

Creation of network paths using drawline() function

Creation of packets and nodes

Translation of packets from source to destination

Display congestion avoidance by routing packets

stop

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
Figure-5: Flowchart

Page | 15

CHAPTER 6

IMPLEMENTATION
6.1 Algorithm
Step 1: Initialize the primitives such as the window position, window coordinates and its size. Step 2: Register the callback functions such as display, keyboard and other callbacks to interact with the system, with the help of GLUT functions. Step 3: Initially by using the drawline functions the network paths are drawn. Step 4: the drawline function is also used to draw the packets which are initially not visible on the screen. Step 5: on pressing s key 2 packets are sent from a predetermined spurce and destination using the translate function. Step 6: on pressing x key the execution is stopped.

6.2 Sample codes


void drawline(void) { glBegin(GL_LINES); glVertex2f(80.0,200.0); glVertex2f(130.0,200.0); glVertex2f(170.0,200.0); glVertex2f(210.0,200.0); glVertex2f(250.0,200.0); //first horizontal loop from the bottom

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
glVertex2f(290.0,200.0); glVertex2f(330.0,200.0); glVertex2f(370.0,200.0); glVertex2f(80.0,200.0); glVertex2f(80.0,170.0); glVertex2f(80.0,170.0); glVertex2f(450.0,170.0); glVertex2f(450.0,170.0); glVertex2f(450.0,200.0); glVertex2f(450.0,200.0); glVertex2f(410.0,200.0); glVertex2f(130.0,200.0); glVertex2f(124.0,207.5); glVertex2f(130.0,199.5); glVertex2f(124.0,192.5); glVertex2f(210.0,199.0); glVertex2f(204.0,207.0); glVertex2f(210.0,200.0); glVertex2f(204.0,192.5); glVertex2f(290.0,200.0); glVertex2f(284.0,207.5); glVertex2f(290.0,199.5); glVertex2f(284.0,192.0); glVertex2f(370.0,200.0); glVertex2f(364.0,207.0); glVertex2f(370.0,199.5); glVertex2f(364.0,192.0); glEnd(); { glPushMatrix(); glTranslatef(trans1,0.0,0.0); A.P.S College Of Engineering // Translate function to translate the packets from Source to destination node Dept Of C.S.E

Page | 16

2011-2012

Manhattan Network
glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); { glVertex2f(415.0,450.0); glVertex2f(415.0,430.0); glVertex2f(425.0,430.0); glVertex2f(425.0,450.0); glEnd(); } trans1=trans1-3; glPopMatrix();

Page | 17

void keys(unsigned char key, int x, int y) { if(key == 'a') { start=0; glutPostRedisplay(); } if(key == 's') { start = 1; glutPostRedisplay(); } if(key == 'd') { start1 = 1; glutPostRedisplay();

\\ Keyboard Function

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
}if(key=='x') exit(0);}

Page | 18

CHAPTER 7

SNAPSHOTS

Figure 7.1: Initial position, With the nodes represented by rotating spheres

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 19

Figure 7.2:2 packets from source at the extreme right from the top start moving On pressing d key

Figure 7.3:packes take different routes to destination to avoid congestion

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 20

Figure 7.4: snapshot showing more packets across the network leading to congestion

CHAPTER-8

CONCLUSION AND FUTURE ENHANCEMENT


8.1 Conclusion
I started with modest aim with no prior experience in any programming projects as this, but ended up in learning many things, fine tuning the programming skills and getting into the real world of software development with an exposure to corporate environment. During the development of any software of significant utility, we are faced with the trade-off between speed of execution and amount of memory consumed. This is simple interactive application. It is extremely user friendly and has the features, which makes simple graphics project. It has an open source code and no security features has been included. The user is free to alter the code for feature enhancement. Checking and verification of all possible types of the functions are taken care. Care was taken to avoid bugs. Bugs may be reported to creator as the need may be .So, we A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network

Page | 21

conclude on note that we are looking forward to develop more such projects with an appetite to learn more in computer graphics.

8.2 Future Enhancement


Further enhancements may include specifying the source node and destination node. Also the specification of number of packets to be transmitted between the nodes We can also specify the node numbers for better understanding.

APPENDIX A
5.2 HEADER FILES
The <stdlib.h> Header File # include <stdlib.h> The ISO C standard introduced this header file as a place to declare certain standard library functions. These include the Memory management functions (malloc, free, et. al.) communication with the environment (abort, exit) and others. Not yet all the standard functions of this header file are supported. If a dlaration is present in the supplied header file, then uCR supports it and will continue to support it. If a function is not there, it will be added in time.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
The <stdio.h> Header File # include <stdio.h>

Page | 22

Load the file SIMPLEIO.C for our first look at a file with standard I/O. Standard I/O refers to the most usual places where data is either read from, the keyboard, or written to, the video monitor. Since they are used so much, they are used as the default I/O devices and do not need to be named in the Input/Output instructions. This will make more sense when we actually start to use them so lets look at the file in front of you. The first thing you will notice is the second line of the file, the #include "stdio.h" line. This is very much like the #define we have already studied, except that instead of a simple substitution, an entire file is read in at this point. The system will find the file named "stdio.h" and read its entire contents in, replacing this statement. Obviously then, the file named "stdio.h" must contain valid C source statements that can be compiled as part of a program. This particular file is composed of several standard #defines to define some of the standard I/O operations. The file is called a header file and you will find several different header files on the source disks that came with your C compiler. Each of the header files has a specific purpose and any or all of them can be included in any program.

Your C compiler uses the double quote marks to indicate that the search for the "include" file will begin in the current directory, and if it not found there, the search will continue in the "include" directory as set up in the environment. It also uses the "less than" and "greater than" signs to indicate that the file search should begin in the directory specified in the environment. Most of the programs in this tutorial have the double quotes in the "include" statements. The next program uses the "<" and ">" to illustrate the usage. Note that this will result is a slightly faster (but probably unnoticeable) compilation because the system will not bother to search the current directory.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 23

APPENDIX B
FUNCTIONS

glLightfv Function
The glLightfv function returns light source parameter values.

SYNTAX: void glLightfv(GLenum light, GLenum pname, GLfloat *params); PARAMETERS:

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
light

Page | 24

The identifier of a light. The number of possible lights depends on the implementation, but at least eight lights are supported. They are identified by symbolic names of the form GL_LIGHTi where i is a value: 0 to GL_MAX_LIGHTS - 1. Pname A light source parameter for light. The following symbolic names are accepted: GL_DIFFUSE : The params parameter contains four integer or floating-point values that specify the diffuse RGBA intensity of the light. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The default diffuse intensity is (0.0, 0.0, 0.0, 1.0) for all lights other than light zero. The default diffuse intensity of light zero is (1.0, 1.0, 1.0, 1.0). GL_SPECULAR : The params parameter contains four integer or floating-point values that specify the specular RGBA intensity of the light. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to 1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The default specular intensity is (0.0, 0.0, 0.0, 1.0) for all lights other than light zero. The default specular intensity of light zero is (1.0, 1.0, 1.0, 1.0). glLightfv(GL_LIGHT1,GL_POSITION,pos);

glPushMatrix, glPopMatrix Function


The glPushMatrix and glPopMatrix functions push and pop the current matrix stack.

SYNTAX: void glPushMatrix, glPopMatrix(void); PARAMETERS: This function has no parameters. glPushMatrix(); glPopMatrix();

glEnable, glDisable Function


Dept Of C.S.E 2011-2012

A.P.S College Of Engineering

Manhattan Network
The glEnable and glDisable functions enable or disable OpenGL capabilities. SYNTAX: void glEnable, glDisable(GLenum cap); PARAMETERS: cap

Page | 25

A symbolic constant indicating an OpenGL capability. glEnable(GL_CULL_FACE); glDisable(GL_CULL_FACE);

glColor3f Function Sets the current color.

SYNTAX: void glColor3f(GLfloat red, GLfloat green, GLfloat blue); PARAMETERS: red The new red value for the current color. green The new green value for the current color.

glBegin, glEnd Function


The glBegin and glEnd functions delimit the vertices of a primitive or a group of like primitives. SYNTAX: void glBegin, glEnd(GLenum mode); PARAMETERS: A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network
mode

Page | 26

The primitive or primitives that will be created from vertices presented between glBegin and the subsequent glEnd. The following are accepted symbolic constants and their meanings: GL_LINES: Treats each pair of vertices as an independent line segment. Vertices 2n - 1 and 2n define line n. N/2 lines are drawn. GL_LINE_STRIP: Draws a connected group of line segments from the first to the last. Vertices n and n+1 define line n. N - 1 lines are drawn. GL_LINE_LOOP: Draws a connected group of line segments from the first vertex to the last, then back to the first. Vertices n and n + 1 define line n. The last line, however, is defined by vertices N and N lines are drawn. GL_TRIANGLES: Treats each triplet of vertices as an independent triangle. Vertices 3n - 2, 3n - 1, and 3n define triangle n. N/3 triangle are drawn. GL_QUADS: Treats each group of four vertices as an independent quadrilateral. Vertices 4n - 3, 4n - 2, 4n - 1, and 4n defined quadrilateral n. N/4 quadrilaterals are drawn. vertex

glNormal3f Function
Sets the current normal vector. SYNTAX: void glNormal3b(GLfloat nx, GLfloat ny, GLfloat nz); PARAMETERS: nx

Specifies the x-coordinate for the new current normal vector. nx

Specifies the y-coordinate for the new current normal vector.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
nz

Page | 27

Specifies the z-coordinate for the new current normal vector. glNormal3f(1.0,0.0,0.0);

glVertex3f Function
Specifies a vertex. SYNTAX: void glVertex3f(GLfloat x, GLfloat y, GLfloat z); PARAMETERS: x Specifies the x-coordinate of a vertex. y

Specifies the y-coordinate of a vertex. z

Specifies the z-coordinate of a vertex. glVertex3f(-3.0,3.0,4.0);

glRotatef Function
The glRotated and glRotatef functions multiply the current matrix by a rotation matrix. SYNTAX: void glRotate( GLfloat angle, GLfloat x, GLfloat y, GLfloat z); PARAMETERS: angle

The angle of rotation, in degrees. x

The x coordinate of a vector. A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network
y

Page | 28

The y coordinate of a vector. z

The z coordinate of a vector. glRotatef(xrot,1.0,0.0,0.0);

glTranslate Function
The glTranslated and glTranslatef functions multiply the current matrix by a translation matrix. SYNTAX: void glTranslate( x, y, z); PARAMETERS: x, y, z

The x, y, and z coordinates of a translation vector. glTranslatef(0.0,0.0,-1.0);

glScalef Function
The glScaled and glScalef functions multiply the current matrix by a general scaling matrix. SYNTAX: void glScalef(GLfloat x, GLfloat y, GLfloat z); PARAMETERS: x Scale factors along the x axis. y Scale factors along the y axis. A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network
z Scale factors along the z axis. glScalef(1.0,1.0,-1.0);

Page | 29

FUNCTIONS USED TO DISPLAY glClear Function


The glClear function clears buffers to preset values. SYNTAX: glClear(GLbitfield mask); PARAMETERS: mask Bitwise OR operators of masks that indicate the buffers to be cleared. The four masks are as follows. Value GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT Meaning The buffers currently enabled for color writing. The depth buffer.

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glMatrixMode Function
The glMatrixMode function specifies which matrix is the current matrix. SYNTAX: void glMatrixMode(GLenum mode); PARAMETERS: A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network
mode

Page | 30

The matrix stack that is the target for subsequent matrix operations. The mode parameter can assume one of three values: Value GL_MODELVIEW Meaning Applies subsequent matrix operations to the modelview matrix stack. glMatrixMode(GL_MODELVIEW);

glLoadIdentity Function
The glLoadIdentity function replaces the current matrix with the identity matrix. SYNTAX: void glLoadIdentity(void); PARAMETERS: This function has no parameters. glLoadIdentity();

glRotatef Function glPushMatrix, glPopMatrix Function glScalef Function glTranslate Function glClear Function glPushAttrib, glPopAttrib Pushes or pops the attribute stack.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
Name glPushAttrib glPopAttrib Meaning Pushes the attribute stack. Pops the attribute stack. glPushAttrib(0xffffffff); glPopAttrib();

Page | 31

glEnable, glDisable Function glColor4f Function Sets the current color.

SYNTAX: void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); PARAMETERS: red The new red value for the current color. green The new green value for the current color. blue The new blue value for the current color. alpha The new alpha value for the current color. glColor4f(0.0,0.0,0.0,0.05);

glBegin, glEnd Function

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
glVertex3f Function glutSwapBuffers glutSwapBuffers swaps the buffers of the current window if double buffered. SYNTAX: void glutSwapBuffers(void); glutSwapBuffers();

Page | 32

FUNCTIONS USED TO RESHAPE glViewport Function


The glViewport function sets the viewport.

SYNTAX: void glViewport(x, y,width, height); PARAMETERS: x, y The lower-left corner of the viewport rectangle, in pixels. The default is (0,0). width, height The width and height, respectively, of the viewport. When an OpenGL context is first attached to a window, width and height are set to the display. glViewport(0,0,w,h);

glMatrixMode Function glLoadIdentity Function gluPerspective Function Dept Of C.S.E 2011-2012

A.P.S College Of Engineering

Manhattan Network
set up a perspective projection matrix SYNTAX:

Page | 33

void gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar ); PARAMETERS: fovy Specifies the field of view angle, in degrees, in the y direction. aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height). zNear Specifies the distance from the viewer to the near clipping plane (always positive). zFar Specifies the distance from the viewer to the far clipping plane (always positive). msecs Number of milliseconds to pass before calling the callback. func The timer callback function. value Integer value to pass to the timer callback. glutTimerFunc(TIMER,timer,0); gluPerspective(50.0,(float)w/(float)h,1.0,20.0);

STATIC INIT FUNCTION glEnable, glDisable Function

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
glLightfv Function glMaterialfv Function The glMaterialfv function specifies material parameters for the lighting model. SYNTAX: void glMaterialfv(GLenum face, GLenum pname, const GLfloat params); PARAMETERS: face

Page | 34

The face or faces that are being updated. Must be one of the following: GL_FRONT, GL_BACK, or GL_FRONT and GL_BACK. pname The material parameter of the face or faces being updated. The parameters that can be specified using glMaterialfv, and their interpretations by the lighting equation, are as follows. GL_SPECULAR:The params parameter contains four integer or floating-point values that specify the specular RGBA reflectance of the material. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The default specular reflectance for both front-facing and back-facing materials is (0.0, 0.0, 0.0, 1.0). glMaterialfv(GL_FRONT,GL_SPECULAR,white);

glColorMaterial Function
The glColorMaterial function causes a material color to track the current color. SYNTAX: void glColorMaterial(GLenum face, GLenum mode); PARAMETERS:

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network
face

Page | 35

Specifies whether front, back, or both front and back material parameters should track the current color. Accepted values are GL_FRONT, GL_BACK, and

GL_FRONT_AND_BACK. The default value is GL_FRONT_AND_BACK. Mode Specifies which of several material parameters track the current color. Accepted values are GL_EMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, and

GL_AMBIENT_AND_DIFFUSE. The default value is GL_AMBIENT_AND_DIFFUSE. glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);

glutDisplayFunc Function
glutDisplayFunc sets the display callback for the current window. SYNTAX: void glutDisplayFunc(void (*func)(void)); PARAMETERS: func The new display callback function. glutDisplayFunc(display);

glutReshapeFunc Function
glutReshapeFunc sets the reshape callback for the current window. SYNTAX: void glutReshapeFunc(void (*func)(int width, int height)); PARAMETERS: func Dept Of C.S.E 2011-2012

A.P.S College Of Engineering

Manhattan Network
The new reshape callback function. glutReshapeFunc(reshape);

Page | 36

MAIN FUNCTION glutInit Function


glutInit is used to initialize the GLUT library. SYNTAX: glutInit(int *argcp, char **argv); PARAMETERS: argcp A pointer to the program's unmodified argc variable from main. Upon return, the value pointed to by argcp will be updated, because glutInit extracts any command line options intended for the GLUT library. Argv The program's unmodified argv variable from main. Like argcp, the data for argv will be updated because glutInit extracts any command line options understood by the GLUT library. glutInit(&argc,argv);

glutInitDisplayMode Function
glutInitDisplayMode sets the initial display mode. SYNTAX: void glutInitDisplayMode(unsigned int mode); PARAMETERS: A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network
mode

Page | 37

Display mode, normally the bitwise OR-ing of GLUT display mode bit masks. See values below: GLUT_RGB: An alias for GLUT_RGBA. GLUT_DOUBLE: Bit mask to select a double buffered window. This overrides GLUT_SINGLE if it is also specified. GLUT_DEPTH: Bit mask to select a window with a depth buffer. glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE);

glutInitWindowPosition, glutInitWindowSize Functions


glutInitWindowPosition and size respectively. SYNTAX: void glutInitWindowSize(int width, int height); void glutInitWindowPosition(int x, int y); PARAMETERS: width Width in pixels. height Height in pixels. x Window X location in pixels. y Window Y location in pixels. glutInitWindowSize(300,300); Dept Of C.S.E 2011-2012 glutInitWindowSize set the initial window position and

A.P.S College Of Engineering

Manhattan Network
glutCreateWindow Function
glutCreateWindow creates a top-level window. SYNTAX: int glutCreateWindow(char *name); PARAMETERS: name ASCII character string for use as window name. glutCreateWindow("two pass mirror");

Page | 38

. glutMainLoop Function
glutMainLoop enters the GLUT event processing loop. SYNTAX: void glutMainLoop(void); glutMainLoop();

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 39

BIBLIOGRAPHY
[i] Edward Angel : Computer Graphics Using OpenGL,3nd Edition.
Donald Hearn and Pauline Baker: Computer Graphics Version,2nd Edition.

[ii]

[iii] www.opengl.org

[iv]

www.morrowland.com

[v]

Jeffrey J. McConnell (2006). Computer Graphics: Theory Into Practice. Jones & Bartlett Publishers.

[vi]

R. D. Parslow, R. W. Prowse, Richard Elliot Green (1969). Computer Graphics: Techniques and Applications.

[vii]

Peter Shirley and others. (2005). Fundamentals of computer graphics. A.K. Peters, Ltd.

[viii] M. Slater, A. Steed, Y. Chrysantho (2002). Computer graphics and virtual environments: from realism to real-time. Addison-Wesley A.P.S College Of Engineering Dept Of C.S.E 2011-2012

Manhattan Network

Page | 40

USER MANUAL
Install Visual C++ 2008 Express Edition
This is a free C++ IDE from Microsoft that is an excellent tool to start with, if you are interested in programming on a Windows environment. Click on the setup icon to install the software. Visual Studio SharePoint workflow features have specific installation requirements. To use the SharePoint workflow development tools in Visual Studio Tools for Office, complete the following installation steps in the specified order. 1. Install Windows Server 2003. 2. Install Internet Information Services (IIS). In Control Panel, select Add/Remove Windows components, then Application Server, then Details, then Internet Information Services (IIS). 3. Install .NET Framework 2.0 and .NET Framework 3.0. 4. In IIS Manager, enable ASP.NET 2.0.5727.

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 41

5. Install Microsoft Office SharePoint Server 2007. Make sure to run the configuration wizard. 6. Install Visual Studio 2008. Use the default installation or make sure that Visual Studio Tools for Office is selected on the Custom installation page of the Setup wizard. Setup stops and displays an error message, "Setup failed to stop Windows Installer service. You must stop all other applications running Windows Installer service or restart your computer before the installation".

Install the GLUT Library


Download the original GLUT from Nate Robins' site. Copy all the .h files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\GL folder. This should be glut.h, freeglut.h, freeglut_ext.h, and freeglut_std.h. Copy all the .lib files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib folder. This should be freeglut.lib and glut32.lib. Copy all the .dll files into the C:\Windows\system32 folder. This should be freeglut.dll and glut32.dll.

Creating the project:


Step 1: To create an empty console project in Visual Studio, do the following: Create a new project (File ---> New ---> --->Project ) In the Project Types: pane, select Visual C++, Win32. Then select Win 32 Console Application in the Templates: pane.Name your project, select the location for the project and click OK. Click the Application Settings tab on the left, and check the Empty Project box. Then click Finish button Step 2: Add Source Code 1. Select Project, Add New Item

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

Manhattan Network

Page | 42

2. In the Categories pane, select Visual C++, Code. Then select C++ File (,cpp) in the Templates: pane. Name your file, and then click Add. Step 3: Compile and Run the project 1. Compile From the Visual Studio's menu Build option (Build ---> Build Solution) 2.Execute the program From the Visual Studio's menu Debug option. 3.(Debug ---> Start without Debugging)

A.P.S College Of Engineering

Dept Of C.S.E

2011-2012

You might also like