DATA COMMUNICATION over INTERNET
SL.NO particulars PAGE.NO
1 Abstract 2
2 System Specifications 3
3 Introduction to OpenGL 4
4 Implementation 7
5 Interaction 9
6 Source Code 10
7 Output 28
8 Conclusion 30
9 Bibliography 31
Contents
1 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
Abstract
Main aim of this Mini Project is to illustrate the concepts and usage of
Data Communication over Internet in OpenGL.
Communication begins with a message, or information, that must be
sent from one individual or device to another.
The first of these elements is the message source, or sender.
Message sources are people, or electronic devices, that need to
send a message to other individuals or devices.
The second element of communication is the destination, or
receiver, of the message. The destination receives the message and
interprets it.
A third element, called a channel, consists of the media that
provides the pathway over which the message can travel from
source to destination.
We have used input devices like mouse and key board to interact with
program.
We have used a SolidSphere to represent an earth. Multiple
SolidCube to form Building, Personal Computers(PC) as we can see in
this project.
We have also used WireCube to look as physical data medium.
To differentiate between objects we have used different colors for
different objects.
We have added menu which makes the program more interactive.
2 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
System specifications
SOFTWARE REQUIREMENTS :
MICROSOFT VISUAL C++
OPENGL
OPERATING SYSTEM :
WINDOWS 2007, WINDOWS XP.
HARDWARE REQUIREMENT :
GRAPHICS SYSTEM.
Pentium P4 with 256 of Ram(Min).
3 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
Introduction to OpenGL
As a software interface for graphics hardware, OpenGL's main purpose is to render
two- and three-dimensional objects into a frame buffer.
These objects are described as sequences of vertices or pixels.
OpenGL performs several processing steps on this data to convert it to pixels to
form the final desired image in the frame buffer.
OpenGL Fundamentals
This section explains some of the concepts inherent in OpenGL.
Primitives and Commands
OpenGL draws primitives—points, line segments, or polygons—subject to several
selectable modes.
You can control modes independently of each other; that is, setting one mode
doesn't affect whether other modes are set .Primitives are specified, modes are set,
and other OpenGL operations are described by issuing commands in the form of
function calls.
Primitives are defined by a group of one or more vertices. A vertex defines a
point, an endpoint of a line, or a corner of a polygon where two edges meet. Data is
associated with a vertex, and each vertex and its associated data are processed
independently, in order, and in the same way. The type of clipping depends on
which primitive the group of vertices represents.
Commands are always processed in the order in which they are received, although
there may be an indeterminate delay before a command takes effect. This means
that each primitive is drawn completely before any subsequent command takes
effect. It also means that state-querying commands return data that's consistent
with complete execution of all previously issued OpenGL commands.
4 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
Basic OpenGL Operation
The figure shown below gives an abstract, high-level block diagram of how
OpenGL processes data. In the diagram, commands enter from the left and proceed
through what can be thought of as a processing pipeline. Some commands specify
geometric objects to be drawn, and others control how the objects are handled
during the various processing stages.
Figure . OpenGL Block Diagram
As shown by the first block in the diagram, rather than having all commands
proceeds immediately through the pipeline, you can choose to accumulate some of
them in a display list for processing at a later time.
Rasterization produces a series of frame buffer addresses and associated values
using a two-dimensional description of a point, line segment, or polygon.
Each fragment so produced is fed into the last stage,
5 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
Per-Fragment operations, which performs the final operations on the data before
it's stored as pixels in the frame buffer. These operations include conditional
updates to the frame buffer based on incoming and previously stored z-value s (for
z-buffering) and blending of incoming pixel colors with stored colors, as well as
masking and other logical operations on pixel values.
All elements of OpenGL state, including the contents of the texture memory and
even of the frame buffer, can be obtained by an OpenGL application.
6 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
Implementation
This program is implemented using various OpenGL functions which are
shown below.
Various functions used in this program.
glutInit() : interaction between the windowing system and OPENGL is
initiated
glutInitDisplayMode() : used when double buffering is required and depth
information is required
glutCreateWindow() : this opens the OPENGL window and displays the
title at top of the window
glutInitWindowSize() : specifies the size of the window
glutInitWindowPosition() : specifies the position of the window in screen
co-ordinates
glutKeyboardFunc() : handles normal ASCII symbols
glutSpecialFunc() : handles special keyboard keys
glutReshapeFunc() : sets up the callback function for reshaping the window
glutIdleFunc() : this handles the processing of the background
glutDisplayFunc() : this handles redrawing of the window
glutMainLoop() : this starts the main loop, it never returns
7 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glViewport() : used to set up the viewport
glVertex3fv() : used to set up the points or vertices in three dimensions
glColor3fv() : used to render color to faces
glFlush() : used to flush the pipeline
glutPostRedisplay() : used to trigger an automatic redrawal of the object
glMatrixMode() : used to set up the required mode of the matrix
glLoadIdentity() : used to load or initialize to the identity matrix
glTranslatef() : used to translate or move the rotation centre from one point
to another in three dimensions
glRotatef() : used to rotate an object through a specified rotation angle
Interaction with program
8 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
We can have an interaction with this project using popular input device like
mouse and key board are used to interact with this program.
Some keys of key board have specific function, we mentioned them below,
‘s/S’ - Start
‘n/N’ – Network
‘a/A’ – About Project
With these above mentioned keys, we can interact with the program.
Also we can interact with this program by using mouse (input device),
By click on right and left button
On right click of mouse menu will occur.
Select the option by left click of mouse.
Source Code
9 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
#include<stdlib.h>
#include<Windows.h>
#include<string.h>
#include<stdarg.h>
#include<stdio.h>
#include <GL/glut.h>
static double x=0.0,x1=-3.0,x2=3.0,y1=0.0,y2=0;
static double x8=-4.0,x9=4.0,y8=1.0,y9=1;
static double move=-60;
static bool pca2pcb=false,pca2rt=false,rt2pca=false, pcb2pca=false, local=false,
dubai=false;
void P();
void d();
void *font;
void *currentfont;
void setFont(void *font)
{
currentfont=font;
}
void drawstring(float x,float y,float z,char *string)
{
char *c;
glRasterPos3f(x,y,z);
for(c=string;*c!='\0';c++)
{ glColor3f(0.0,1.0,1.0);
glutBitmapCharacter(currentfont,*c);
}
}
void stroke_output(GLfloat x, GLfloat y, char *format,...)
{ va_list args;
char buffer[200], *p;
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
glPushMatrix();
10 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glTranslatef(-2.5, y, 0);
glScaled(0.003, 0.005, 0.005);
for (p = buffer; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopMatrix();
}
//Windows
void window(float x4, float y4)
{
glLoadIdentity();
glColor3f(1.0,1.5,0.5);
glTranslatef(0.0f,0.0f,-11.0f);
for(float j=-2;j<1.5;j+=.8)
{ for(float i=-3.3;i<-2;i+=0.7)
{ glPushMatrix();
glTranslatef(i,j,-0.2);
glutSolidCube(0.3);
glPopMatrix();
}
}
}
//Windows
void window1(float x5, float y5)
{
glLoadIdentity();
glColor3f(1.5,0,0);
glTranslatef(0.0f,0.0f,-11.0f);
for(float j=-2;j<1.5;j+=.8)
{ for(float i=2.6;i<=3.5;i+=0.7)
{ glPushMatrix();
glTranslatef(i,j,-0.2);
glutSolidCube(0.3);
glPopMatrix();
}
}
}
11 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
//Router
void router(float x6, float y6)
{
glLoadIdentity();
glColor3f(0.2,0.3,1);
glTranslatef(0.0f,0.0f,-13.0f);
glPushMatrix();
glScaled(0.45,1.5,0.1);
glRotatef(91,1.0f,0.0f,0.0f);
glTranslatef(x6,y6,-2.0);
glutSolidTorus(0.2,1.5,10,10);
glPopMatrix();
}
//PC Computers
void pc(float x7, float y7, float z7)
{ glLoadIdentity();
glColor3f(0.1,0.1,.1);
glTranslatef(0.0f,0.0f,-13.0f);
glPushMatrix();
glPushMatrix();
glScaled(.7,.7,0);
glRotatef(95,1.0f,0.0f,0.0f);
glTranslatef(x7,y7,z7);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glColor3f(1,1,1);
//Condition for pcB to change Color
if(pcb2pca && x7==5)
glColor3f(1,0,0);
// Condition for PCA to change color
if(pcb2pca && x9>=-5 && x9<=-4 && x7==-5)
glColor3f(1,0,0);
glScaled(.7,.7,0);
glRotatef(95,1.0f,0.0f,0.0f);
glTranslatef(x7,y7,z7);
12 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glutSolidCube(.85);
glPopMatrix();
glPopMatrix();
}
//PC
void cpu(float x7, float y7, float z7)
{ glLoadIdentity();
glColor3f(0.5,0.5,.5);
glTranslatef(0.0f,0.0f,-13.0f);
glPushMatrix();
glPushMatrix();
glScaled(1,.3,0);
glRotatef(95,1.0f,0.0f,0.0f);
glTranslatef(x7,y7,z7);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glColor3f(1,1,1);
glScaled(1,.3,0);
glRotatef(95,1.0f,0.0f,0.0f);
glTranslatef(x7,y7,z7);
glutSolidCube(.4);
glPopMatrix();
glPopMatrix();
}
//Draw LAN/WAN
void lan(double x8,double y8)
{
glClearColor(0.6,0.5,.5,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
router(0,-1);
//Data Media (connected to Router)
glPushMatrix();
13 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glTranslatef(0.0,1.0,-2.0);
glScaled(0.1,5.0,0.1);
glColor3f(1,1,1);
glutWireCube(1.5);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,0.0,-2.0);
glScaled(5.1,0.1,0.1);
glColor3f(1,1,1);
glutWireCube(1.5);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,0.0,-2.0);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(1,3.5,-1.0,"ROUTER");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-4.6,.5,-1.0,"PC-A");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-.5,.5,-1.0,"SWITCH");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(4,.5,-1.0,"PC-B");
glPopMatrix();
//Data Transfer
if(pca2pcb){
// data
glPushMatrix();
glTranslatef(x8,y8,-2.0);
glScaled(0.1,0.1,0.1);
glColor3f(x8,0,1);
glutSolidCube(1);
glPopMatrix();
if(x8>=4){
14 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
pcb2pca=true;
pca2pcb=false;
} }
//Ack
if(pcb2pca){
glPushMatrix();
glTranslatef(x8,y8,-2.0);
glScaled(0.1,0.1,0.1);
glColor3f(x8,0,1);
glutSolidCube(1);
glPopMatrix();
}
if(pca2rt)
{
glPushMatrix();
glTranslatef(x8,y8,-2.0);
glScaled(0.1,0.1,0.1);
glColor3f(x8,0,1);
glutSolidCube(1);
glPopMatrix();
}
// move the packet out of LAN
if(pca2rt && rt2pca==false && y8>=6)
{
glutIdleFunc(P);
}
//switch
glPushMatrix();
glColor3f(0.5,0.5,1.5);
glTranslatef(0.0,0,1.0);
glRotatef(15,1.0f,0.0f,0.0f);
glScaled(1.2,0.2,1.0);
glutSolidCube(1);
glPopMatrix();
pc(-5,1,0);
cpu(-3.5,7,1.5);
15 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
pc(5,1,0);
cpu(3.5,7,1.5);
pc(0,20,2);
cpu(0,105,1.5);
glFlush();
glutSwapBuffers();
}
// Draw Network
void network(double ang,double x1,double x2,double y1,double y2)
{
glClearColor(0.0,0.85,1,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
glBegin(GL_POLYGON);
glColor3f(0.0,1.8,0.0);
glVertex2f(-10,0);
glVertex2f(10,0);
glVertex2f(-10,-10);
glVertex2f(-10,10);
glEnd();
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-4.2,2.65,0.0,"LOCAL BUILDING");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-1.5,3.2,0.0,"EARTH Connected with Fibric Wires");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(2.5,2.65,0.0,"DUBAI BUILDING");
//Earth
glPushMatrix();
glColor3f(0.5,0.5,1.5);
glScaled(0.8,1,0.8);
glTranslatef(0.0,2.2,0.0);
glRotatef(ang,0.0f,-1.0f,0.0f);
16 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glutSolidSphere(1,20,20);
glPopMatrix();
//Building A
glLoadIdentity();
glTranslatef(0.0f,0.0f,-12.0f);
glPushMatrix();
glTranslatef(-3,-0.5,0.0);
glScaled(0.8,2.2,0.8);
glutSolidCube(1.8);
glPopMatrix();
window(-2.6, 1);
//Building B
glLoadIdentity();
glTranslatef(0.0f,0.0f,-12.0f);
glPushMatrix();
glTranslatef(3,-0.5,0.0);
glScaled(0.8,2.2,0.8);
glutSolidCube(1.8);
glPopMatrix();
window1(3.3, 1);
// Line 1
glPushMatrix();
glTranslatef(-3.0,1.0,-2.0);
glScaled(0.1,3.0,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
glPushMatrix();
glTranslatef(-1.45,2.4,-2.0);
glScaled(3.0,0.2,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
//Line 2
glPushMatrix();
17 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glTranslatef(3.0,1.0,-2.0);
glScaled(0.1,3.0,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
glPushMatrix();
glTranslatef(1.45,2.4,-2.0);
glScaled(3.0,0.2,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
// Transmission of Datapackets
glPushMatrix();
// Send Packets
if(local){
if(x1==-3 && y1<=2.38)
glTranslatef(-3,y1,-2.0);
if(y1>=2.38 && x1<=3)
glTranslatef(x1,2.38,-2.0);
if(x1>=3 && y1>=0)
glTranslatef(3,y1,-2.0);
if(x1>=3 && y1<=0.0)
{
dubai=true;
local=false;
} }
// Ack packets
if(dubai)
{
if(x2>=3 && y2<=2.38)
glTranslatef(3,y2,-2.0);
if(y2>=2.38 && x2>=-3)
glTranslatef(x2,2.38,-2.0);
if(x2<=-3 && y2>=0.0)
glTranslatef(-3,y2,-2.0);
if(x2<=-3 && y2<=0.0)
18 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
{
dubai=false;
local=true;
rt2pca=true;
x8=0;
y8=6;
glutIdleFunc(d);
} }
glScaled(0.1,0.1,0.1);
glColor3f(1,1,1);
glutSolidCube(1);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void building(double ang)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
glPushMatrix();
glScaled(0.3,1.5,0.3);
glRotatef(90,1.0f,0.0f,0.0f);
glTranslatef(8.5,0,-0.5);
glutSolidTorus(0.2,1.0,40,40);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void about()
{
glClearColor(0.0,0.85,1,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
19 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glColor3f(0,0,0);
drawstring(-4.2,2,0.0,"About Data Communication");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-3.5,1.5,0.0,"1. Data Communications refers to the exchange of
data between two devices via some");
glColor3f(0,0,0);
drawstring(-3.5,1,0.0," form of transmission medium such as a wire
cable.");
glColor3f(0,0,0);
drawstring(-3.5,.5,0.0,"2. Similarly data and information from one computer
system can be transmitted to");
glColor3f(0,0,0);
drawstring(-3.5,0.0,0.0," other systems across geographical areas.");
glColor3f(0,0,0);
drawstring(-3.5,-0.5,0.0,"3. Thus data transmission is the movement of
information using some standard methods.");
glColor3f(0,0,0);
drawstring(-3.5,-1,0.0,"4. The effectiveness of a data communications
system depends on");
glColor3f(0,0,0);
drawstring(-3.5,-1.5,0.0," four fundamental characteristics: delivery,
accuracy, timeliness, and jitter.");
glColor3f(0,0,0);
drawstring(-3.5,-2,0.0,"5. A network is two or more devices connected
through links.");
glColor3f(0,0,0);
drawstring(-3.5,-2.5,0.0,"6. A link is a communications pathway that
transfers data from one device to another.");
glColor3f(0,0,0);
drawstring(-3.5,-3,0.0,"7. Type of Connection : Point-to-Point &
Multipoint.");
glFlush();
glutSwapBuffers();
}
void s()
20 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
{
lan(-4,1);
}
void n()
{
x-=0.07;
network(x,0,0,0,0);
}
void P()
{
if(local)
{
if(x1==-3 && y1<=2.38){
y1+=0.01;
}
if(y1>=2.38 && x1<=3.0)
{ x1+=0.01;
}
if(x1>=3 && y1>=0.0){
y1-=0.01;
}
x+= .07;
network(x,x1,x2,y1,y2);
}
//Dubai to local
if(dubai)
{
if(x2>=3 && y2<=2.38)
y2+=0.01;
if(y2>=2.38 && x2>=-3)
x2-=0.01;
if(x2<=-3 && y2>=0.0)
y2-=0.01;
x+= .07;
network(x,x1,x2,y1,y2);
} }
21 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
void d()
{
if(pca2pcb)
{ if(x8>=-4 && x8<=4){
x8+=0.01;
}
lan(x8,0);
}
if(pcb2pca)
{
if(x9<=4 && x9>=-4){
x9-=0.01;
}
lan(x9,0);
}
// To Dubai
if(pca2rt & rt2pca==false)
{
if(x8>=-4 && y8<=6){
if(x8<=0)
{x8+=0.01;
}
if(x8>=0 && y8<=6)
{
y8+=0.01;
}
}
lan(x8,y8);
}
if(rt2pca)
{
if(x8<=0 && y8<=6){
if(y8>=0)
{y8-=0.01;
}
if(x8>=-4 && y8<=0)
22 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
{
x8-=0.01;
} }
lan(x8,y8);
} }
void doInit()
{
/* Background and foreground color */
glClearColor(0.0,0.0,0.0,0);
glViewport(0,0,640,480);
/* Select the projection matrix and reset it then
setup our view perspective */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0f,(GLfloat)640/(GLfloat)480,0.1f,200.0f);
/* Select the modelview matrix, which we alter with rotatef() */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearDepth(2.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
}
void display()
{
glClearColor(0.1,0.1,0.5,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(3.0,1.0,1.0);
drawstring(-1.5,3.0,0.0,"DEPARTMENT OF COMPUTER SCIENCE");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-3.0,2.5,0.0,"Computer Graphics Mini Project on DATA
COMMUNICATION IN NETWORK");
23 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-1,2,0,"Using OPENGL");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-0.5,1.5,0,"By");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-2,1,0,"BUSHRA JABEEN (USN : 3KB10CS022)");
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-2,.5,0,"BUSHRA SULTANA (USN : 3KB10CS023)");
stroke_output(-2.0, -1, "s --> Start");
stroke_output(-2.0, -1.75, "A --> About");
stroke_output(-2.0, -3,"q --> Quit");
GLfloat mat_ambient[]={0.0f,1.0f,2.0f,1.0f};
GLfloat mat_diffuse[]={0.0f,1.5f,.5f,1.0f};
GLfloat mat_specular[]={5.0f,1.0f,1.0f,1.0f};
GLfloat mat_shininess[]={50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
GLfloat lightIntensity[]={1.7f,1.7f,1.7f,1.0f};
GLfloat light_position3[]={0.0f,5.0f,5.0f,0.0f};
glLightfv(GL_LIGHT0,GL_POSITION,light_position3);
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
glEnable(GL_COLOR_MATERIAL);
glFlush();
glutSwapBuffers();
}
void menu(int id)
{
switch(id)
{
case 1:glutIdleFunc(about);
24 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
break;
case 2:glutIdleFunc(s);
break;
case 3:glutIdleFunc(d);
break;
case 4:glutIdleFunc(P);
break;
case 5:glutIdleFunc(n);
break;
case 6:
pca2pcb=true;
x8=-4;
glutIdleFunc(d);
break;
case 7:
local=true;
dubai=false;
pca2rt=true;
x8=-4.0;x9=4.0;y8=0.0; y9=0;
pca2pcb=false;
pcb2pca=false;
glutIdleFunc(d);
break;
case 8: pca2rt=false;
pca2pcb=false;
x8=-4.0;x9=4.0;y8=1.0; y9=0;
x=0.0;x1=-3.0;x2=3.0;y1=0.0;y2=2.38;
pca2pcb=false;pca2rt=false; pcb2pca=false;
glutIdleFunc(s);
break;
case 9:exit(0);
break;
}
glFlush();
glutSwapBuffers();
glutPostRedisplay();
25 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
}
void mykey(unsigned char key,int x,int y)
{
if(key=='s')
{
glutIdleFunc(s);
}
if(key=='n')
{
glutIdleFunc(n);
}
if(key=='P')
{
glutIdleFunc(P);
}
if(key=='A')
{
glutIdleFunc(about);
}
if(key=='q'||key=='Q')
{
exit(0);
}
}
void main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(1000,480);
glutInitWindowPosition(0,0);
glutCreateWindow("Data Communication in Network");
glutDisplayFunc(display);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
26 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
glEnable(GL_NORMALIZE);
glutKeyboardFunc(mykey);
glutCreateMenu(menu);
glutAddMenuEntry("About Project 'A'",1);
glutAddMenuEntry("Local Area Network(LAN) 's'",2);
glutAddMenuEntry("Local Area Network(LAN) 'n'",3);
glutAddMenuEntry("Wide Area Network(WAN) 'P'",5);
glutAddMenuEntry("Transfer data from PC-A to PC-B '1'",6);
glutAddMenuEntry("Transfer data from PC-A to Company B -->'2'",7);
glutAddMenuEntry("Reset 'r'",8);
glutAddMenuEntry("Quit 'q'",9);
glutAttachMenu(GLUT_RIGHT_BUTTON);
doInit();
glutMainLoop();
}
27 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
OUTPUT OF THE PROGRAM
28 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
Conclusions
This project aims at using glut pre-built model sub-api and callback functions.
Finally we conclude that this program clearly illustrate the use of glut model sub-
api. and has been completed successfully and is ready to be demonstrated.
Bibliography
29 Dept. of Computer Science & Engineering.
DATA COMMUNICATION over INTERNET
WE HAVE OBTAINED INFORMATION FROM MANY RESOURCES TO DESIGN AND
IMPLEMENT OUR PROJECT SUCCESSIVELY. WE HAVE ACQUIRED MOST OF THE
KNOWLEDGE FROM RELATED WEBSITES. THE FOLLOWING ARE SOME OF THE
RESOURCES :
TEXT BOOKS :
INTERACTIVE COMPUTER GRAPHICS A TOP-DOWN APPROACH
-By Edward Angel.
COMPUTER GRAPHICS,PRINCIPLES & PRACTICES
- Foley van dam
- Feiner hughes
WEB REFERENCES:
http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson3.php
http://google.com
http://opengl.org
30 Dept. of Computer Science & Engineering.