how to change the symbolic constant in glBegin()

Hi, just wondering how I can change the constant in glBegin(GL_POLYGON) to glBegin(GL_LINE_LOOP) if the user presss a key event. thanks

glPolygonMode( GL_FRONT_AND_BACK, mode ), where mode is GL_FILL or GL_LINE.

glPolygonMode? Eh?

No, what you want is just to save the mode in a variable, and glBegin the variable instead. Something like:

// Initialisation:
int mode = GL_POLYGON;

// On key event:
if(mode == GL_POLYGON)
  mode = GL_LINE_LOOP;
else
  mode = GL_POLYGON;

// Drawing:
glBegin(mode);
...