Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

opengl

glfw

glew

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?
like image 420
Imnotanerd Avatar asked Oct 18 '25 15:10

Imnotanerd


2 Answers

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

like image 193
elmindreda Avatar answered Oct 20 '25 07:10

elmindreda


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.

like image 37
yuriks Avatar answered Oct 20 '25 05:10

yuriks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!