glut and windows.h

/* GLUT 3.7 now tries to avoid including <windows.h>
to avoid name space pollution, but Win32’s <GL/gl.h>
needs APIENTRY and WINGDIAPI defined properly. */

at least this is what the glut.h header file says, but for some reason it doesn’t work… well actually i’ve got no clue what’s this all about , but the compiler complains about lines in gl.h etc. where those words ( WINGDIAPI…) appear. can anyone help me? where can i get a suitable “windows.h” file? or what else can i do?



The problem is that different compilers comes with little different headers so glut.h may not work. The easiest is to change the line with “if 0” at the beginning to “if 1”.

windows.h should come with windows anyway (or at least with your windows compiler). The easiest platform independent way to get rid of the WINGDIAPI errors is like this:

#ifdef _WIN32 // Think that’s right.
#include <windows.h>

#include <GL/…>

Hope that helps.

Also the order of includes DOES make a difference. C/C++ files are compiled from the top down so if you were doing something like so…

#include <GL/gl.h>
#include <GL/glut.h>

You would be getting to the WINGDIAPI stuff in gl.h before the glut.h had a chance to define it for you.

#if defined(_WIN32) (beginning of glut.h)

what does that mean anyway? I think here is already a problem (it seems to be FALSE, i changed the line to (#if 1 …) and now i get different errors like "dllimport was not declared in this scope "…).

the next thing is just cannot find a windows.h file anywhere on my computer…


What compiler do you use? I would have thought you would have windows.h with it. Maybe the MSDN site has windows.h for download? Mine is kept in my Visual Studio directories but I also have another one that came with cygwin.

If your compiler doesn’t have a windows.h, I would tend to think that it is probably not a windows compiler, and just getting a windows.h from somewhere isn’t going to help. For instance if you are using Turbo C++ 3.0, you can throw all the windows headers you want in there, but you will not be able to create a windows executable with it because it is a DOS compiler, not a Win32 compiler, and not even a Win16 compiler.

So, as ffish asked, which compiler do you use?

OK guys, now that i’m using a different compiler,cygwin, it works!

thx !