#include<GL/glut.h>
int count=0;
int flag=0;
char a[10];
int j;
void print(int x,int y,int z,char *string){
glRasterPos2f(-0.5,y);
int i;
int len=(int)strlen(string);
for(i=0; i<len;i++){
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,a[i]);
//in built func to print the text bit vz
}
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,0,0);
glPushMatrix();
switch(flag){
case 1: {print(0,0,0,a); break;}
case 2: {print(0,0,0,a); break;}
case 3: {print(0,0,0,a);break;}
case 4: {print(0,0,0,a);break;}
case 5: {print(0,0,0,a);break;}
case 6: {print(0,0,0,a);break;}
case 7: {print(0,0,0,a);break;}
case 8: {print(0,0,0,a);break;}
case 9: {print(0,0,0,a);break;}
case 10: {print(0,0,0,a);break;}
case 11: {print(0,0,0,a);break;}
case 12: {print(0,0,0,a);break;}
case 13: {print(0,0,0,a);break;}
case 14: {print(0,0,0,a);break;}
case 15: {print(0,0,0,a);break;}
case 16: {print(0,0,0,a);break;}
case 17: {print(0,0,0,a);break;}
case 19: {print(0,0,0,a);break;}
case 20: {print(0,0,0,a);break;}
case 21: {print(0,0,0,a);break;}
case 22: {print(0,0,0,a);break;}
case 23: {print(0,0,0,a);break;}
case 24: {print(0,0,0,a);break;}
case 25: {print(0,0,0,a);break;}
case 26: {print(0,0,0,a);break;}
case 27: {print(0,0,0,a);break;}
}
glPopMatrix();
glFlush();
}
void init(){
glClearColor(1,1,1,1);
glColor3f(1,0,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-1,1,-1,1);
}
void keyboard(unsigned char key,int x,int y){
switch(key){
case 'a': {flag=1; a[count]='A';count++; glutPostRedisplay(); break;}
case 'b': {flag=2;a[count]='B'; count++; glutPostRedisplay();break;}
case 'c': {flag=3; a[count]='C';count++; glutPostRedisplay();break;}
case 'd': {flag=4; a[count]='D';count++; glutPostRedisplay();break;}
case 'e': {flag=5;a[count]='E';count++; glutPostRedisplay();break;}
case 'f': {flag=6;a[count]='F';count++; glutPostRedisplay();break;}
case 'g': {flag=7;a[count]='G';count++; glutPostRedisplay();break;}
case 'h': {flag=8;a[count]='H';count++; glutPostRedisplay();break;}
case 'i': {flag=9;a[count]='I';count++; glutPostRedisplay();break;}
case 'j': {flag=10; a[count]='J';count++; glutPostRedisplay();break;}
case 'k': {flag=11; a[count]='K';count++;glutPostRedisplay(); break;}
case 'l': {flag=12; a[count]='L';count++;glutPostRedisplay(); break;}
case 'm': {flag=13; a[count]='M';count++; glutPostRedisplay();break;}
case 'n': {flag=14; a[count]='N';count++;glutPostRedisplay();break;}
case 'o': {flag=15; a[count]='O';count++;glutPostRedisplay(); break;}
case 'p': {flag=16; a[count]='P';count++; glutPostRedisplay();break;}
case 'q': {flag=17; a[count]='Q';count++;glutPostRedisplay(); break;}
case 'r': {flag=18; a[count]='R';count++;glutPostRedisplay(); break;}
case 's': {flag=19; a[count]='S';count++; glutPostRedisplay(); break;}
case 't': {flag=20; a[count]='T';count++; glutPostRedisplay(); break;}
case 'u': {flag=21; a[count]='U';count++; glutPostRedisplay(); break;}
case 'v': {flag=22; a[count]='V';count++; glutPostRedisplay(); break;}
case 'w': {flag=23; a[count]='W';count++; glutPostRedisplay(); break;}
case 'x': {flag=24; a[count]='X';count++; glutPostRedisplay(); break;}
case 'y': {flag=25; a[count]='Y';count++; glutPostRedisplay(); break;}
case 'z': {flag=26; a[count]='Z';count++; glutPostRedisplay(); break;}
case ' ': {flag=27; a[count]=' ';count++; glutPostRedisplay(); break;}
case '1': {exit(0);}
}
}
void main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow(":-(");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
init();
glutMainLoop();
}
No comments:
Post a Comment