Q += 0.2f; NOT Accepted !!!

Hello,

i try this code to change the position of vertex, but not working :
static void Display(void)
{

/--------------- Variables -----------/

GLfloat ap1= -0.70f;
GLfloat op1= 0.05f;

GLfloat Q= -0.70f;
GLfloat op2= 0.20f;

GLfloat ap3= -0.50f;
GLfloat op3= 0.20f;

GLfloat ap4= -0.50f;
GLfloat op4= 0.05f;

glBegin(GL_TRIANGLE_FAN);
glColor3ub(255,0.0,0.0);

 glVertex2d(ap1,op1);    // 1
[b] glVertex2d(Q,op2);[/b]    // 2
 glVertex2d(ap3,op3);   // 4
 glVertex2d(ap4,op4);   // 3

 glEnd();

/------------------Mouvement--------------------------------/

void keyboard(unsigned char key)
{
switch (key) {

      case 'p': 
           
                [b]Q += 0.2f;[/b]    // this is the problem of compilation
                 op2+=0.2f;
                 
           glutPostRedisplay();
            
      break;      
    

     
   
     
     
default:  break;

}

}

thank you for help

You declare Q inside a function and try to access it in another.Make Q global.

thank you so much, yes i forget to declare those variable, outside the function

thanks again :wink:

Nitpicking on: You didn’t declare the variable, you declared and defined Q. Nitpicking off.

yes, i correct it, it work, thanks again