NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include<stdio.h>
#include<GL/glut.h>
#include<string.h>
#include<stdlib.h>
#define monitor 1
#define upbox 2
#define boxbuses 3
#define fi 4
#define keys 5
float x=-18,y=34;
int i,flag=0,w=0,q=5,r=0,s=0,u=0,flag1=0,ff2=1,k=0;
float tr=0.0,t=0.0,t2=0.0,t3=0.0,t4=0.0,t1=0.0,t5=0.0;
float tr1=0.0;
float tr2=0.0;
float tr3=0.0;
float tr4=0.0;
float tr5=0.0;
void animated();
void anim();
void polygona(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4)
{
glBegin(GL_POLYGON);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
glVertex2f(x3,y3);
glVertex2f(x4,y4);
glEnd();
glFlush();
}
void polygon3a(int x1,int y1,int z1,int x2,int y2,int z2,int x3,int y3,int z3,int x4,int y4,int z4)
{
glBegin(GL_POLYGON);
glVertex3f(x1,y1,z1);
glVertex3f(x2,y2,z2);
glVertex3f(x3,y3,z3);
glVertex3f(x4,y4,z4);
glEnd();
glFlush();
}
void quada(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4)
{
glBegin(GL_QUAD_STRIP);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
glVertex2f(x3,y3);
glVertex2f(x4,y4);
glEnd();
glFlush();
}
void bitmap_output(int x, int y, char *string, void *font)
{
int len, i;

glRasterPos2f(x, y);
len = (int) strlen(string);
for (i = 0; i < len; i++) {
glutBitmapCharacter(font, string[i]);
}
}
void textures()
{
glColor3f(1.0,0.0,0.0);
bitmap_output(-10, 45, "CLIENT SERVER SIMULATION",GLUT_BITMAP_HELVETICA_18);
bitmap_output(-31.0,-3.0,": Controls",GLUT_BITMAP_HELVETICA_18);
bitmap_output(23.5,-3.0," : Controls",GLUT_BITMAP_HELVETICA_18);
bitmap_output(23.5,-38," : DATA",GLUT_BITMAP_HELVETICA_18);
bitmap_output(-31.0,-38,": DATA",GLUT_BITMAP_HELVETICA_18);
bitmap_output(27,40,"SERVER",GLUT_BITMAP_HELVETICA_18);
glFlush();
}
void ctrline()
{
glLineWidth(1.5);
glBegin(GL_LINES);
glVertex3f(-22,34.0,10.0);
glVertex3f(-20,34.0,10.0);
glEnd();
}
void file()
{
glNewList(fi,GL_COMPILE_AND_EXECUTE);

glColor3f(1.0,1.0,1.0);
//polygona(-17.5,31.5,-17.5,34.5,-16.0,34.5,-16.0,31.5);
glBegin(GL_POLYGON);
glVertex2f(-17.5,31.5);
glVertex2f(-17.5,34.5);
glVertex2f(-16.0,34.5);
glVertex2f(-16.0,31.5);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(-16.3,32);
glVertex2f(-17.3,32);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(-16.3,33);
glVertex2f(-17.2,33);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(-16.3,34);
glVertex2f(-17.3,34);
glEnd();
glEndList();
}
void disp()
{
//left side cpu........
glColor3f(0.7,0.65,0.83); //stand
glBegin(GL_POLYGON);
glVertex3f(-43.50,26.0,-10.0);
glVertex3f(-43.50,23.0,-10.0);
glVertex3f(-40.0,23.0,-10.0);
glVertex3f(-40.0,26.0,-10.0);
glEnd();
glColor3f(0.2,0.3,.4);
glBegin(GL_POLYGON); //stand
glVertex2f(-44.5,23.0);
glVertex2f(-39.0,23.0);
glVertex2f(-39.0,22.0);
glVertex2f(-44.5,22.0);
glEnd();
//polygona(-44.5,23.0,-39.0,23.0,-39.0,22.0,-44.5,22.0);
glBegin(GL_QUAD_STRIP);
glColor3f(0.2,0.3,0.4);
glVertex2f(-48.0,25.0);
glVertex2f(-36.0,25.0);
glVertex2f(-36.0,38.5);
glVertex2f(-48.0,38.5);
glVertex2f(-48.0,38.5);
glVertex2f(-48.0,25.0);
glVertex2f(-36.0,38.5);
glVertex2f(-36.0,25.0);
glEnd();
glColor3f(0.6,0.73,0.83);
polygona(-47.0,26.0,-37.0,26.0,-37.0,38.0,-47.0,38.0);//monitor

//keyboard
glColor3f(0.3,0.5,0.6);
polygona(-48.0,17.0,-36.0,17.0,-37.0,21.0,-47.0,21.0);

glColor3f(0.3,0.3,0.6);
polygona(-48.0,17.0,-36.0,17.0,-36.0,16.0,-48.0,16.0);

glColor3f(0.0,0.0,0.1);
polygon3a(-27.0,15.0,0.0,-19.0,15.0,0.0,-19.0,40.0,0.0,-27.0,40.0,0.0);
glColor3f(0.0,2.0,4.0);
polygon3a(-30.0,12.0,3.0,-22.0,12.0,3.0,-19.0,15.0,0.0,-27.0,15.0,0.0);
glColor3f(0.2,0.4,0.0);
polygon3a(-30.0,12.0,3.0,-26.0,15.0,0.0,-26.0,40.0,0.0,-30.0,37.0,3.0);
glColor3f(0.0,0.0,0.0);
polygon3a(-22.0,12.0,3.0,-22.0,37.0,3.0,-19.0,40.0,0.0,-19.0,15.0,0.0);
glColor3f(0.3,0.3,0.3);
polygon3a(-30.0,37.0,3.0,-22.0,37.0,3.0,-19.0,40.0,0.0,-27.0,40.0,0.0);
glColor3f(0.0,0.0,0.0);
polygon3a(-30.0,12.0,3.0,-22.0,12.0,3.0,-22.0,37.0,3.0,-30.0,37.0,0.0);
glBegin(GL_LINES);
glColor3f(0.8,0.7,0.6);
glVertex3f(-23.0,33.0,3.0);
glVertex3f(-23.0,32.5,3.0);
glVertex3f(-23.0,32.5,3.0);
glVertex3f(-23.5,32.5,3.0);
glVertex3f(-23.5,32.5,3.0);
glVertex3f(-23.5,33.0,3.0);
glVertex3f(-23.5,33.0,3.0);
glVertex3f(-23.0,33.0,3.0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.7,0.63,0.84);
glVertex3f(-29.0,35.0,3.0);
glVertex3f(-23.0,35.0,3.0);
glVertex3f(-23.0,35.0,3.0);
glVertex3f(-23.0,34.0,3.0);
glVertex3f(-23.0,34.0,3.0);
glVertex3f(-29.0,34.0,3.0);
glVertex3f(-29.0,34.0,3.0);
glVertex3f(-29.0,35.0,3.0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.7,0.6,0.8);
glVertex3f(-26.0,19.0,3.0);
glVertex3f(-27.0,19.0,3.0);
glVertex3f(-27.0,19.0,3.0);
glVertex3f(-27.0,18.0,3.0);
glVertex3f(-27.0,18.0,3.0);
glVertex3f(-26.0,18.0,3.0);
glVertex3f(-26.0,18.0,3.0);
glVertex3f(-26.0,19.0,3.0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.5,0.7,0.8);
glVertex3f(-22.0,12.0,3.0);
glVertex3f(-22.0,37.0,3.0);
glVertex3f(-22.0,37.0,3.0);
glVertex3f(-19.0,40.0,3.0);
glVertex3f(-19.0,40.0,3.0);
glVertex3f(-19.0,15.0,3.0);
glVertex3f(-19.0,15.0,3.0);
glVertex3f(-22.0,12.0,3.0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.5,0.7,0.8);
glVertex3f(-30.0,37.0,3.0);
glVertex3f(-22.0,37.0,3.0);
glVertex3f(-22.0,37.0,3.0);
glVertex3f(-19.0,40.0,3.0);
glVertex3f(-19.0,40.0,3.0);
glVertex3f(-27.0,40.0,3.0);
glVertex3f(-27.0,40.0,3.0);
glVertex3f(-30.0,37.0,3.0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.5,0.7,0.8);
glVertex3f(-30.0,12.0,3.0);
glVertex3f(-22.0,12.0,3.0);
glVertex3f(-22.0,12.0,3.0);
glVertex3f(-22.0,37.0,3.0);
glVertex3f(-22.0,37.0,3.0);
glVertex3f(-30.0,37.0,3.0);
glVertex3f(-30.0,37.0,3.0);
glVertex3f(-30.0,12.0,3.0);
glEnd();
//cpu ends.......
glFlush();
glEndList();

//server starts
glColor3f(0.0,0.0,0.1);
polygon3a(25.0,20.0,0.0,40.0,17.0,0.0,40.0,42.0,0.0,25.0,45.0,0.0);
polygon3a(25.0,20.0,0.0,40.0,17.0,0.0,20.0,15.0,5.0,35.0,12.0,5.0);
polygon3a(25.0,20.0,0.0,25.0,45.0,0.0,20.0,40.0,5.0,20.0,15.0,5.0);
polygon3a(20.0,40.5,0.0,25.0,45.0,0.0,20.0,40.0,5.0,20.0,15.0,5.0);
polygon3a(20.0,40.0,5.0,25.0,45.0,0.0,40.0,42.0,0.0,35.0,37.0,5.0);
polygon3a(35.0,12.0,5.0,35.0,37.0,5.0,40.0,42.0,0.0,40.0,17.0,0.0);
polygon3a(20.0,15.0,5.0,35.0,12.0,5.0,35.0,37.0,5.0,20.0,40.0,5.0);
//lines at the front and side
glColor3f(0.3,0.3,0.3);
polygon3a(20.0,40.0,5.0,20.0,37.0,5.0,35.0,34.0,5.0,35.0,37.0,5.0);
polygon3a(40.0,39.0,0.0,40.0,42.0,0.0,35.0,37.0,5.0,35.0,34.0,5.0);
polygon3a(20.0,36.0,5.0,20.0,33.0,5.0,35.0,30.0,5.0,35.0,33.0,5.0);
polygon3a(40.0,38.0,0.0,40.0,35.0,0.0,35.0,30.0,5.0,35.0,33.0,5.0);
polygon3a(20.0,32.0,5.0,20.0,29.0,5.0,35.0,26.0,5.0,35.0,29.0,5.0);
polygon3a(40.0,31.0,0.0,40.0,34.0,0.0,35.0,29.0,5.0,35.0,26.0,5.0);
polygon3a(20.0,28.0,5.0,20.0,25.0,5.0,35.0,22.0,5.0,35.0,25.0,5.0);
polygon3a(40.0,27.0,0.0,40.0,30.0,0.0,35.0,25.0,5.0,35.0,22.0,5.0);
polygon3a(20.0,24.0,5.0,20.0,21.0,5.0,35.0,18.0,5.0,35.0,21.0,5.0);
polygon3a(40.0,23.0,0.0,40.0,26.0,0.0,35.0,21.0,5.0,35.0,18.0,5.0);
polygon3a(20.0,20.0,5.0,20.0,15.0,5.0,35.0,12.0,5.0,35.0,17.0,5.0);
polygon3a(40.0,17.0,5.0,40.0,22.0,5.0,35.0,17.0,5.0,35.0,12.0,5.0);
//Buses
glEnable(GL_BLEND);
glColor4f(0.6,0.7,0.8,0.6);
quada(-19.0,35.0,-19.0,33.0,20.0,35.0,20.0,33.0);
quada(-19.0,16.0,-19.0,20.0,20.0,16.0,20.0,20.0);
glDisable(GL_BLEND);
//server ends
//upbox
glNewList(upbox,GL_COMPILE_AND_EXECUTE);
glColor3f(0.6,0.5,0.4);
polygon3a(25.0,2.0,0.0,25.0,-3.0,0.0,35.0,-3.0,0.0,35.0,2.0,0.0);
glColor3f(0.4,0.5,0.3);
polygon3a(23.0,-5.0,5.0,33.0,-5.0,5.0,25.0,-3.0,0.0,25.0,-3.0,5.0);
glColor3f(0.4,0.5,0.3);
polygon3a(25.0,2.0,0.0,25.0,-3.0,0.0,23.0,-5.0,5.0,23.0,0.0,5.0);
glColor3f(0.7,0.8,0.6);
polygon3a(23.0,0.0,5.0,33.0,0.0,5.0,35.0,2.0,0.0,25.0,2.0,0.0);
glColor3f(0.7,0.7,0.6);
polygon3a(33.0,0.0,5.0,33.0,-5.0,5.0,35.0,-3.0,0.0,35.0,2.0,5.0);
glColor3f(0.3,0.5,0.4);
polygon3a(23.0,-5.0,5.0,33.0,-5.0,5.0,33.0,0.0,5.0,23.0,0.0,5.0);
glEndList();
glPushMatrix();
glScalef(0.0,0.5,0.0);
glCallList(2);
glPopMatrix();
glPushMatrix();
glTranslatef(-55.0,0.0,0.0);
glCallList(2);
glPopMatrix();
glPushMatrix();
glTranslatef(-55.0,-35.0,0.0);
glCallList(2);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,-35.0,0.0);
glCallList(2);
glPopMatrix();

//buses for boxes
glNewList(boxbuses,GL_COMPILE_AND_EXECUTE);
glEnable(GL_BLEND);
glColor4f(0.6,0.7,0.8,0.5);
glBegin(GL_QUAD_STRIP);
glVertex2f(-22.0,-1.0);
glVertex2f(-22.0,-5.0);
glVertex2f(23.0,-1.0);
glVertex2f(23.0,-5.0);
glEnd();
glDisable(GL_BLEND);
glEndList();
glPushMatrix();
glTranslatef(0.0,-35.0,0.0);
glCallList(3);
glPopMatrix();
}
void display()
{

if(k==0)
{
glClear(GL_COLOR_BUFFER_BIT/*|GL_DEPTH_BUFFER_BIT*/ );
glPushMatrix();
glColor3f(1.0,0.0,0.0);
bitmap_output(-22, 40, "COMPUTER GRAPHICS MINI PROJECT",GLUT_BITMAP_TIMES_ROMAN_24);
bitmap_output(0, 30, "ON",GLUT_BITMAP_TIMES_ROMAN_24);
bitmap_output(-25, 20, "WELCOME",GLUT_BITMAP_TIMES_ROMAN_24);
bitmap_output(-10, 20, "TO",GLUT_BITMAP_TIMES_ROMAN_24);
bitmap_output(-04, 20, "CLIENT SERVER SIMULATION",GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(1.0,1.0,1.0);
bitmap_output(0, 0, "BY",GLUT_BITMAP_TIMES_ROMAN_24);
bitmap_output(-20, -10, "Nikhil AR 1BY15CS056",GLUT_BITMAP_TIMES_ROMAN_24);
bitmap_output(-20, -20, "Pavan H 1BY15CS061",GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,0.0,0.0);
bitmap_output(-20, -30, "PROJECT GUIDE : MR.SHANKAR R",GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,0.0);
bitmap_output(-20, -40, "Press Enter to continue.......",GLUT_BITMAP_HELVETICA_18);
glPopMatrix();
glutSwapBuffers();
glFlush();
}
else{
glClear(GL_COLOR_BUFFER_BIT/*|GL_DEPTH_BUFFER_BIT*/ );
glColor3f(0.0,0.0,0.0);
glPushMatrix();
glColor3f(1.0,1.0,0.0);
glTranslatef(0.0+tr,0.0,10.0);
ctrline();
glPopMatrix();
glPushMatrix();
glColor3f(0.0,1.0,0.0);
glTranslatef(47.0-tr1,0.0,10.0);
ctrline();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,0.0,1.0);
glTranslatef(-3.0+tr2,-15.0,10.0);
file();
glPopMatrix();
glPushMatrix();
glTranslatef(-5.0+tr2,-15.0,0.0);
glCallList(fi);
glPopMatrix();
glPushMatrix();
glTranslatef(-7.0+tr2,-15.0,0.0);
glCallList(fi);
glPopMatrix();
glPushMatrix();
glTranslatef(-9.0+tr2,-15.0,0.0);
glCallList(fi);
glPopMatrix();
glLineWidth(.1);

//R E T R I E V E A D A T A

if(flag==1)
{
glPushMatrix();
glTranslatef(-5.0+t,-36.5,0.0);
glColor3f(1.0,1.0,1.0);
ctrline();
glPopMatrix();
glPushMatrix();
glTranslatef(41.0-t1,-71,0.0);
glCallList(fi);
glPopMatrix();
glPushMatrix();
if(flag==1 && r<5)r++;
glTranslatef(r,r,0);

glPopMatrix();
}
// S T O R E S D A T A
if(flag==2)
{
glPushMatrix();
glTranslatef(-6.0+t2,-36.5,0.0);
glColor3f(1.0,1.0,1.0);
ctrline();
glPopMatrix();
glPushMatrix();
glTranslatef(-5+t3,-71,0.0);
glCallList(fi);
glPopMatrix();
glPushMatrix();
if(flag==2 && s<5) s++;
glTranslatef(s,s,0);

glPopMatrix();

}
disp();
textures();
glColor3f(1.0,0.0,0.0);
if(tr1>=48&&flag==0)
{
bitmap_output(-46,32,"DATA",GLUT_BITMAP_HELVETICA_12);
}
if(tr2>=48&&flag==0)
{
bitmap_output(-46,32,"DATA SENT",GLUT_BITMAP_HELVETICA_12);
flag1=1;
}
if(t4<53&&flag==2){
bitmap_output(-46,32,"SENDING",GLUT_BITMAP_HELVETICA_12);
}
else if(flag==2&&t4>53){
bitmap_output(-46,32,"DATA SENT",GLUT_BITMAP_HELVETICA_12);
}
if(t4<53&&flag==1){
bitmap_output(-46,32,"RETRIVING",GLUT_BITMAP_HELVETICA_12);
}
else if(t4>53&&flag==1){
bitmap_output(-46,32,"RECIEVED",GLUT_BITMAP_HELVETICA_12);
}
//glPopMatrix();
glPushMatrix();
if(w<5) w++;
glTranslatef(w,w,0);
bitmap_output(-18,34.5,"COMMANDS",GLUT_BITMAP_HELVETICA_12);
glPopMatrix();
glPushMatrix();
if(tr>=43 && w>=5 && q>2)q--;
glTranslatef(q,q,0);
bitmap_output(7,22,"RESPONSE",GLUT_BITMAP_HELVETICA_12);
glPopMatrix();
glutSwapBuffers();
glFlush();
}
}
void init()
{
glClearColor(0.0,0.8,1.0,0.0);
glOrtho(-50,50,-50,50,-50,50);
}
void animate()
{
if(tr<48)
tr+=0.2;
else if(tr>=48 && tr1<48)
tr1+=0.2;
else if(tr1>=48 && tr2<48)
tr2+=0.1;
else if(tr2>=48 && tr3<48)
tr3+=0.1;
glutPostRedisplay();
}
void anim()
{
if(t<53)
t+=0.2;
else if(t>=53 && t1<53)
t1+=0.2;
//S T O R E
else if(t2<53)
t2+=0.2;
else if(t2>=53 && t3<53)
t3+=0.2;
//L I S T
else if(t4<53)
t4+=0.2;
else if(t4>=53 && t5<53)
t5+=0.2;
glutPostRedisplay();
}
void mymenu(int id)
{
switch(id)
{
case 1:
glutIdleFunc(animate);
break;
case 2:if(flag1){
flag=1;
glutIdleFunc(anim);
t=t1=t2=t3=t4=t5=0;
}
break;
case 3: if(flag1){
flag=2;
glutIdleFunc(anim);
t=t1=t2=t3=t4=t5=0;
}
break;
case 4:exit(0);
}
}
void keyboard (unsigned char key, int x, int y)
{
if(key==13)
k=1;
glutPostRedisplay();
}
void myReshape(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-1.0,1.0,-1.0*(GLfloat)h/(GLfloat)w,
1.0*(GLfloat)h/(GLfloat)w,-10.0,10.0);
else
glOrtho(-1.0*(GLfloat)w/(GLfloat)h,
1.0*(GLfloat)w/(GLfloat)h,-1.0,1.0,-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
glutPostRedisplay();
}
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB/*|GLUT_DEPTH*/);
glutInitWindowSize(1000,1000);
glutInitWindowPosition(0,0);
glutCreateWindow("server");
glutDisplayFunc(display);
glutReshapeFunc(myReshape);
glutKeyboardFunc(keyboard);
glutCreateMenu(mymenu);
glutAddMenuEntry("START",1);
glutAddMenuEntry("START 1:RETRIVE",2);
glutAddMenuEntry("START 2:STORE",3);
glutAddMenuEntry("EXIT",4);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
init();
glutMainLoop();
return 0;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.