TifaOng
05-05-2011, 10:16 PM
I wanted to translate an object following a mouse and these are my coding related to the mouse motion,
void mouseDrag(int x, int y)
{
int button;
int state;
GLfloat translateX;
GLfloat translateY;
if ((state == GLUT_DOWN) && (button == GLUT_LEFT_BUTTON)) // translate
{
translateX += (400-x)/ 1000.0f;
translateY += (400-y) / 1000.0f;
}
gl_draw(translateX, translateY);
glutPostRedisplay();
}
in gl_draw() i use glTranslatef(translateX,translateY, -6.0f); to translate the object.
and in main()
glutMotionFunc(mouseDrag);
But I keep getting this error : Error 2 error C2664: 'glutMotionFunc' : cannot convert parameter 1 from 'overloaded-function' to 'void (__cdecl *)(int,int)' F:\UTM courses\OpenGL Tutorials\VidTut\cube\main.cpp 475
I think it refers to the mouseDrag() function. But where is the error?
Please help.
Thank you very much!!!
void mouseDrag(int x, int y)
{
int button;
int state;
GLfloat translateX;
GLfloat translateY;
if ((state == GLUT_DOWN) && (button == GLUT_LEFT_BUTTON)) // translate
{
translateX += (400-x)/ 1000.0f;
translateY += (400-y) / 1000.0f;
}
gl_draw(translateX, translateY);
glutPostRedisplay();
}
in gl_draw() i use glTranslatef(translateX,translateY, -6.0f); to translate the object.
and in main()
glutMotionFunc(mouseDrag);
But I keep getting this error : Error 2 error C2664: 'glutMotionFunc' : cannot convert parameter 1 from 'overloaded-function' to 'void (__cdecl *)(int,int)' F:\UTM courses\OpenGL Tutorials\VidTut\cube\main.cpp 475
I think it refers to the mouseDrag() function. But where is the error?
Please help.
Thank you very much!!!