Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / Help using openGL in visual C++ Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
JosephDuchesne

March 02, 2005, 07:20 PM

Hi, I'm trying to use openGL in visual studio and I'm not sure exactly what I'm doing wrong. I am porting the source from Mac, and I am sure that there are no errors. I have removed anything of which I am not 100% sure is cross platform. I'm pretty sure that I am somehow not including the opengl stuff the right way. Can anyone exaplin what I might be doing wrong?


#include
#include
#include
#include "SDL/SDL.h" //I'm also using SDL which is working fine


=== the errors ===
Compiling...
main.c
c:program filesmicrosoft visual studiovc98includeglgl.h(1152) : error C2054: expected '(' to follow 'WINGDIAPI'
c:program filesmicrosoft visual studiovc98includeglgl.h(1152) : error C2085: 'APIENTRY' : not in formal parameter list
c:program filesmicrosoft visual studiovc98includeglgl.h(1152) : error C2146: syntax error : missing ',' before identifier 'glAccum'
c:program filesmicrosoft visual studiovc98includeglgl.h(1152) : error C2143: syntax error : missing ';' before '('
c:program filesmicrosoft visual studiovc98includeglgl.h(1152) : error C2059: syntax error : ')'
c:program filesmicrosoft visual studiovc98includeglgl.h(1153) : error C2054: expected '(' to follow 'WINGDIAPI'
c:program filesmicrosoft visual studiovc98includeglgl.h(1153) : error C2085: 'APIENTRY' : not in formal parameter list
c:program filesmicrosoft visual studiovc98includeglgl.h(1153) : error C2146: syntax error : missing ',' before identifier 'glAlphaFunc'
c:program filesmicrosoft visual studiovc98includeglgl.h(1153) : error C2143: syntax error : missing ';' before '('
c:program filesmicrosoft visual studiovc98includeglgl.h(1153) : error C2059: syntax error : ')'
c:program filesmicrosoft visual studiovc98includeglgl.h(1154) : error C2054: expected '(' to follow 'WINGDIAPI'
c:program filesmicrosoft visual studiovc98includeglgl.h(1154) : error C2085: 'APIENTRY' : not in formal parameter list
c:program filesmicrosoft visual studiovc98includeglgl.h(1154) : error C2146: syntax error : missing ',' before identifier 'glAreTexturesResident'
c:program filesmicrosoft visual studiovc98includeglgl.h(1154) : error C2143: syntax error : missing ';' before '('
c:program filesmicrosoft visual studiovc98includeglgl.h(1154) : error C2059: syntax error : ')'
c:program filesmicrosoft visual studiovc98includeglgl.h(1155) : error C2054: expected '(' to follow 'WINGDIAPI'
c:program filesmicrosoft visual studiovc98includeglgl.h(1155) : error C2085: 'APIENTRY' : not in formal parameter list
c:program filesmicrosoft visual studiovc98includeglgl.h(1155) : error C2146: syntax error : missing ',' before identifier 'glArrayElement'
c:program filesmicrosoft visual studiovc98includeglgl.h(1155) : error C2143: syntax error : missing ';' before '('
c:program filesmicrosoft visual studiovc98includeglgl.h(1155) : error C2059: syntax error : ')'

 
Vander Nunes

March 02, 2005, 08:01 PM

Have you tried including before anything else? Does it work? You may #ifdef it to keep your engine cross-platform.

 
JosephDuchesne

March 02, 2005, 09:25 PM

You hit the nail on the head. Thanks a lot. It's dumb things that that that make porting such a pain :)

I have a new problem of course. I am now getting the following errors:

main.obj : error LNK2001: unresolved external symbol __imp__glOrtho@48
main.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
main.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
main.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
main.obj : error LNK2001: unresolved external symbol __imp__glClear@4
main.obj : error LNK2001: unresolved external symbol __imp__glHint@8
main.obj : error LNK2001: unresolved external symbol __imp__glBlendFunc@8
main.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
MadTak : fatal error LNK1120: 8 unresolved externals
Error executing link.exe.

 
Vander Nunes

March 02, 2005, 11:10 PM

OK, you got the code compiled, but now you need to link with the OpenGL library (opengl32.lib, and possibly glu32.lib and glut32.lib). This is under Project -> Settings -> Link.

 
JosephDuchesne

March 03, 2005, 03:55 PM

It's now running. Thanks a lot :)

 
Vast

March 03, 2005, 06:10 PM

Also, if "windows" header sounds a little win32-scary, what u could do is try to include before gl.h, and it would make u feel a lot better (i know glaux is outdated, i just use it to get rid of the errors, and the thing is cross-platform, so it makes me sleep better =))

Tim

 
Erik Faye-Lund

March 04, 2005, 04:25 AM

Vast: whats wrong with

#ifdef WIN32
#include
#endif

? ;)

 
Rui Martins

March 04, 2005, 06:34 AM

I don't know his answer, but mine is that "windows.h" is full of "crap", that you don't need, which polutes the name space, and delays compilation too.

"glut.h" for example, only defines the absolutly necessary constants, hence avoids including "windows.h".

 
Nico

March 04, 2005, 06:54 AM

You can
#define WIN32_LEAN_AND_MEAN
before #include'ing windows.h. That way most of the stuff in there is removed by the preprocessor.

 
Rui Martins

March 04, 2005, 10:09 AM

Yes I know that one too, but it's still preprocessed, and the file isn't that small (for a definttions file).

 
This thread contains 10 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.