PDA

View Full Version : extremly new baby's question on openGl for VC



09-13-2002, 09:14 PM
I am trying to transfer my openGL code for unix to windows xp (VC 6.0). But I on't know how to.

I followed the tutorial of NEHE, include the head file for openGL:
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl\glaux.h>

and then add three library in project->setting->link-> objects module:
OpenGL32.lib GLu32.lib GLaux.lib

then I compile it, but got many errors, like:
error C2065: 'glutBitmapCharacter' : undeclared identifier

error C2065: 'glutSwapBuffers' : undeclared identifier

I think I must do sth wrong,
anyone can help me?

Bode
09-13-2002, 11:04 PM
Hi...

Did you forget to also include 'glut.h'?

...just a guess

tinak
09-13-2002, 11:06 PM
Those are GLUT specific commands so you will need to download a Windows version of the GLUT library and include that .h file and link to that lib file.

There is a win32 command SwapBuffers(HDC) which you can use instead passing the Windows HDC to the command. However I'm not sure there is a direct equivalent of the Bitmap Character. Instead there are a group of routines you can used instead to display text. These are in Nehe's windows GL tutorials.

Tina

nexusone
09-14-2002, 07:11 AM
I expect that you should change #include<GL/glaux.h> to #include<GL/glut.h>.

glaux is a utility made back in the early days of openGL. Mostly only supported by windows and VC++.
Nehe used glaux in his windows examples of opengl to load BMP texture files, but if I remember in the linux examples he uses a extra routine to load TGA files since glaux is not avaible on unix.

If you do not have glut.h for windows you will need to download it from Nate Robins web site, http://www.xmission.com/~nate/opengl.html



Originally posted by newbaby:
I am trying to transfer my openGL code for unix to windows xp (VC 6.0). But I on't know how to.

I followed the tutorial of NEHE, include the head file for openGL:
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl\glaux.h>

and then add three library in project->setting->link-> objects module:
OpenGL32.lib GLu32.lib GLaux.lib

then I compile it, but got many errors, like:
error C2065: 'glutBitmapCharacter' : undeclared identifier

error C2065: 'glutSwapBuffers' : undeclared identifier

I think I must do sth wrong,
anyone can help me?

09-14-2002, 03:15 PM
got it, thanks.

09-14-2002, 04:15 PM
I resolved the compile problem now, I download the glut.h , glut32.dll and glut32.lib copy them to the designated directory.

but I got link error as:

Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/pin.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

pin.exe - 2 error(s), 2 warning(s)

why?

09-14-2002, 06:27 PM
ok, i already got it. Thanks

tinak
09-15-2002, 02:08 AM
The link error is due to making a win32 application with GLUT commands. Technically GLUT requires a console application but we can work round this in Visual C++ by placing a pragma command near the top of the program.

#pragma comment( linker, "/entry:\"mainCRTStartup\"" )

Place this all in one line and it will tell the linker to treat the main() command as the entry point to the program. I use it all the time and it works wonderfully.

Tina

Deiussum
09-15-2002, 12:50 PM
Originally posted by tinak:
The link error is due to making a win32 application with GLUT commands. Technically GLUT requires a console application but we can work round this in Visual C++ by placing a pragma command near the top of the program.

#pragma comment( linker, "/entry:\"mainCRTStartup\"" )

Place this all in one line and it will tell the linker to treat the main() command as the entry point to the program. I use it all the time and it works wonderfully.

Tina

Or you can do what most people do and start the program's project out appropriately. Win32 Application for WinMain, Win32 Console for main.

Why botther adding a line of code to every project if all you have to do is choose the right option when first create that project.

tinak
09-15-2002, 01:18 PM
hehe, of course the decision is up to the programmer... I hate that extra console window popping up so choose not to use console project deliberately because of that... most of my projects are non glut so it isn't a problem for me..

Tina