我对GLFW的使用还比较新,想要在左键点击时将鼠标坐标输出到控制台。然而,我没有得到任何输出。
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
//ESC to quit
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
{
glfwSetWindowShouldClose(window, GL_TRUE);
return;
}
if (key == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
{
double xpos, ypos;
//getting cursor position
glfwGetCursorPos(window, &xpos, &ypos);
cout << "Cursor Position at (" << xpos << " : " << ypos << endl;
}
}