gl.h included before glew, but GLFW needs gl.h

点点圈 提交于 2019-12-14 01:26:13

问题


I remember that the way you order your #include-s matter. Well, I'm in a bit on trouble. I have these two headers:

#include <gl/glfw.h>
#include <gl/glew.h>

If I run that, I get an error saying that gl.h is included before glew.h. But If I reverse the order of those two so that glew.h is first, I get a LOT of errors. I was just thinking of hunting down what the #define-s mean so I could just say for me: #define whatineed 0x0000x.

  1. How can I fix this problem with the headers arrangement.
  2. Is the method of hunting and making my defines safe?

回答1:


What sort of errors are you getting when you include the GLEW header first?

The GLEW header defines all the magic necessary to disable the inclusion of most GL headers, so including the GLEW header before the GLFW one should work; should as in I've used this successfully for a number of years on Linux, Windows and Mac OS X with native GCC, Clang, MinGW, Cygwin and VC++. It's even an official FAQ:

http://www.glfw.org/faq.html#can-i-use-extension-loaders-with-glfw




回答2:


The main problem is that glfw.h has an explicit check to test if gl.h has already been included and fail if it has, instead of just carrying on ignoring that "error". I ended up simply commenting that piece of code out of the header on my version of the lib.



来源:https://stackoverflow.com/questions/5768189/gl-h-included-before-glew-but-glfw-needs-gl-h

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!