freeglut ERROR:Function called without first calling 'glutInit'

在配置好freeglut后,运行出现错误:

freeglut  ERROR:  Function <glutMainLoopEvent> called without first calling 'glutInit'.

而使用glutMainLoop时就没有出现任何问题。

后来在http://objectmix.com/graphics/355206-unusual-error-same-code-different-systems-function-glutbitmapcharacter-called-without-first-calling-glutinit.html中找到了解决方法:

在添加依赖项时,只需添加freeglut.lib,而不要同时添加原来的glut32.lib。

这里的主要原因是,freeglut把原来glut库中的很多函数都重写了,比如glut中的glutInit函数和freeglut中的不一致。而在依赖项中如果还有glut32.lib,

则在编译时可能会把glutInit认为是原来的那个,导致出错。

你可能感兴趣的:(freeglut ERROR:Function called without first calling 'glutInit')