freeglut (./a.out): ERROR: No display callback registered for window 1
freeglut (./a.out): ERROR: No display callback registered for window 1
我正在尝试开始学习如何使用 C 制作图形。
#include <GL/glut.h>
int main(int argc, char **argv, char **envp) {
glutInit(&argc, argv);
glutCreateWindow("test");
glutMainLoop();
return 0;
}
这是用 gcc test.c -l glut
编译的。执行时,会打印以下错误:freeglut (./a.out): ERROR: No display callback registered for window 1
。这可能是什么原因造成的,可以采取什么措施来解决它?
您必须为当前 window 设置显示回调 glutDisplayFunc
before you enter the event processing loop with glutMainLoop
:
#include <GL/glut.h>
void display(void);
int main(int argc, char **argv, char **envp) {
glutInit(&argc, argv);
glutCreateWindow("test");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void display(void)
{
/* ... */
}
我正在尝试开始学习如何使用 C 制作图形。
#include <GL/glut.h>
int main(int argc, char **argv, char **envp) {
glutInit(&argc, argv);
glutCreateWindow("test");
glutMainLoop();
return 0;
}
这是用 gcc test.c -l glut
编译的。执行时,会打印以下错误:freeglut (./a.out): ERROR: No display callback registered for window 1
。这可能是什么原因造成的,可以采取什么措施来解决它?
您必须为当前 window 设置显示回调 glutDisplayFunc
before you enter the event processing loop with glutMainLoop
:
#include <GL/glut.h>
void display(void);
int main(int argc, char **argv, char **envp) {
glutInit(&argc, argv);
glutCreateWindow("test");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void display(void)
{
/* ... */
}