Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

function / method pointer - Inputsystem

Started by benderB Jan 25, 2006 at 8:18 AM 1 replies 900+ views
Original Post
benderB
benderB
heya, I'm in the process of implementing the input system for my engine. Although I have abstracted the main parts of the engine away via interfaces, the only implementation for my window system at the moment is GLFW (hopefully a wxWindows implementation in the near future). So I thought I'll use the input functions of GLFW for the current implementation of my (simple) input system. Now GLFW is a non OO library and uses function pointers to register the callbacks for the input (i.e: void glfwSetKeyCallback( GLFWkeyfun cbfun )). My engine is pure OO and I want to keep it that way. My inital though was to have an IInput interface and an CGLFWInput implementation which has got an update() methode to gather the input. In the update methode a glfwPollEvents() would be called which should the call the callback function registered via glfwSetKeyCallback(). The problem I got is, that I can't pass a pointer to a methode of the CGLFWInput class to the glfwSetKeyCallback() function, as it requires a function pointer, not a pointer to a methode. Does anybody know a solution to this, as I don't want to poll every single key every time... thanks, benderB
_goat
_goat
No. They have two different signatures. A pointer to a method will require an instance of the class, which is why it won't accept it (it would not be able to just generate an instance of a class on the fly).

Function-Pointer.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.