在一個簡單的OpenGL程序我有下面這行:glutKeyboardfunc()回調函數參數
glutKeyboardFunc(keypressed);
問題是我的「的keyPressed」功能在另一個CPP文件中包含項目。我怎樣才能從我的其他文件調用這個功能?
在main.cpp中:
main()
{
---
glutKeyboardFunc(keypressed);
---
}
在Motion.cpp:
void keypressed(unsigned char key, int x, int y){...}
事情我嘗試(一切都給編譯錯誤):
glutKeyboardFunc(keypressed);
glutKeyboardFunc(Motion::keypressed);
glutKeyboardFunc(&Motion::keypressed);
glutKeyboardFunc(&keypressed);
Motion mot;
glutKeyboardFunc(mot.keypressed);
有什麼建議? (我使用freeglut.dll如果庫問題的答案)
製作一個具有函數聲明的'Motion.h'文件。 –