GlutPostRedisplay problem

Hey guys i’m trying to setup my application where upon keyboard input it cycles between two different ways to “draw” my robot.

1.the first is with texture mapping

2.the second is with color mapping using a different set of vertices.

How can i make it so it completely redraws the whole scene? I tried passing a parameter to GlutPostRedisplay(display(int)); so i could choose based on # but that didn’t work.

my code looks something like this:


void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
flythru1(distance, azimAngle, incAngle, twistAngle);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _textureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

whichtexture(decider);

glBegin(GL_QUADS);

//texture mapping code here//



//color mapped code here//

//glEnable(GL_COLOR_MATERIAL);
	

//glPushMatrix();
//colorcube();

//neck();
//body();
//armleft();
//armright();
//handleft();
//handright();
//leg1();
//leg2();
//foot1();
//foot2();
//glutSwapBuffers();
//glPopMatrix();


Well glutPostRedisplay will simply invoke the display function. The logic of what to render is decided by u. In your case, you just need to setup a flag which u set (using key press etc.) and then in the display function call the appropriate render path. so in pseudocode its like this,


void Display() {
   glClear(...);
   if(flag) {
      //texture mapping code here//
   } else {
      //color mapped code here//
   } 
   glutSwapBuffers();
}