3
我有下面的代碼,它似乎在工作,如果我使用glfwGetKey(),但因爲它不會退出循環,甚至似乎不打電話輸入功能。我嘗試通過*輸入,而不是輸入,但沒有骰子。什麼可能導致這個?glfwPollEvents()不會在按鍵上調用keycallback
#include <display.h>
#include <GL/glfw.h>
#include <stdlib.h>
#include <stdio.h>
bool running;
void GLFWCALL input(int key, int action)
{
//if(key == GLFW_KEY_ESC){
running = false;
//}
printf("%d",key);
}
int main(int argc, char* argv[])
{
running = true;
if(argc==3){
int width = atoi(argv[1]);
int height = atoi(argv[2]);
Display d(width,height);
glfwSetKeyCallback(*input);
d.open();
while(running){
glfwPollEvents();
printf("Running");
}
printf("\n %d,%d %d\n", width,height,GLFW_KEY_ESC);
d.close();
return 1;
}
else {
printf("Usage: GLFW_play width height");
return 0;
}
}
謝謝,glfwInit在d.open中調用。這解決了它。小啞巴錯誤-.- – thegermanpole