Jump to content
  • Advertisement

Archived

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

MicahM

OpenGL Why Does OpenGL for Windows require windows.h?

This topic is 6110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I thought OpenGL was supposed to be platform independant. If that is the case why does OpenGL require windows.h to compile correctly on a Windows machine? -Micah

Share this post


Link to post
Share on other sites
Advertisement
Nothing is "really" cross platform...

When they say that OGL is cross platform is because the C/C++ function calls, wether it be unix, windows, mac etc... are the same and "should" behave the same.
Now underneath those functions lies the specific OS code, now that is why you need windows.h for Windows... For the mac it can be mac.h for all I know That is why every platform maker must provide there own, programming libraries. The OGL Architectural Review Board makes a specification, once that specification is final and released all platfor makers(Unix, Windows, Mac etc...) Must follow that specification to produce the libraries. Thats where the specifi OS code goes... Also notice how I said each function "should" behave the same. They should but also each platform maker has their own ways of optimizing and implementing thigns... As logn as the librarry meats the final spec it should be ok....

Share this post


Link to post
Share on other sites
Microsoft placed several Windows macros in thier versions. Remember that GL/gl.h not only defines the OpenGL api but also the system specific glue functions wgl*, xgl*, etc..

If you don't wish to include windows.h (always a good thing to avoid) you can do the following.

  
//////// BEGIN GROSS WINDOZE BUSINESS.
// It would be nice not to have this crap here but GL/gl.h on windows
// requires that these things be defined. Better this than have to
// include "windows.h" on WIN32.
#ifdef WIN32
/* XXX This is from Win32's "windef.h" */
# ifndef APIENTRY
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
# define APIENTRY __stdcall
# else
# define APIENTRY
# endif
# endif
/* XXX This is from Win32's "winnt.h" */
# ifndef CALLBACK
# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
# define CALLBACK __stdcall
# else
# define CALLBACK
# endif
# endif
/* XXX This is from Win32's "wingdi.h" and "winnt.h" */
# ifndef WINGDIAPI
# define WINGDIAPI __declspec(dllimport)
# endif
/* XXX This is from Win32's "ctype.h" */
# ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
# define _WCHAR_T_DEFINED
# endif

#include "GL/glu.h"
#include "GL/gl.h"

#endif
//////// END OF GROSS WINDOZE BUSINESS.


Edited by - Kelvin on December 27, 2001 11:00:18 PM

Share this post


Link to post
Share on other sites
To simply answer your question, it''s because you''re creating a window to put your OpenGL surface on. In order to create a window in Windows, you need to include windows.h. Make sense?

Johnny Watson
Owner/Main Programmer Vigasotech, Inc.

Share this post


Link to post
Share on other sites
is it really such a problem to include window.h ?
i simply do this in my code..

#ifdef WIN32
#include
#endif

now the same code will compile on windows or some other OS without me having to rewrite that bit

Edited by - Marvin on December 30, 2001 6:02:42 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!