Jump to content
  • Advertisement
Sign in to follow this  
monkey4sale

OpenGL error

This topic is 3756 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

While trying to learn OpenGL programming i've come across a problem, just including the GL header file results in 143 errors, most of which talink about missing semicolons and type definitions....

Share this post


Link to post
Share on other sites
Advertisement
#include <windows.h> before including the gl header file.

The <GL/gl.h> file on windows relies on types declared in windows.h but doesn't include it for some reason.

Share this post


Link to post
Share on other sites
If you are using glut, just include glut.h. This will define the various things the GL/gl.h header file needs. Here is a snippet of it (one I found anyway) to show you what I mean:

#if defined(_WIN32)

/* 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. */

# if 0
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# else
/* XXX This is from Win32's <windef.h> */
# ifndef APIENTRY
# define GLUT_APIENTRY_DEFINED
# 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 GLUT_WINGDIAPI_DEFINED
# 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
# endif


I actually didn't know it did this until reading it, but glut apparently only defines the minimal things needed [smile].

Share this post


Link to post
Share on other sites
Alright, i downloaded glut, searched for and downloaded glut32.lib, and now I have another problem.

1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>G:\C++\OpenGL Red Book\Hello\Debug\Hello.exe : fatal error LNK1120: 1 unresolved externals

[Edited by - monkey4sale on June 13, 2008 3:44:40 PM]

Share this post


Link to post
Share on other sites
If you are compiling a windows application, you need to have a WinMain, not a main. So either use WinMain, or change to a console application.

Share this post


Link to post
Share on other sites
A console is that black window where you type commands.
You must make a console application. GLUT will create a GL window.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!