Im 다소 glut 및 opengl에 새로운 기능이 있습니다. 마우스 동작에서 카메라 움직임을 만들려고 노력하고 있지만 화면에서 마우스 위치를 얻으려고하면 x 및 y를 전달할 메서드를 가정합니다. glutPassiveMotionFunc() 매개 변수에서 참조됩니다. 하지만 CameraMove 메서드에 함수를 제공하려고 할 때 오류가 발생합니다. 나는 방법을 잘못 전달하고 있지만 확실하지는 않다는 것을 압니다.glutPassiveMotionFunc 문제
void helloGl::CameraMove(int x, int y)
{
oldMouseX = mouseX;
oldMouseY = mouseY;
// get mouse coordinates from Windows
mouseX = x;
mouseY = y;
// these lines limit the camera's range
if (mouseY < 60)
mouseY = 60;
if (mouseY > 450)
mouseY = 450;
if ((mouseX - oldMouseX) > 0) // mouse moved to the right
angle += 3.0f;`enter code here`
else if ((mouseX - oldMouseX) < 0) // mouse moved to the left
angle -= 3.0f;
}
void helloGl::mouse(int button, int state, int x, int y)
{
switch (button)
{
// When left button is pressed and released.
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
{
glutIdleFunc(NULL);
}
else if (state == GLUT_UP)
{
glutIdleFunc(NULL);
}
break;
// When right button is pressed and released.
case GLUT_RIGHT_BUTTON:
if (state == GLUT_DOWN)
{
glutIdleFunc(NULL);
//fltSpeed += 0.1;
}
else if (state == GLUT_UP)
{
glutIdleFunc(NULL);
}
break;
case WM_MOUSEMOVE:
glutPassiveMotionFunc(CameraMove);
break;
default:
break;
}
}