A deep creative Elucidations for a problem comes from the depth understanding of the problem. Back bench signifies emancipated minds, only those minds siting at the back bench and meditates deep in to the understanding of the problems will see what has to be seen
An
ancient Chinese legend tells of Emperor Yu-Huang swimming in the mighty
Yellow River (Huang-He). The Emperor sought solitude at the river edge
and as he gazed into the water he saw the turtle at his feet. Emperor Yu
knew it was the same turtle he had seen formed by a pattern of stars in
the night sky each night before he went to bed. The Emperor noticed the
special pattern on the turtle's back and realized it was the Divine
Turtle. Another
version of the legend tells of the yellow river flooding and the
sacrifices the people made to the river in an attempt to calm its anger.
Each time an offering was made, a turtle emerged from the river and
walked onto the riverbank and around the offering, but the river
remained angry. The Emperor Fu Xi noticed the strange pattern on the
turtle's back and realized it was a 3 x 3 grid pattern with dots in the
center of the squares. The sum of the number of dots in each row added
to 15. The Emperor realized that was the number of offerings they had to
make to the angry flooding river with the hope of making it happy and
peaceful again. Snapshots and user guide. click on the image to enlarge.
Home page where the Application is available online
This main function is capable of handling the
arguments given in the argument list at the command prompt as we have used variable
‘argc’ for total number of arguments and ‘argv’ for the array of argument list.
Main function initializes the Display Mode, Window
Size and position. Then it invokes the display function within glutDisplayFunc()
as the call back function.
void main(int argc, char* argv[])
{
glutInit(&argc,
argv);
glutInitDisplayMode(GLUT_DOUBLE
| GLUT_RGB);
glutInitWindowSize(1346,728);
glutInitWindowPosition(0,0);
glutCreateWindow("Traffic
signal");
glutDisplayFunc(mydisplay);
/*call
back functions*/
glutKeyboardFunc(myKeyboard);
glutMouseFunc(myMouse);
myinit();
glutMainLoop();
}
2.
Keyboard function
This
Interactive function is invoked at the main program within glutKeyboardFunc()
and it is repeatedly called during the execution of the program and hence
handles the keyboard interrupts from the users.
When a key is
been pressed the ASCII code of the key and the position of the screen pointer
at the time of interruption will be sent to the function.
void myKeyboard(
unsigned char key, int x, int y )
{
switch(key)
{
case 13:
if(flag==1)
{
flag=2;
mydisplay();
}
if(flag==0) //Ascii of 'enter' key is 13
{
flag=1;
mydisplay();
} break;
case 'l': control_keyl=key;
p=0;q=0;r=1;break;
case 'r': control_keyr=key;
p=0;q=0;r=1;break;
case 's': mydisplay();break;
case 'h': flag=1;mydisplay(); break;
default: break;
}
}
3.
Mouse function
This
Interactive function is invoked at the main program within glutMoseFunc() and
it is repeatedly called during the execution of the program and hence handles
the Mouse interrupts from the users.
When a button
is been pressed the identity of the button and the state of the button and the
position of the screen pointer at the time of interruption will be sent to the
mouse function.
void
myMouse(int button,int state,int x,int y)
{
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
traffic_regulator=0;
p=1;q=0;r=0;}
if(button==GLUT_RIGHT_BUTTON &&
state==GLUT_DOWN)
{
traffic_regulator=0;
p=0;q=1;r=0;
}
if(button==GLUT_RIGHT_BUTTON && state==GLUT_UP)
{
traffic_regulator=1;
p=0;q=0;r=1;
}
glutPostRedisplay();
}
4.
Displaying text on the screen
The setFont() function is used to set the type of the font we are using.
The drawstring() function takes the position of the string to be displayed on
the screen in X Y Z coordinates and the string to display.
glClearColor(0.15,0.1,0.01,0);/*background
for cover page*/
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,0,0);
drawstring(450.0,700.0,0.0,"BEARYS
INSTITUTE OF TECHNOLOGY ");
glFLush();
}
5. Display functions
We have used three display functions in this program
the first one that is the myDisplay function is called in the main program
using glutDisplayFunc() call back function. The mydisplay function controls the
displaying of the front screen, help screen or the display function.
The second display function that is display() calls
the objects like road(),car() etc. According to the order that we have written
hence it indirectly handles the depth information.
void
mydisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
if(flag==0)
frontscreen
();
if(flag==1)
helpscreen();
if(flag==2)
display();
glutSwapBuffers();
}
glutPostRedisplay();
}
void
display(void)
{
if(traffic_regulator)
glutTimerFunc(50,update,0);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(red,green,blue,0);/*back
ground for sky*/
road();
bus();
signal();
car();
car2();
glFlush();
}
6. Update
functions Update function is used for the
transformation of the objects this function is invoked in display function
inside glutTimerFunc(50,update,0). This function calls the update every 50
mille seconds hence the variable ‘a’, ’b’ are all modified then when we
translate the object with this points we will see the animation effect.