some help regarding flickering

I have create a game in glut. It was flickering so I used GLUT_DOUBLE and then it was showing the transparent window then I used glutSwapBuffers(); then it was showing game without flickering but there was no movement in game i.e. the keystrokes are not working. What should I do now??

Could you paste the relevant code here?

    void display(void)
    {
    	glClear (GL_COLOR_BUFFER_BIT);
    	arena();
    	start();			//start the game
    	comments();
    	next_level();
    	glutSwapBuffers();
    }


void init() {
        glClearColor (0.0, 0.0, 0.0, 0.0);
//    	glEnable(GL_DEPTH_TEST);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glShadeModel(GL_SMOOTH);
        glOrtho(-1000.0, 1000.0, -1000.0, 1000.0, -1000.0, 1000.0);
    	glutDisplayFunc(display);
    	glutKeyboardFunc(processNormalKeys);
    	glutSpecialFunc(pressKey);
    	

    }
    int  main(int argc, char** argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
  //      glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize (700,700);
        glutInitWindowPosition (100,-100);
        glutCreateWindow ("BLASTERBALL 1.0");
        init ();
        glutMainLoop();
        return 0;
    	
    }

please help someone!!!


glutDisplayFunc(display);
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(pressKey);

for a start, all of the above functions should be in your main function (before glutMainLoop();), NOT your init function.

also, why are you using glLoadIdentity(); in your init function?

I am new to this. I saw this on some site. What should I do here instead?

did moving the mouse and key functions to the main function resolve the issue.

from what i can see i your code, the glLoadIdentity() call isnt needed, thats all.

no its still same. The keystrokes are not working with GLUT_DOUBLE and glutSwapBuffer()

keep the functions mentioned in the main function, but remove the glLoadIdentity(); call

see if that helps.

dale

i did all those thing but still the issue is same.

I am stuck please help me out someone.

Ok, Number 1, im trying to be patient with you, but you have absolutely no patience whatsoever. I am finding you a little rude. People will help you out as and when they can, begging will get you no where.

Number 2, please post all of your code.

I didn’t mean it that way. I am really sorry for that.

    #define GLUT_DISABLE_ATEXIT_HACK
   
   
    #include<string>
   
    #include<vector>
    #include <stdlib.h>
    #include <GL/glut.h>
    #include <math.h>
    #include <GL/gl.h>
    #include<stack>
    
    
    #define RESUME 1
    #define PAUSE 2
    #define INCREASE 3
    #define DECREASE 4
    #define REVERSE 5
    #define RESTART 6
    #define NORMAL1 7
    #define POWER 8
    #define NEXT 9
    #define QUIT 10
    
    using namespace std;
    
    int flag=0;
    int flag1=0;
    int flag2=0;
    int flag3=0;
    int x1=0;
    int y3=-835;
    int x2=-925;
    int y2=100;
    int xc=0;
    int yc=0;
    int TIMER_MS = 10;
    const float root=1/1.4142;
    int a=-150;
    int b=-900;
    int c=150;
    int d=-850;
    int r=50;
    const float PI = 3.1415926535f;
    float NORMAL;
    float ANGLE=0.75*PI; 
    int rad=10;
    int temp2=rad;
    int score1=-500;
    int bricks;
    int bricks1;
    int level=1;
    int life=3;
    int s=-1;
    int count=0;
    int font=(int)GLUT_BITMAP_TIMES_ROMAN_24 ;
    int font1=(int)GLUT_BITMAP_TIMES_ROMAN_10 ;
    int font2=(int)GLUT_BITMAP_HELVETICA_18 ;
    bool m=true;
    bool enter=false;
    bool power=false;
    bool start1=true;
    int condition=0;
    int when=0;
    int xy=1;
    double boundry=(rad/1.4142)+1;
    int specialKey;
    int sensitivity=100;
    char gameModeString[40] = "640x480";
    char currentMode[80];
    
    float rBall=0.0,gBall=1.0,bBall=1.0;
    float rBar=0.0,gBar=0.0,bBar=1.0;
    float rBrick=0.0,gBrick=0.0,bBrick=0.0;
    float rButton=1.0,gButton=1.0,bButton=0.0;
    float rBackground=1,gBackground=1,bBackground=1;
    float rComments=1,gComments=0,bComments=0;
    float rScore=1,gScore=1,bScore=1;
    float rSelected=0,gSelected=1,bSelected=1;
    float rTouched=0,gTouched=0,bTouched=1;
    
    void renderBitmapCharacher(float x, float y, void *font,char *string);
    void processNormalKeys(unsigned char key, int , int );
    void print_score(int );
    void init();
    
    vector< pair < pair <int ,int >,pair<int ,int > > > temp,temp1;
    vector < vector< pair < pair <int ,int >,pair<int ,int > > > > input(5);
    stack < pair < pair <int ,int >,pair<int ,int > > > touch_finder;
    pair < pair <int ,int >,pair<int ,int > > ptouch;
    
    
    
   													
    void print(int xl,int yl,int xh,int yh){
        glBegin(GL_POLYGON); //create the background
    	glVertex2f(xl,yl);
        glVertex2f(xh,yl);
        glVertex2f(xh,yh);
        glVertex2f(xl,yh);
    	glEnd();
    	glFlush();
    	glColor3f(rBackground,gBackground,bBackground); // Background color
    	glBegin(GL_LINE_LOOP);     // create the bricks boundary
    	glVertex2f(xl,yl);
    	glVertex2f(xh,yl);
    	glVertex2f(xh,yh);
    	glVertex2f(xl,yh);
    	glEnd();
    	glFlush(); 
    }
    void make(int xl,int yl,int xh,int yh){     // create the control panel
    	
    	glBegin(GL_POLYGON);
    	glVertex2f(xl,yl);
    	glVertex2f(xh,yl);
    	glVertex2f(xh,yh);
    	glVertex2f(xl,yh);
    	glEnd();
    	glFlush();
    }
    void make_boundry(int xl,int yl,int xh,int yh){ // create the boundary in control panel
    	
    	glBegin(GL_LINE_LOOP);
    	glVertex2f(xl,yl);
    	glVertex2f(xh,yl);
    	glVertex2f(xh,yh);
    	glVertex2f(xl,yh);
    	glEnd();
    	glFlush();
    }
    void make_bricks(void){                        // create the bricks
    	for(int i=0;i<temp.size();i++){
    				glColor3f(rBrick,gBrick,bBrick); 
    			print(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second);
    		}
    }
    float reflect(float angle, float normal) {
    		angle = 2 * normal - PI - angle;
    	
    		while (angle < 0) {
    			angle += 2 * PI;
    		}
    		while (angle > 2 * PI) {
    			angle -= 2 * PI;
    		}
    		return angle;
    	}
    
    
    void start(void){
    
    	if(start1==true){			//this is due to restart either through keyboard or menu function
    		
    		
    		score1=-500;
    		s=-1;
    		life=3;
    		level=1;
    		glColor3f (rBar,gBar,bBar);
    		print(a,b,c,d);
    		
    		power=false;
    		rad=10;
    		ANGLE=0.75*PI;
    		boundry=(rad/1.4142)+1;
    	}
    	else{						//this is due to change of resolution
    		rad=temp2;				
    		s=-1;
    		score1-=500;
    	}
    	int i,j;
    	input[0].clear();
    	for(i=-5;i<=5;i++){
    		for(j=0;j<i+1;j++){
    				input[0].push_back(make_pair(make_pair(-600+i*100,0+75*j),make_pair(-600+i*100+100,75+75*j)));	
    		}
    	}
    	temp=input[0];
    	if(level>=4){
    		temp1.clear();
    		temp.clear();
    	}
    	if((condition==1||condition==2||condition==3||condition==4||condition==6)&&(start1==false)) 
    		temp=temp1;
    	make_bricks();
    	bricks=temp.size();
    	print_score(bricks);
    }
    void print_score(int remaining){
    	
    	string score;
    			int t=bricks-remaining;
    			if(t!=s){
    				score1+=500;
    			int printer;
    			int i=0,abc[20];
    			char a[20];
    			printer=score1;
    			if(printer==0){
    				for(int j=0;j<1;j++)
    				a[j]=char(48);
    			}
    			else{
    			while(printer>0){
    				abc[i]=printer%10;
    				printer/=10;
    				i++;
    			}
    			}
    			for(int j=0;j<i;j++){
    				a[j]=char(abc[i-j-1]+'0');
    				
              }	
    			glColor3f(0.2,0.1,0.1);
    			make(600,590,900,700);
    			glColor3f(rComments,gComments,bComments);
    			renderBitmapCharacher(600,700,(void *)font2,"SCORE: ");
    			glColor3f(rScore,gScore,bScore);
    			renderBitmapCharacher(600,600,(void *)font2,a);
    			}
    			
    			char lvl[1];
    			for(int k=0;k<1;k++)
    				lvl[k]=char(level+48);
    			glColor3f(0.2,0.1,0.1);
    			make(750,375,820,500);
    			
    
    			glColor3f(rComments,gComments,bComments);
    
    			renderBitmapCharacher(600,400,(void *)font2,"LEVEL: ");
    			glColor3f(rScore,gScore,bScore);
    			renderBitmapCharacher(800,400,(void *)font2,lvl);
    			glColor3f(0.2,0.1,0.1);
    			make(820,375,900,500);
    			
    
    			char lyf[4];
    			for(int k2=0;k2<1;k2++)
    				lyf[k2]=char(life+48);;
    			glColor3f(0.2,0.1,0.1);
    			make(775,175,825,300);
    			glColor3f(rComments,gComments,bComments);
    
    			renderBitmapCharacher(600,200,(void *)font2,"LIFE: ");
    			glColor3f(rScore,gScore,bScore);
    			renderBitmapCharacher(800,200,(void *)font2,lyf);
    			s=t;
    }
    void comments(void){
    	glColor3f(rButton,gButton,bButton);					//BUTTON COLORS
       	make_boundry(580,-225,920,-125);	//M
    	make_boundry(580,-125,920,-25);		//P
  
  	
    	make_boundry(-1000,900,-715,1000);	//R
    	make_boundry(-715,900,-520,1000);	//ESC
    	make_boundry(-520,900,-225,1000);	//N
    	make_boundry(-225,900,125,1000);	//SPACEBAR
    	make_boundry(125,900,450,1000);	//UP
    	make_boundry(450,900,1000,1000);	//DOWN
  	
    	glColor3f(rComments,gComments,bComments);					//COMMENT COLOR
    
    	renderBitmapCharacher(-900,910,(void *)font1,"R:Restart");
    	renderBitmapCharacher(-700,910,(void *)font1,"ESC:Quit");
    	renderBitmapCharacher(-500,910,(void *)font1,"N:Next level");
    	renderBitmapCharacher(-200,910,(void *)font1,"SPACEBAR:Pause");
    	renderBitmapCharacher(200,910,(void *)font1,"UP:Inc. Speed");
    	renderBitmapCharacher(500,910,(void *)font1,"DOWN:Dec. Speed");
    	renderBitmapCharacher(600,-100,(void *)font1,"P:PowerBall");
    	renderBitmapCharacher(600,-200,(void *)font1,"M:Normal Ball");
	
}
    void next_level(void){
    	int i,j;
    	input[1].clear();
    	
    	for(i=-2;i<=2;i++)			//level two	
    	{
    		for(j=-2;j<=2;j++)
    		{ 
    			input[1].push_back(make_pair(make_pair(-250+i*100,j*75),make_pair(-250+i*100+100,75*j+75)));
    			input[1].push_back(make_pair(make_pair(-750+i*100,550+j*75),make_pair(-750+i*100+100,75*j+550+75)));
    			input[1].push_back(make_pair(make_pair(150+i*100,550+j*75),make_pair(150+i*100+100,75*j+550+75)));
    			input[1].push_back(make_pair(make_pair(150+i*100,-350+j*75),make_pair(150+i*100+100,75*j-350+75)));
    		}
    	}
    	// level 3
    	input[2].clear();
    	for(i=0;i<15;i++)		//vertical line
    		input[2].push_back(make_pair(make_pair(-200,-600+i*100),make_pair(-200+75,-600+i*100+100)));
    	for(i=0;i<6;i++){     //in right bottommost
    			input[2].push_back(make_pair(make_pair(-50+i*100,-250),make_pair(-50+i*100+100,-250+75)));	
    	}
    	for(i=0;i<3;i++){		
    		input[2].push_back(make_pair(make_pair(50+i*150,-325),make_pair(50+i*150+150,-325+75)));	
    	}
    	for(i=0;i<2;i++){
    		input[2].push_back(make_pair(make_pair(100+i*175,-400),make_pair(100+i*175+175,-400+75)));	
    	}
    	for(i=0;i<1;i++){
    		input[2].push_back(make_pair(make_pair(175+i*200,-475),make_pair(175+i*200+200,-475+75)));	
    	}		
    	for(i=0;i<5;i++){		//in left uppermost
    		for(j=0;j<4;j++){
    				input[2].push_back(make_pair(make_pair(-800+i*100,250+75*j),make_pair(-800+i*100+100,250+75+75*j)));
    		}
    	}
    	for(i=0;i<3;i++)	//in left bottommost 
    			input[2].push_back(make_pair(make_pair(-850+i*100,-500),make_pair(-850+i*100+100,-500+75)));
    	for(i=0;i<3;i++)
    			input[2].push_back(make_pair(make_pair(-850+i*100,-100),make_pair(-850+i*100+100,-100+75)));
    	for(i=0;i<3;i++)
    			input[2].push_back(make_pair(make_pair(-600+i*100,-300),make_pair(-600+i*100+100,-300+75)));
    	for(i=0;i<4;i++)		// in right uppermost
    			input[2].push_back(make_pair(make_pair(0+i*100,650),make_pair(0+i*100+100,650+75)));
    	for(i=0;i<5;i++)
    			input[2].push_back(make_pair(make_pair(180,650-i*100),make_pair(180+75,650-100-i*100)));
    	for(i=0;i<4;i++)
    			input[2].push_back(make_pair(make_pair(0+i*100,75),make_pair(0+i*100+100,75+75)));

    	
    	// level 4
    	input[3].clear();	
    	for(i=0;i<17;i++)
    			input[3].push_back(make_pair(make_pair(-250,-450+i*75),make_pair(-250+100,-450+i*75+75)));
    	for(i=0;i<15;i++){
    			///input[3].push_back(make_pair(make_pair(-350,-375+i*75),make_pair(-350+100,-375+i*75+75)));
    			if(i==12)
    				continue;	
    			input[3].push_back(make_pair(make_pair(-350,-375+i*75),make_pair(-350+100,-375+i*75+75)));
    			input[3].push_back(make_pair(make_pair(-150,-375+i*75),make_pair(-150+100,-375+i*75+75)));
    	}
    	for(i=0;i<10;i++){
    			input[3].push_back(make_pair(make_pair(-450,-300+i*75),make_pair(-450+100,-300+i*75+75)));
    			input[3].push_back(make_pair(make_pair(-50,-300+i*75),make_pair(-50+100,-300+i*75+75)));
    	}
    	for(i=0;i<12;i++){
    			if(i==2 || i==9)
    				continue;
    			input[3].push_back(make_pair(make_pair(-550,-375+i*75),make_pair(-550+100,-375+i*75+75)));
    			input[3].push_back(make_pair(make_pair(50,-375+i*75),make_pair(50+100,-375+i*75+75)));
    	}
    	for(i=0;i<3;i++){
    			input[3].push_back(make_pair(make_pair(-650,-450+i*75),make_pair(-650+100,-450+i*75+75)));
    			input[3].push_back(make_pair(make_pair(150,-450+i*75),make_pair(150+100,-450+i*75+75)));
    	}
    	for(i=0;i<6;i++){
    			if(i==3 || i==2 || i==4)
    				continue;	
    			input[3].push_back(make_pair(make_pair(-650,375+i*75),make_pair(-650+100,375+i*75+75)));
    			input[3].push_back(make_pair(make_pair(150,375+i*75),make_pair(150+100,375+i*75+75)));
    	}
    	for(i=0;i<1;i++){
    			input[3].push_back(make_pair(make_pair(-750,750+i*75),make_pair(-750+100,750+i*75+75)));
    			input[3].push_back(make_pair(make_pair(250,750+i*750),make_pair(250+100,750+i*75+75)));
    	}
    	for(i=0;i<2;i++){
    			input[3].push_back(make_pair(make_pair(-850+i*100,675),make_pair(-850+i*100+100,675+75)));
    			input[3].push_back(make_pair(make_pair(250+i*100,675),make_pair(250+100+i*100,675+75)));
    	}
    	for(i=0;i<10;i++){
    			if(i==4 || i==5 || i==6 || i==7 || i==8 )
    				continue;
    			input[3].push_back(make_pair(make_pair(-950,-75+i*75),make_pair(-950+100,-75+i*75+75)));
    			input[3].push_back(make_pair(make_pair(450,-75+i*75),make_pair(450+100,-75+i*75+75)));
    	}

    	
    		// level 5
    	input[4].clear();
    	for(i=0;i<15;i++)		//horozontal line
    		input[4].push_back(make_pair(make_pair(-950+i*100,-675),make_pair(-950+i*100+100,-675+75)));
    	for(i=0;i<14;i++)		
    		input[4].push_back(make_pair(make_pair(-895+i*100,-600),make_pair(-895+i*100+100,-600+75)));
    	for(i=0;i<13;i++)		
    		input[4].push_back(make_pair(make_pair(-840+i*100,-525),make_pair(-840+i*100+100,-525+75)));
    	for(i=0;i<12;i++)		
    		input[4].push_back(make_pair(make_pair(-785+i*100,-450),make_pair(-785+i*100+100,-450+75)));
    	for(i=0;i<11;i++)		
    		input[4].push_back(make_pair(make_pair(-730+i*100,-375),make_pair(-730+i*100+100,-375+75)));
    	for(i=0;i<10;i++)		
    		input[4].push_back(make_pair(make_pair(-675+i*100,-300),make_pair(-675+i*100+100,-300+75)));
    	for(i=0;i<9;i++)		
    		input[4].push_back(make_pair(make_pair(-620+i*100,-225),make_pair(-620+i*100+100,-225+75)));
    	for(i=0;i<8;i++)		
    		input[4].push_back(make_pair(make_pair(-565+i*100,-150),make_pair(-565+i*100+100,-150+75)));
    	for(i=0;i<7;i++)		
    		input[4].push_back(make_pair(make_pair(-510+i*100,-75),make_pair(-510+i*100+100,-75+75)));
    	for(i=0;i<6;i++)		
    		input[4].push_back(make_pair(make_pair(-455+i*100,0),make_pair(-455+i*100+100,0+75)));// lower part
    	for(i=0;i<5;i++)		
    		input[4].push_back(make_pair(make_pair(-400+i*100,75),make_pair(-400+i*100+100,75+75)));
    	for(i=0;i<6;i++)		
    		input[4].push_back(make_pair(make_pair(-455+i*100,150),make_pair(-455+i*100+100,150+75)));
    	for(i=0;i<7;i++)		
    		input[4].push_back(make_pair(make_pair(-510+i*100,225),make_pair(-510+i*100+100,225+75)));
    	for(i=0;i<8;i++)		
    		input[4].push_back(make_pair(make_pair(-565+i*100,300),make_pair(-565+i*100+100,300+75)));
    	for(i=0;i<9;i++)		
    		input[4].push_back(make_pair(make_pair(-620+i*100,375),make_pair(-620+i*100+100,375+75)));
    	for(i=0;i<10;i++)		
    		input[4].push_back(make_pair(make_pair(-675+i*100,450),make_pair(-675+i*100+100,450+75)));
    	for(i=0;i<11;i++)		
    		input[4].push_back(make_pair(make_pair(-730+i*100,525),make_pair(-730+i*100+100,525+75)));
    	for(i=0;i<12;i++)		
    		input[4].push_back(make_pair(make_pair(-785+i*100,600),make_pair(-785+i*100+100,600+75)));
    	for(i=0;i<13;i++)		
    		input[4].push_back(make_pair(make_pair(-840+i*100,675),make_pair(-840+i*100+100,675+75)));
    	for(i=0;i<14;i++)		
    		input[4].push_back(make_pair(make_pair(-895+i*100,750),make_pair(-895+i*100+100,750+75)));
    	for(i=0;i<15;i++)		//horozontal line
    		input[4].push_back(make_pair(make_pair(-950+i*100,825),make_pair(-950+i*100+100,825+75)));
    
    			print_score(temp.size());
    }
    
   
    void erase_block(int a,int b,int c,int d,float e,int f){
    	glColor3f(rBackground,gBackground,bBackground);
    	make(a,b,c,d);
    	temp.erase(temp.begin()+f);
    	NORMAL=e*PI;
        ANGLE=reflect(ANGLE,NORMAL);
    }
    void erase_block_power(int a,int b,int c,int d,float e,int f){
    	glColor3f(rBackground,gBackground,bBackground);
    	make(a,b,c,d);
    	temp.erase(temp.begin()+f);
    }
    void pause1(){
    	flag=0;
    	flag1=0;
    	flag3++;
    }
    void update(int value) {
    	
    	glColor3f (rBackground,gBackground,bBackground); // update the color of background when ball leaves bar
    	draw(0,-835,r);	
    	
    	glColor3f (rBackground,gBackground,bBackground); // update the color of background when ball moves
    	draw(x1,y3,r);
    	
    	float x,y;
        x=x1+rad*cos(ANGLE);
    	y=y3+rad*sin(ANGLE);
        glColor3f (rBall,gBall,bBall); // color of the ball when moving
    	draw((int)x,(int)y,(int)r);
    	int i;
    	// conditions for erasing the bricks
    	for(i=0;i <temp.size();i++){
    		if(abs((int)(x+r)-(int)temp[i].first.first)<abs((int)boundry)&&y>=(int)temp[i].first.second&&y<=(int)temp[i].second.second){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,0,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,0,i);
    			enter=true;
    			break;
    		}
    
    		if(abs((int)(x-r)-(int)temp[i].second.first)<abs((int)boundry)&&y>=(int)temp[i].first.second&&y<=(int)temp[i].second.second){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,1,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,1,i);
    			enter=true;
    			break;
    		}
    
    		if(abs((int)(y+r)-(int)temp[i].first.second)<abs((int)boundry)&&x>=(int)temp[i].first.first&&x<=(int)temp[i].second.first){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,1.5,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,1.5,i);
    			enter=true;
    			break;
    		}
    
    		if(abs((int)(y-r)-(int)temp[i].second.second)<abs((int)boundry)&&x>=(int)temp[i].first.first&&x<=(int)temp[i].second.first){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,0.5,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,0.5,i);
    			enter=true;
    			break;
    		}
    
    		if(sqrt(pow(x+r*cos(ANGLE)-temp[i].first.first,2)+pow(y+r*sin(ANGLE)-temp[i].first.second,2))<rad){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			enter=true;
    			break;
    		}
    
    		if(sqrt(pow(x-r*cos(ANGLE)-temp[i].second.first,2)+pow(y+r*sin(ANGLE)-temp[i].first.second,2))<rad){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			enter=true;
    			break;
    		}
    
    		if(sqrt(pow(x+r*cos(ANGLE)-temp[i].first.first,2)+pow(y-r*sin(ANGLE)-temp[i].second.second,2))<rad){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			enter=true;
    			break;
    		}
    
    		if(sqrt(pow(x-r*cos(ANGLE)-temp[i].second.first,2)+pow(y-r*sin(ANGLE)-temp[i].second.second,2))<rad){
    			if(power==false)
    				erase_block(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			if(power==true)
    				erase_block_power(temp[i].first.first,temp[i].first.second,temp[i].second.first,temp[i].second.second,ANGLE/PI,i);
    			enter=true;
    			break;
    		}
    	}
    	
    
    	if(enter==true)
    		when++;
    	if(when==5){
    		make_bricks();
    		enter=false;;
    		when=0;
    	}
    	
    	print_score(temp.size());
    
    	if((int)(x-r+950)<abs((int)boundry)){
           NORMAL=0;
           ANGLE=reflect(ANGLE,NORMAL);
    	}
    	if(-y-r+900<abs((int)boundry))
    	{
    		NORMAL=1.5*PI;
    		ANGLE=reflect(ANGLE,NORMAL);
    	}
    	if(-x-r+950-400<abs((int)boundry))
    	{
    		NORMAL=PI;
    		ANGLE=reflect(ANGLE,NORMAL);
    	}
    	if(y-r+850<abs((int)boundry) && a<=x&&c>=x)		//the ball touches the bar
    	{
    		NORMAL=0.5*PI;
    		ANGLE=reflect(ANGLE,NORMAL);
    	} 
    	if(sqrt(pow(c-x,2)+pow(y-d,2))<=r){			//the ball touches the right part of the bar		
    		rad=(-1)*rad;
    			temp2=rad;
    	}
    
    	if(sqrt(pow(a-x,2)+pow(y-d,2))<=r){			//the ball touches the left part of the bar
    		rad=(-1)*rad;
    			temp2=rad;
    	}
    
    	if(y-r+875<abs((int)boundry) )  //the ball misses the bar
    	{		
    		life--;
    		if(life<0)
    			return;
    		if(life==0){	
    			print_score(temp.size());
    			glColor3f(rComments,gComments,bComments);
    			renderBitmapCharacher(0,800,(void *)font,"GAME OVER");
    			pause1();
    			return;
    		}
    		glColor3f (rBackground,gBackground,bBackground); 
    		print(-950,-900,550,-800);
    		print(a,b,c,d);
    		glColor3f (rBall,gBall,bBall); // the ball is re-created
    		draw(0,-835,r);
    		ANGLE=.75*PI;
    		x=0;
    		y=-825;
    		a=-150;
    		b=-900;
    		c=150;
    		d=-850;
    		glColor3f (0.0, 1.0,0.0); // bar is created again after miss
    		print(a,b,c,d);
    		flag=0;
    		flag1=0;
    		flag2=0;
    		print_score(temp.size());
    		
    	} 
    	
    	if(temp.size()==0){
    		level++;
    		if(level>6){
    			level=6;
    			return;
    		}
    		if(level==6){
    			glColor3f(rComments,gComments,bComments);
    			renderBitmapCharacher(-700,0,(void *)font,"YOU HAVE WON THE MATCH");
    			return;
    			temp1.clear();
    		}
    		temp=input[level-1];
    		bricks=temp.size();
    		glColor3f (rBackground,gBackground,bBackground);
    		draw((int)x,(int)y,(int)r);
    		make_bricks();
    
    		glColor3f (rBackground,gBackground,bBackground);
    		print(-950,-900,550,-700);
    		print(a,b,c,d);
    		glColor3f (rBall,gBall,bBall);
    		draw(0,-835,r);
    		ANGLE=.75*PI;
    		x=0;
    		y=-835;
    		a=-150;
    		b=-900;
    		c=150;
    		d=-850;
    		glColor3f (0.0, 1.0,0.0);
    		print(a,b,c,d);
    		flag=0;
    		flag1=0;
    		flag2=0;
    		flag3=0;
    		print_score(temp.size());
    		//increase_speed();
    	}
    	x1=(int)x;
    	y3=(int)y;
    	temp1=temp;
    	if(flag!=0)
    		glutTimerFunc(TIMER_MS, update, 0);
    }
    void move_left(void)
    {
    	
    		if(a<=-950){
    	                 	 glColor3f (rBar,gBar,bBar);
    	           	 print(-950,-900,-650,-850);
    			}
    		else
    		{
    		glColor3f (rBackground,gBackground,bBackground);
    		print(a,b,c,d);
    		a-=sensitivity;
    		c-=sensitivity;
    		glColor3f (rBar,gBar,bBar);
    		print(a,b,c,d);
    		}
    }
    void move_right(void)
    {
    	
    		if(c>=550){
    	                   glColor3f (rBar,gBar,bBar);
                           print(650-400,-900,950-400,-850);}
    		 else
    		 {
    			 glColor3f (rBackground,gBackground,bBackground);
    			 print(a,b,c,d);
    			 a+=sensitivity;
    			 c+=sensitivity;
    			 glColor3f (rBar,gBar,bBar);
            	 print(a,b,c,d);
    		 }
    		
    }
    void increase_speed(void){
    	if(rad>0)
    			rad+=10;
    		if(rad<0)
    			rad-=10;
    
    		boundry=abs((int)(rad/1.4142))+1;
    		temp2=rad;
    }
    void decrease_speed(void){
    	if(rad>0){
    			rad-=10;
    			if(rad==0)
    				rad+=10;
    		}
    		if(rad<0){
    			rad+=10;
    			if(rad==0)
    				rad-=10;
    		}
    		boundry=abs((int)(rad/1.4142))+1;
    		temp2=rad;
    }
    void restart(void){
    	start1=true;
    		glutPostRedisplay();
    		pause1();
    }
    void next(void){
    	glColor3f(1,1,1);
    		for(int f=0;f<temp.size();f++)
    			make(temp[f].first.first,temp[f].first.second,temp[f].second.first,temp[f].second.second);
    		temp.clear();
    		condition=0;
    }
    void touch_stack(int txl,int tyl,int txh,int tyh){
    	if(!touch_finder.empty()){
    		ptouch=touch_finder.top();
    		glColor3f(rButton,gButton,bButton);
    		make_boundry(ptouch.first.first,ptouch.first.second,ptouch.second.first,ptouch.second.second);
    		touch_finder.pop();
    	}
    	glColor3f(rTouched,gTouched,bTouched);
    	make_boundry(txl,tyl,txh,tyh);
    	touch_finder.push(make_pair(make_pair(txl,tyl),make_pair(txh,tyh)));
    }
    
    void processNormalKeys(unsigned char key, int x, int y) {
    	specialKey = glutGetModifiers();
    	if (specialKey == GLUT_ACTIVE_ALT) {
    		if (key == 114)
    			rBrick=1.0,gBrick=0.0,bBrick=0.0;
    
    		if (key == 103)
    			rBrick=0.0,gBrick=1.0,bBrick=0.0;
    
    		if(key == 98)
    			 rBrick=0.0,gBrick=0.0,bBrick=1.0;
    		make_bricks();
    
    	}
       	else{
    
    	if (key == 27)		//esc
    		exit(0);
    
    	if(key==32){		//spacebar
    		if(m==true){
    			pause1();
    			m=false;
    		}
    		else{
       			glutTimerFunc(TIMER_MS, update, 0);
    			flag++;
    			flag1++;
    			flag2++;
    			flag3=0;
    			m=true;
    		}
    		
    	}
    	if(key==110){		//NEXT LEVEL==n
    		next();
    	}
    	if(key==114){	//start the game
    		restart();
    	}
    	
    	if(key==113)		//QUIT ==q
    		return;
    	if(key==112){		//POWERBALL=p
    		power=true;
    		rBall=1.0;
    		gBall=0.0;
    		bBall=0.0;
    	}
    	if(key==109){		//MODE NORMAL=m
    		power=false;
    		rBall=0.0;
    		gBall=1.0;
    		bBall=1.0;
    	}
    
   	}
    	
    }
    void renderBitmapCharacher(float x, float y, void *font,char *string)
    {
      
      char *c;
      glRasterPos2f(x, y);
      for (c=string; *c != '\0'; c++) {
        glutBitmapCharacter(font, *c);
      }
    }
    void pressKey(int key, int x, int y) {
    
    	if(flag==0){
    
    		glutTimerFunc(TIMER_MS, update, 0);
    		flag++;
    		flag1++;
    		flag2++;
    		flag3=0;
    		m=true;
    	}
    	
    	if(key==GLUT_KEY_LEFT)
    			move_left();
    	if(key==GLUT_KEY_RIGHT)
    			move_right();
    	if(key==GLUT_KEY_UP){		//increase speed
    		if(rad>0)
    			rad+=10;
    		if(rad<0)
    			rad-=10;
    		boundry=abs((int)(rad/1.4142))+1;
    		temp2=rad;
    	}
    
    	if(key==GLUT_KEY_DOWN){		//decrease speed
    		if(rad>0){
    			rad-=10;
    			if(rad==0)
    				rad+=10;
    		}
    		if(rad<0){
    			rad+=10;
    			if(rad==0)
    				rad-=10;
    		}
    		boundry=abs((int)(rad/1.4142))+1;
    		temp2=rad;
    	}
    

    }
    void display(void)
    {
    	glClear (GL_COLOR_BUFFER_BIT);
    	arena();
    	start();			//start the game
    	comments();
    	next_level();
    	glutSwapBuffers();
    }
    void init() {
        glClearColor (0.0, 0.0, 0.0, 0.0);
//    	glEnable(GL_DEPTH_TEST);
        glMatrixMode(GL_PROJECTION);
    //    glLoadIdentity();
   //     glShadeModel(GL_SMOOTH);
        glOrtho(-1000.0, 1000.0, -1000.0, 1000.0, -1000.0, 1000.0);
    	
    	

    }
    int  main(int argc, char** argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
       glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize (700,700);
        glutInitWindowPosition (100,-100);
        glutCreateWindow ("BLASTERBALL 1.1");
        init ();
        glutDisplayFunc(display);
    	glutKeyboardFunc(processNormalKeys);
    	glutSpecialFunc(pressKey);
        glutMainLoop();
        return 0;
    	
    }

Well you have 2 glutInitDisplayMode() calls and the second one specifies a GLUT_SINGLE color buffer, you need to specify GLUT_DOUBLE and delete one of the calls. If you use the depth buffer, be sure to clear it along with the color buffer.

I commented the 2nd glutDisplayMode() call with GLUT_SINGLE then the output screen is like pause there is no effect of keystrokes.

and yeah along with this there is one problem when I minimize the game window and open other one then the whole game is again from starting stage.

glutPostRedisplay() is your friend, check the docs.

where should I use it ??

Check the docs, call it when you want to redraw.

I have used glutPostRedisplay() in all functions like where I am using left arrow key and others. But still the output is just picture there is no animation.