PDA

View Full Version : Q += 0.2f; NOT Accepted !!!



GMA-216
04-11-2013, 04:23 PM
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
glVertex2d(Q,op2); // 2
glVertex2d(ap3,op3); // 4
glVertex2d(ap4,op4); // 3

glEnd();
---------------------------------


/*------------------Mouvement--------------------------------*/


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

case 'p':

Q += 0.2f; // this is the problem of compilation
op2+=0.2f;

glutPostRedisplay();

break;






default: break;
}

}


thank you for help

Claude
04-11-2013, 05:32 PM
You declare Q inside a function and try to access it in another.Make Q global.

GMA-216
04-12-2013, 03:11 AM
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 ;)

thokra
04-12-2013, 04:33 AM
Nitpicking on: You didn't declare the variable, you declared and defined Q. Nitpicking off.

GMA-216
04-12-2013, 03:39 PM
yes, i correct it, it work, thanks again