我真的堅持功能:glfwSetCursorPosCallback到另一個類
我的主窗口和主遊戲循環我做的:
// poll for input
glfwPollEvents();
this->controls->handleInput(window, world->getPlayer());
glfwSetCursorPosCallback(window, controls->handleMouse);
我想要做的是有一個班級負責爲控件,並讓這個類也處理鼠標。
我總是得到:
'Controls::handleMouse': function call missing argument list; use '&Controls::handleMouse' to create a pointer to member
現在,當我試試這個,我得到:
'GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow *,GLFWcursorposfun)' : cannot convert argument 2 from 'void (__thiscall Controls::*)(GLFWwindow *,double,double)' to 'GLFWcursorposfun'
不知道我在做什麼錯在這裏,作爲GLFWcursorposfun僅僅是一個帶有GLFWwindow的typedef和兩次雙打。
由於函數是在另一個類我試圖爲它創建一個原型,如:
class Controls {
void handleInput(GLFWwindow *window, object *gameObject);
void handleMouse(GLFWwindow *window, double mouseXPos, double mouseYPos);
};
,但無濟於事。
編輯:當然,我可以將它設置爲& Controls :: handleMouse如果我使該函數成爲靜態,但我寧願能夠創建多個控件對象與他們操作的不同攝像頭和gameObjects。
另外,如何獲取正確的camera/gameObject數據呢?
你可以看到我的回答這個問題,這在短期使'glfwSetWindowUserPointer'的用途:HTTP://計算器。 com/questions/7676971 /指向某一功能的成員-glass-member-glfw-setkeycallback/28660673#28660673 – N0vember 2015-04-02 01:32:58