Skip to main content
gamedev.net
🔒 Locked

why include windows?

Started by Ainokea 2 replies 550+ views
Original Post
Ainokea
Ainokea
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.
______________With the flesh of a cow.
SiCrane
SiCrane
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.
_DarkWIng_
_DarkWIng_
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.
You should never let your fears become the boundaries of your dreams.
Null and Void
Null and Void
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).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.