0% found this document useful (0 votes)
86 views27 pages

1.1 Introduction To Computer Graphics

SHIVA",2); output(220,100,"Press 'e' to start Encryption",2); glPopMatrix(); glFlush(); } // ENCRYPTION SCREEN void encryption() { int i; // COMPONENTS computer(); computer_dest(); message(); key(); cipher(); // ANIMATION for(i=0;i<=100;i++) { animation_encryption(); delay(); } } Department of Computer Science and Engg, S.G.B.I.T.Belagavi.

Uploaded by

Sejal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views27 pages

1.1 Introduction To Computer Graphics

SHIVA",2); output(220,100,"Press 'e' to start Encryption",2); glPopMatrix(); glFlush(); } // ENCRYPTION SCREEN void encryption() { int i; // COMPONENTS computer(); computer_dest(); message(); key(); cipher(); // ANIMATION for(i=0;i<=100;i++) { animation_encryption(); delay(); } } Department of Computer Science and Engg, S.G.B.I.T.Belagavi.

Uploaded by

Sejal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Encryption and decryption.

2018

Chapter 1
INTRODUCTION
1.1 Introduction to Computer Graphics
Computer graphics started with the display of data on hardcopy plotters and Cathode Ray Tube (CRT)
screens soon after the Introduction of computers themselves. It has grown to include the Creation,
Storage and Manipulation of Models and Images of objects. These models come from a diverse and
expanding set of fields, and include physical, mathematical, engineering, architectural and even
conceptual structures, natural phenomenon and so on. Computer graphics today is largely interactive:
the user controls the contents, structure, and appearance of objects and of their displayed images by
using input devices, such as a keyboard, mouse, or touch-sensitive panel on the screen. Because of the
close relationship between the input devices and the display, the handling of such devices is included in
the study of computer graphics.

1.2 Uses of Computer Graphics:


Computer graphics is used in many different areas of industry, business, government, education,
entertainment etc.

User Interfaces

Word-processing, spreadsheet and desktop-publishing programs are typical applications of such user-
interface techniques.

Interactive Plotting in Business, Science and Technology

The common use of graphics is to create 2D and 3D graphs of mathematical, physical and economic
functions, histograms, and bar and pie charts.

Computer Aided Drafting and Design (CAD)

In CAD, interactive graphics is used to design components and systems of mechanical, electrical and
electronic devices including structures such as buildings, automobile bodies, aero planes, ship hulls etc.

Simulation and Animation for Scientific Visualization and Entertainment

Computer-produced animated movies are becoming increasing popular for scientific and engineering
visualization. Cartoon characters will increasingly be modeled in the computer as 3D shape descriptions
whose movements are controlled by computer commands.

2D Graphics

These editors are used to draw 2D pictures (line, rectangle, circle and ellipse) alter those with operations
like cut, copy and paste. These may also support features like translation, rotation etc.

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 1


Encryption and decryption. 2018

3D Graphics

These editors are used to draw 3D pictures (line, rectangle, circle and ellipse).These may also support
features like translation, rotation etc.

GLUT will use GLX and X libraries.

#include<GL/glut.h>

OR

#include<GLUT/glut.h>

GLUT is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL
programs. It implements a simple windowing application programming interface (API) for OpenGL.
GLUT makes it considerably easier to learn about and explore OpenGL programming. GLUT provides a
portable API so you can write a single OpenGL program that works across all PC and workstation OS
platforms. GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT
is well-suited to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-
featured toolkit so large applications requiring sophisticated user interfaces are better off using native
window system toolkits. GLUT is simple, easy, and small.The GLUT library has C, C++ (same as C),
FORTRAN, and ADA programming bindings. The GLUT source code distribution is portable to nearly
all OpenGL implementations and platforms. The current version is 3.7. Additional releases of the library
are not anticipated. GLUT is not open source.

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 2


Encryption and decryption. 2018

Chapter 2
SYSTEM REQUIREMENTS
System requirements are intended to communicate in precise way, the functions that the system must
provide. To reduce ambiguity, they may be written in a structured form of natural language
supplemented by tables and system models.

2.1 HARDWARE REQUIREMENTS


The physical components required are:

Processor – intel core i5

Memory – 8 GB

40GB Hard Disk Drive

2.2 SOFTWARE REQUIREMENTS


The software used in building this program are as specified:-

Operating system – windows

Tools : CodeBocks

Graphics Library – glut.h

OpenGL

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 3


Encryption and decryption. 2018

Chapter 3
IMPLEMENTATION
file_gen is used to check whether high score file already exists. If it does not, it will create. If it does,
it will read data from existing file.

render_header to display the player's name along with a running timer. The timer gets its values
from the clock class, which maintains the time elapsed since the game started in hour, minutes and
seconds.

hiscore_check to determine the position of the player in the highscores list. If he completes the game
in a time lesser than the top 10 players, it implements an insertion sort to insert the player's name and
time into the existing high score list.

write_file is used to write a text file of the current player class. The player class contains details of
the player name and the time he took to complete the game. All these details, along with the pre-existing
records of the highscores are arranged in ascending order of time and are written into a text file.

sub is the display function for the sub window created to display the highscores. This window is
activated when the user chooses the option "highscores" from the menu obtained on right click of the
mouse.

Mouse events:

When mouse event occurs, the ASCII code for the corresponding coordinates that generate the event and
the location of mouse are returned. Mouse callback function is

glutMouseFunc (mouse);
Void mouse (int btn, int state, int x, int y) {
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
begin = x;
}

Menu Entry:
GLUT provides one additional feature, pop_up menus, which we can use with the mouse to create
sophisticated interactive application

glutCreateMenu ();
glutAddMenuEntry ();
glutAttachMenu (GLUT_RIGHT_BUTTON);
Application program
Description
Mouse event
Motion event

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 4


Encryption and decryption. 2018

3.1 DESIGN:
The flow chart describes how the path travels.

Compiled built and executed

Application
Program

Compiled built and executed


Description

Mouse Event Motion Event Menu List

Fig 3.1: Data flow diagram.

Figure 3.1 under Implementation Chapter explains the Data Flow Diagram.

This includes the flow from application program to handling different events like Mouse event, Motion
event and the Menu list.

3.2 USER DEFINED FUNCTIONS


display(): this function calls the frontpage function.

frontpage(): this function displays the project name, students name,guide name and also
an input is asked from the user to start the project.

encryption(): the function creates the components required in the process i.e; client side
computer (computer()), destination computer(computer_dest()),the message data
block(message()),cipher block (cipher()),key block(key()).

animation_encryption(): this function is concerned with the speed of the movement of the
key,message and cipher block from client to server computer.

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 5


Encryption and decryption. 2018

CODE:

#include<windows.h>

#include<stdlib.h>

#include<GL/glut.h>

#include<stdio.h>

#include<math.h>

#include<string.h>

#define SCENE 10

enum { FRONTPAGE,ENCRYPTION,EXIT };

int width = 650, height = 650;

void *font =GLUT_BITMAP_HELVETICA_12;

void *fonts[] =

GLUT_BITMAP_9_BY_15,

GLUT_BITMAP_TIMES_ROMAN_10,

GLUT_BITMAP_TIMES_ROMAN_24, // Text Styles

GLUT_BITMAP_HELVETICA_12,

GLUT_BITMAP_HELVETICA_10,

GLUT_BITMAP_HELVETICA_18,

};

// TO DISPLAY THE TEXT INFORMATION

void output(int x, int y, char *string,int j)

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 6


Encryption and decryption. 2018

{ int len, i;

glRasterPos2f(x, y);

len = (int) strlen(string);

for (i = 0; i < len; i++)

glutBitmapCharacter(fonts[j], string[i]);

// FUNCTIONS. FOR DELAY

void delay(void)

{ int i,j,k;

for(i=0;i<5000;i++)

for(j=0;j<10000;j++);

for(k=0;k<15000;k++);

void delay1(void)

int i;

for(i=0;i<10000;i++);

// FIRST SCREEN - FRONT PAGE

void front_page()

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 7


Encryption and decryption. 2018

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);

glPushMatrix();

output(220,550,"COLLEGE NAME : S.G.B.I.T",2);

output(320,500,"A",2);

output(220,450,"MINI PROJECT ON",2);

output(220,400,"ENCRYPTION AND DECRYPTION",2);

output(130,200,"Guides:Veena",2);

//output(175,180,"Name 1:",2);

//output(175,150,"Name 2:",2);

output(450,200,"By:",3);

output(475,180,"Name 1 : NAUSEEN",2);

output(475,150,"Name 2 : RIDA",2);

output(275,50,"Press S to start",2);

glFlush();

glCallList(SCENE);

glPopMatrix();

glutSwapBuffers();

/* Movement angles */

GLint
movement_angle=0,packet_angle=0,head_angle=0,packet_angle1=0,head_angle1=0,packet_angle2=0,
head_angle2=0,packet_angle3=0,head_angle3=0,packet_angle4=0;

GLdouble mov_speed = 1;

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 8


Encryption and decryption. 2018

GLint
head_angle4=0,packet_angle5=0,head_angle5=0,packet_angle6=0,head_angle6=0,packet_angle7,hea
d_angle7=0,packet_angle8=40;

/* Movement angles */

GLint
movement_angle1=0,arrow_angle=0,rev_arrow_angle=0,phy_header_angle=0,rev_phy_header_angle
=0,rev_phy_header_angle1=0,phy_header_angle1=0,analog_sig_angle=0,rev_analog_sig_angle = 0;

void animation_encryp(void)

if ((movement_angle += mov_speed) >= 600)

movement_angle = 600;

if ((arrow_angle += mov_speed) >= 150)

arrow_angle = 150;

if(arrow_angle==150)

if ((phy_header_angle += mov_speed) >= 100)

phy_header_angle = 100;

if(phy_header_angle==100)

if ((phy_header_angle1 += mov_speed) >= 100)

phy_header_angle1 = 100;

if(phy_header_angle1==100)

if ((analog_sig_angle += mov_speed) >= 100)

analog_sig_angle = 100;

if(analog_sig_angle==100)

if ((movement_angle1 += mov_speed) >= 420)

movement_angle1 = 420;

if(movement_angle1 ==420)

if ((rev_analog_sig_angle += mov_speed) >= 100)

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 9


Encryption and decryption. 2018

rev_analog_sig_angle = 100;

if(rev_analog_sig_angle ==100)

if ((rev_phy_header_angle += mov_speed) >= 200)

rev_phy_header_angle = 200;

if(rev_phy_header_angle ==200)

if ((rev_phy_header_angle1 += mov_speed) >= 100)

rev_phy_header_angle1 = 100;

if(rev_phy_header_angle ==200)

if ((rev_arrow_angle += mov_speed) >= 100)

rev_arrow_angle = 100;

glutPostRedisplay();

void computer()

glColor3f(0.75,0.85,0.65);//keyboard

glBegin(GL_QUADS);

glVertex2f(55.0,340.0);

glVertex2f(145.0,340.0);

glVertex2f(150.0,350.0);

glVertex2f(60.0,350.0);

glEnd();

glColor3f(0.75,0.85,0.65);//cabinet

glBegin(GL_LINE_LOOP);

glVertex2f(60.0,355.0);

glVertex2f(150.0,355.0);

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 10


Encryption and decryption. 2018

glVertex2f(150.0,370.0);

glVertex2f(60.0,370.0);

glEnd();

glColor3f(0.75,0.85,0.65);

glBegin(GL_LINE_LOOP);

glVertex2f(75.0,380.0);

glVertex2f(135,380.0);

glVertex2f(135.0,430.0);

glVertex2f(75.0,430.0);

glEnd();

glColor3f(0.7,0.8,0.6);

glBegin(GL_QUADS);

glVertex2f(80.0,385.0);

glVertex2f(130.0,385.0);

glVertex2f(130.0,425.0);

glVertex2f(80.0,425.0);

glEnd();

glColor3f(0.75,0.85,0.65);

glBegin(GL_LINES);

glVertex2f(90.0,370.0);

glVertex2f(90.0,380.0);

glVertex2f(120.0,370.0);

glVertex2f(120.0,380.0);

glEnd();

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 11


Encryption and decryption. 2018

void computer_dest()

glColor3f(0.75,0.85,0.65);//keyboard

glBegin(GL_QUADS);

glVertex2f(545.0,525.0);

glVertex2f(635.0,525.0);

glVertex2f(640.0,535.0);

glVertex2f(550.0,535.0);

glEnd();

glColor3f(0.75,0.85,0.65);//cabinet

glBegin(GL_LINE_LOOP);

glVertex2f(550.0,540.0);

glVertex2f(640.0,540.0);

glVertex2f(640.0,555.0);

glVertex2f(550.0,555.0);

glEnd();

glColor3f(0.75,0.85,0.65);//cpu

glBegin(GL_LINE_LOOP);

glVertex2f(565.0,565.0);

glVertex2f(625,565.0);

glVertex2f(625.0,615.0);

glVertex2f(565.0,615.0);

glEnd();

glColor3f(0.7,0.8,0.6);//monitor

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 12


Encryption and decryption. 2018

glBegin(GL_QUADS);

glVertex2f(570.0,570.0);

glVertex2f(620.0,570.0);

glVertex2f(620.0,610.0);

glVertex2f(570.0,610.0);

glEnd();

glColor3f(0.75,0.85,0.65);

glBegin(GL_LINES);

glVertex2f(580.0,555.0);

glVertex2f(580.0,565.0);

glVertex2f(610.0,555.0);

glVertex2f(610.0,565.0);

glEnd();

void cipher()

glColor3f(0.0f,0.0f,1.0f);

glPushMatrix();

glScalef(40,20,.5);

glTranslatef(3,14,0);

glutWireCube(2);

output(-1,0," CIPHER",2);

glPopMatrix();

void message_data()

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 13


Encryption and decryption. 2018

glColor3f(1.0f,1.0f,0.0f);

glPushMatrix();

glScalef(40,20,.5);

glTranslatef(3,14,0);

glutWireCube(2);

output(-1,0," MESSAGE",2);

glPopMatrix();

void message_key(void)

glColor3f(0.0f,1.0f,0.0f);

glPushMatrix();

glScalef(20,20,.5);

glTranslatef(3,14,0);

glutWireCube(2);

output(-1,0,"KEY",2);

glPopMatrix();

void encryption()

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);

//glPushMatrix();

// glColor3f(0.25,0.15,0.36);

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 14


Encryption and decryption. 2018

glColor3f(1.0f,1.0f,1.0f);

output(150,640,"ENCRYPTION AND DECRYPTION PROCESS",2);

//glPopMatrix();

glColor3f(1.0f,1.0f,1.0f);

glPushMatrix();

glTranslatef(-30,200,0);

output(75,440,"Sender",2);

computer();

glPopMatrix();

glColor3f(1.0f,1.0f,1.0f);

glPushMatrix();

output(565,630,"Receiver",2);

computer_dest();

glPopMatrix();

glColor3f(1.0f,1.0f,1.0f);

glPushMatrix();

glScalef(70,40,.5);

glTranslatef(1.5,7,0);

glutWireCube(2);

glPopMatrix();

if(phy_header_angle1!=100)

glPushMatrix();

glTranslatef(0,-phy_header_angle1,0);

glPushMatrix();

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 15


Encryption and decryption. 2018

glTranslatef(0,-arrow_angle,0);

glTranslatef(0,150,0);

message_data();

glPopMatrix();

glPushMatrix();

glTranslatef(phy_header_angle,0,0);

glTranslatef(-100,0,0);

message_key();

glPopMatrix();

glPopMatrix();

glPushMatrix();

glTranslatef(movement_angle1,0,0);

if(phy_header_angle1==100)

glPushMatrix();

if(movement_angle1>=420)

// glRotatef(180,0,1,0);

glTranslatef(0,rev_analog_sig_angle,0);

glTranslatef(0,-analog_sig_angle,0);

if(rev_analog_sig_angle!=100)

cipher();

glPopMatrix();

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 16


Encryption and decryption. 2018

glPopMatrix();

glPushMatrix();

glTranslatef(movement_angle1,0,0);

if(phy_header_angle1==100)

glPushMatrix();

glScalef(50,30,.5);

glTranslatef(2.5,2.5,0);

glutWireCube(2);

glPopMatrix();

glPopMatrix();

if(rev_analog_sig_angle==100)

glPushMatrix();

glTranslatef(450,rev_phy_header_angle1,0);

glPushMatrix();

//glTranslatef(0,rev_arrow_angle,0);

//glTranslatef(0,0,0);

message_data();

glPopMatrix();

glPushMatrix();

glTranslatef(rev_phy_header_angle,0,0);

glTranslatef(-10,0,0);

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 17


Encryption and decryption. 2018

if(rev_phy_header_angle<200)

message_key();

glPopMatrix();

glPopMatrix();

glColor3f(1.0f,1.0f,1.0f);

glPushMatrix();

glTranslatef(450,0,0);

glScalef(70,40,.5);

glTranslatef(1.5,7,0);

glutWireCube(2);//right layer

glPopMatrix();

animation_encryp();

glFlush();

glutSwapBuffers();

void myinit()

glColor3f(1.0,0.0,0.0);

glPointSize(1.0);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,700.0,0.0,700.0);

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 18


Encryption and decryption. 2018

void display()

glClearColor(0.0,0.0,0.0,0.0);

glClear(GL_COLOR_BUFFER_BIT);

front_page();

glFlush();

glutSwapBuffers();

void key (unsigned char key, int x, int y)

switch(key)

case 'S' :

case 's' :glutDisplayFunc(encryption);

break;

case 'q':

case 'Q':

exit(0);

glutPostRedisplay();

static void menu(int mode)

switch (mode)

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 19


Encryption and decryption. 2018

case FRONTPAGE:glutDisplayFunc(front_page);

break;

case ENCRYPTION:glutDisplayFunc(encryption);

break;

case EXIT: exit(0);

glutPostRedisplay();

int main(int argc, char** argv)

glutInit(&argc,argv);

glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);

glutInitWindowSize(1000,700);

glutInitWindowPosition(0,0);

glutCreateWindow("ENCRYPTION");

glutKeyboardFunc(key);

myinit();

glutDisplayFunc(display);

glutCreateMenu(menu);

glutAddMenuEntry("Front Page", FRONTPAGE);

glutAddMenuEntry("Encryption",ENCRYPTION);

glutAddMenuEntry("Exit", EXIT);

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 20


Encryption and decryption. 2018

glutAttachMenu(GLUT_RIGHT_BUTTON);

glutMainLoop();

4. CODE

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 21


Encryption and decryption. 2018

5. SNAPSHOTS

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 22


Encryption and decryption. 2018

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 23


Encryption and decryption. 2018

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 24


Encryption and decryption. 2018

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 25


Encryption and decryption. 2018

6. CONCLUSION & FUTURE IDEAS

We successfully implemented the Puzzle Slider game with tiles and frame.

The extra features include Player’s name and a clock that starts at the beginning of the game. Also, a
high score list – Hall Of Fame has been included.

To make the high score list permanent, a text file is running at the back end.

6.1 FUTURE IDEAS


Implement texture mapping to map images onto the tiles instead of the current Roman Numerals.

Adding cheat codes like most commercial games, so that the player can enter them and the fully
solved puzzle is displayed. This can also be used to view the effects when a player makes it to the Hall
of Fame.

Give the option of allowing the user to put any image of his choice onto the tiles. This again involves
Texture mapping and image processing.

Implementing different levels with increasing levels of difficulty.

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 26


Encryption and decryption. 2018

REFERENCES

1. Donald Hearn & Pauline Baker: Computer Graphics-OpenGL Version,3rd Edition,


Pearson Education,2011
2. Edward Angel: Interactive computer graphics- A Top Down approach with OpenGL,
5th edition. Pearson Education, 2011
3. M M Raikar, Computer Graphics using OpenGL, Fillip Learning / Elsevier,
Bangalore / New Delhi (2013)

Department of Computer Science and Engg, S.G.B.I.T.Belagavi. Page 27

You might also like