09-26-2003, 05:31 AM
I'm using the pop-up menus in OpenGL to allow users to input what item or picture they wish to create. When I activate the menu and click to, for example, "Create Agent", it flashes the picture on the screen but then nothing is actually drawn. So when I activate the menu again for a 2nd time repeating the same thing it draws it. I am not sure what I am doing wrong. Here's my sample code below:
void mainMenu(int value){
if(value == 1){ createAgent(); }
if(value == 0){ exit(0); }
}
void createDiamond()
{
glPushMatrix();
GLUquadricObj* mySphere2;
mySphere2 = gluNewQuadric();
gluQuadricDrawStyle(mySphere2, GLU_LINE);
glColor3f(0.0, 1.0, 1.0);
glLineWidth(2.0);
glTranslatef(0.0, -0.75, 0.0);
gluDisk(mySphere2, 0.2, 0.2, 3, 1);
glLoadIdentity();
glPopMatrix();
}
void createAgentTop(){
glPushMatrix();
GLUquadricObj* mySphere2;
mySphere2 = gluNewQuadric();
gluQuadricDrawStyle(mySphere2, GLU_LINE);
glColor3f(0.0, 1.0, 1.0);
glLineWidth(2.0);
glTranslatef(0.0, -0.5, 0.0);
gluDisk(mySphere2, 0.05, 0.05, 50, 1);
glLoadIdentity();
glPopMatrix();
}
void createAgent(){
glLoadIdentity();
createAgentTop();
createDiamond();
glFlush();
}
void mainMenu(int value){
if(value == 1){ createAgent(); }
if(value == 0){ exit(0); }
}
void createDiamond()
{
glPushMatrix();
GLUquadricObj* mySphere2;
mySphere2 = gluNewQuadric();
gluQuadricDrawStyle(mySphere2, GLU_LINE);
glColor3f(0.0, 1.0, 1.0);
glLineWidth(2.0);
glTranslatef(0.0, -0.75, 0.0);
gluDisk(mySphere2, 0.2, 0.2, 3, 1);
glLoadIdentity();
glPopMatrix();
}
void createAgentTop(){
glPushMatrix();
GLUquadricObj* mySphere2;
mySphere2 = gluNewQuadric();
gluQuadricDrawStyle(mySphere2, GLU_LINE);
glColor3f(0.0, 1.0, 1.0);
glLineWidth(2.0);
glTranslatef(0.0, -0.5, 0.0);
gluDisk(mySphere2, 0.05, 0.05, 50, 1);
glLoadIdentity();
glPopMatrix();
}
void createAgent(){
glLoadIdentity();
createAgentTop();
createDiamond();
glFlush();
}