View Full Version : Blending OpenGL and MFC

07-30-2002, 11:18 AM
Yes, I know there is another thread about this topic, but my question is different, and the replies to that post didn't help me.
I have written some opengl code that works, and now I am trying to combine a program someone else wrote into my code. The person wrote a command line program that uses MFC(I think for the sole purpose of using CStrings, but maybe there are some other things in there I missed when I skimmed over it). When I try and compile my program with his stuff included, I get the following error:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

So I comment out the #include <windows.h> in my opengl code, and then I get 3 errors that read:
include\gl\gl.h(2301) : error C2144: syntax error : missing ';' before type 'void'

\include\gl\gl.h(2301) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers

\include\gl\gl.h(2301) : fatal error C1004: unexpected end of file found

Does anyone know why this is happening, and what I can do about it? Any help would be appreciated. TIA


07-30-2002, 01:17 PM
Without looking at your code it is difficult to tell what is wrong exactly but try using the MFC header, afxwin.h, instead and before any other headers.

#include <afxwin.h> // MFC Windows include file
#include <GL/gl.h> // OpenGL include file
#include <GL/glu.h> // OpenGL Utilities include file