I'm attempting to set my glfw error and key callbacks to a function in class Game. When doing this, I get undefined references to the callback functions.
Here's what the relevant parts of the class looks like:
namespace TGE
{
class Game
{
public:
void init()
{
glfwSetErrorCallback(error_callback)
if(!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(800, 600, "Test", NULL, NULL);
if(!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSetKeyCallback(window, key_callback);
start();
}
void start()
{
// Main loop stuff
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if(action == GLFW_PRESS)
{
switch(key)
{
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldCLose(window, GL_TRUE);
break;
}
}
}
static void error_callback(int error, const char* description)
{
fputs(description, stderr);
}
protected:
GLFWwindow* window;
}
}
When I try to compile I get
In function `TGE::Game::init()`:
undefined reference to `TGE::Game::error_callback(int, char const*)`
undefined reference to `TGE::Game::key_callback(GLFWwindow*, int, int, int, int)`
I have a feeling it may be because of the namespace, but I'm not sure how to get around that if it is.
EDIT: Moving everything out of the namespace results in the same error.