Archived

This topic is now archived and is closed to further replies.

Ainokea

why include windows?

Recommended Posts

If opengl is cross platform howcome the opengl tutorial in nehe #include "windows.h" ? I dont mind i have windows xp. I was just wondering.

Share this post


Link to post
Share on other sites
Because the tutorials were compiled on windows, and the GL headers (in MSVC at least) have this annoying quirk that they use some #defines from windows.h.

Share this post


Link to post
Share on other sites
OpenGL is crossplatform. But window creation is not. For that you use OS specific code or use something like GLUT.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
Microsoft''s OpenGL implementation uses GDI macros in the GL/gl.h header and requires that they be defined before the header is included, hence the need to include windows.h before GL/gl.h. Since it''s only that OpenGL implementation that requires that, feel free to wrap the windows.h inclusion in a preprocessor test to only do it when necessary (less global-namespace-poluting solutions exist too, by avoiding the need for windows.h, but they''re more difficult).

Share this post


Link to post
Share on other sites