Hi, there is a following problem.
Depending on configuration glut have to be included in one of three ways:
#include <glut.h>
#include <GL/glut.h>
#include <GLUT/glut.h>
(or even #include <OpenGL/glut.h> )
Wesley proposed such kind of solution ….
#if defined (__APPLE__) || defined (OSX) #include <GLUT/glut.h> #elif defined (__LINUX__) || defined (UNIX) || defined(WIN32) #include <GL/glut.h> #endif
but after some searching I found that it's platform independent thing were GLUT files are located.
So I thing we should think about another options…
Fabio proposed another solution:
There is no standard place to put 'glut.h', specially
in windows. Many people put it in <GL/glut.h>, others
in <GLUT/glut.h> and others in <glut.h>. We could
use:#ifndef glut_h
… glut inclusion here …
#endifSo if the user put 'glut.h' in another place he can
include by himself before including 'luaglut.h' with
no errors..
So I see here tree possible solutions:
1. Follow by Opengl.org examples and use #include <GL/glut.h> .
2. Use #include <glut.h> (or even #include "glut.h") and then use more sophisticated "configure" script to set proper compiler parameters.
3. Fabio's solution with preprocessor constants like __glut_h .
*1 - Assuming that opengl.org is a kind of standard makes sens for me… examples: http://www.opengl.org/resources/code/samples/glut_examples/
http://www.opengl.org/resources/code/samples/glut_examples/examples/examples.html
*2 - I mean "-I" in gcc. In this way we can adjust to current configuration without any interference into sources. Additionally on specific configurations (when compilation FAILs :( … ) user can simply create file "glut.h" in project directory just by "echo '#include <XXX/glut.h>' > glut.h" to adjust project to his specific configuration (like "OpenGL/glut.h").
*3 - It can be a another option between two previous ones.
The standard place to include glut is <GL/glut.h> . See: http://www.opengl.org/resources/libraries/glut/spec3/node7.html.
The problem is that very often the standard is broken.
The original solution that I have implemented is #2.
An alternative is #3, maybe we can use GLUT_VERSION definition or other definition.
A #4 solution is to not include glut at all. Leave it as responsability to who is using the lib.
And remember that it's very important that eventual changes must be backward compatible! It may not broke current projects using LuaGL.
On OSX since GLUT is a framework and is standardized in where it is located, doing:
#include <GLUT/glut.h>
will always work and is the prefered method of including this header. I think the inclusion of GLUT should be handled inside the OS detection macros.
wes