PDA

View Full Version : completely beginning opengl



BenSanders
09-21-2005, 09:41 PM
Hi, I am interested in programming in openGL. I have both the red and blue books so I typed the first code example into a ".c" file and tried to compile it with g++. It didn't recognize any of the #include <GL/glu.h> files or any of the enumerated types. Are there some files I need to download (libraries)? And if so, where could I get those?

Thanks,
Ben

mikael_aronsson
09-22-2005, 03:12 AM
Hi !

Did you compile it on Linux or Windows using MinGW or what ?

As far as I know almost all platforms include gl.h and glu.h with the compiler so that should not be a problem, could you please post the error messages you get, this makes it much easier to help you.

Mikael

BenSanders
09-23-2005, 10:07 PM
Hi, I compiled it under Ubuntu Linux 5.04 "Hedgehog" version with the g++ compiler -- I'll post the error messages next

09-24-2005, 09:23 AM
Hi Ben!
I've never used Ubuntu Linux but it's really strange that a platform that support OpenGL comes up without GLU library. Are you sure you're not making confusion with glut? anyway, if really so, i can send you the library header .h and the libGLU.so file to copy in the appropriate directories. But first, i invite you again ensure that is really glu that you miss and not instead glut.
Bye

BenSanders
09-24-2005, 02:09 PM
Hi,

I don't know if I'm confusing something with glut or anything ... I don't even know what files I should have -- I've pasted the error messages I get below. This is one of the first examples in the "red book" for openGL release 1.

ben@PowerBookG4:~$ g++ double.c
double.c:1:19: GL/gl.h: No such file or directory
double.c:2:20: GL/glu.h: No such file or directory
double.c:3:20: GL/glx.h: No such file or directory
double.c:4:17: aux.h: No such file or directory
double.c:6: error: syntax error before `=' token
double.c: In function `void display()':
double.c:10: error: `GL_COLOR_BUFFER_BIT' undeclared (first use this function)
double.c:10: error: (Each undeclared identifier is reported only once for each
function it appears in.)
double.c:10: error: `glClear' undeclared (first use this function)
double.c:12: error: `glPushMatrix' undeclared (first use this function)
double.c:13: error: `spin' undeclared (first use this function)
double.c:13: error: `glRotatef' undeclared (first use this function)
double.c:14: error: `glRectf' undeclared (first use this function)
double.c:15: error: `glPopMatrx' undeclared (first use this function)
double.c:17: error: `glFlush' undeclared (first use this function)
double.c:18: error: `auxXDisplay' undeclared (first use this function)
double.c:18: error: `auxXWindow' undeclared (first use this function)
double.c:18: error: `glXSwapBuffers' undeclared (first use this function)
double.c: At global scope:
double.c:29: error: `AUX_EVENTREC' was not declared in this scope
double.c:29: error: `event' was not declared in this scope
double.c:30: error: variable or field `startIdleFunc' declared void
double.c:30: error: syntax error before `{' token
double.c:34: error: `AUX_EVENTREC' was not declared in this scope
double.c:34: error: `event' was not declared in this scope
double.c:35: error: variable or field `stopIdleFunc' declared void
double.c:35: error: syntax error before `{' token
double.c: In function `void myinit()':
double.c:41: error: `glClearColor' undeclared (first use this function)
double.c:42: error: `glColor3f' undeclared (first use this function)
double.c:43: error: `GL_FLAT' undeclared (first use this function)
double.c:43: error: `glShadeModel' undeclared (first use this function)
double.c: At global scope:
double.c:46: error: `GLsizei' was not declared in this scope
double.c:46: error: parse error before `,' token
double.c: In function `void myReshape(...)':
double.c:48: error: `w' undeclared (first use this function)
double.c:48: error: `h' undeclared (first use this function)
double.c:48: error: `glViewport' undeclared (first use this function)
double.c:49: error: `GL_PROJECTION' undeclared (first use this function)
double.c:49: error: `glMatrixMode' undeclared (first use this function)
double.c:50: error: `glLoadIdentity' undeclared (first use this function)
double.c:52: error: `GLfloat' undeclared (first use this function)
double.c:52: error: parse error before `/' token
double.c:57: error: `GL_MODELVIEW' undeclared (first use this function)
double.c: In function `int main(int, char**)':
double.c:63: error: `AUX_DOUBLE' undeclared (first use this function)
double.c:63: error: `AUX_RGBA' undeclared (first use this function)
double.c:63: error: `auxInitDisplayMode' undeclared (first use this function)
double.c:64: error: `auxInitPosition' undeclared (first use this function)
double.c:65: error: `auxInitWindow' undeclared (first use this function)
double.c:67: error: `auxReshapeFunc' undeclared (first use this function)
double.c:68: error: `auxIdleFunc' undeclared (first use this function)
double.c:69: error: `AUX_LEFTBUTTON' undeclared (first use this function)
double.c:69: error: `AUX_MOUSEDOWN' undeclared (first use this function)
double.c:69: error: `auxMouseFunc' undeclared (first use this function)
double.c:70: error: `AUX_MIDDLEBUTTON' undeclared (first use this function)
double.c:71: error: `auxMainLoop' undeclared (first use this function)
ben@PowerBookG4:~$

Overmind
09-25-2005, 02:30 AM
Try to find out where these headers are located on your system. A good guess would be /usr/X11R6/include. Then you have to compile the program with "g++ -I/usr/X11R6/include ...". Per default, the include search path is only /usr/include.

Also make sure the correct developement packages are installed, I'm not sure about ubuntu, but most distributions have their packages split into runtime (dynamic libraries only) and devel (headers, ...).

BenSanders
09-25-2005, 08:29 PM
So I tried looking in various directories for the "glu.h" etc files, but without any luck. I went to root and typed "locate glu.h" and nothing was returned. when I typed "locate GL" it returned a lot of Python directories (but I'm not too interested in Python at the moment) Any suggestions?

Thanks,
Ben

john
09-25-2005, 09:10 PM
Hi,

I, too, have Ubuntu and my OpenGL libraries are in /usr/X11R6/{include|lib}. I can't remember how I got them, so I'm surprised that you don't have them. Still, Ubuntu DOESN'T come with gcc by default, so I guess that's part of the reason :-/

at the very least you could apt-get mesa (`apt-get install xlibmesa-gl-dev xlibmesa-glu-dev') and you'd probably want glut, too. that'd definately work. You could also try updating your graphics drivers; maybe the default ones with Ubuntu don't magically instlal opengl development stuff?

cheers
John

john
09-25-2005, 09:12 PM
> PowerBookG4

er, are you using a Mac? I thought they kept their OpenGL files in 'OpenGL' rather than just 'GL'? (ie. OpenGL/gl.h, etc.)??

are you running Ubuntu on a Mac? Does Big Steve Jobs let that happen without your kneecaps being broken?

BenSanders
09-26-2005, 01:38 PM
hi, yes I am running Ubuntu on a mac -- so far it doesn't do half the things I'd expect it to do (sleep, sound, trackpad input, GL doesn't run on the graphics card b/c nVidia hasn't made the drivers for it.... it doesn't come with many dev tools but I was able to install emacs and gcc) but GL does run in "software" rather than the graphics card. So I'm trying to write a little GL program (one I copied out of the red book) because I will be taking a GL class at school in about a year and wanted to get some practice in. I guess I'll look around for the files in Tiger, too

john
09-26-2005, 03:56 PM
why are you using ubuntu under a Mac? OSX runs on top of FreeBSD, which is a unix-based operaing system, anyways...?

my colleague uses a Macintosh. I've even ported my code (which runs under Ubuntu) to the FreeBSD running under OSX. It works just like a Unix-like environment, so it's all there already!

BenSanders
09-27-2005, 12:47 PM
well, I like Linux better than OS X but couldn't bring myself to buy a "PC" laptop. So I found Ubuntu, which runs on the mac, and thought I would be happy with it. While the Unix in OS X is nice, I can't use any of the programs that are compiled under Linux (from school) on the Unix machine. I needed something that was compatable with both Unix and Linux and am glad to have found the PowerBook for the price I did -- I'm not interested in programming in Unix, but in Linux, and while they are similar, in my case Linux is preferable. Also, this link "inspired" me as it were to go ahead and try it out ...

http://www.intuitive.com/blog/ubuntu_linux_yellowdog_linux_and_mac_os_x_all_on_o ne_powerbook.html

john
09-27-2005, 04:48 PM
Hi,

you can't run programmes compiled for Linux under MacOSX because of more fundamental architecture reasons than just the Linux/FreeBSD argument; but there is nothing stopping you from *RE*compiling under OSX to get them to work.

I don't know what you need from Linux that's not in any other Un*x system. The Linux kernel is based/inspired on *a* unix kernel, but so too is the BSD kernel. As a general statement, everything else from FreeBSD and Linux is taken from the GNU foundantion, anyway, so I can't see what fundamental difference you're worried about: GCC under FreeBSD/MacOSX is the same kind of gcc under Linux, for example. (Apple have modified their gcc, so it's not QUITE the same.)

I don't use a Macintosh, but if I did, then I'd almost certainly use the unix variant it came with. Linux isn't actually all THAT good!?

But I'll ask my Macintosh colleague and see what he says

cheers
John

BenSanders
09-27-2005, 05:00 PM
how would you recompile something if the source isn't provided?

dorbie
09-27-2005, 06:12 PM
You need to accept that some things are not as simple or supported on your Mac. Either that or you've missed some SDK components in your distro installation.

Getting drivers etc may be an issue depending on distro.

You may want to download & build Mesa and see if you can use that

http://www.mesa3d.org/

But accept that you're really making life difficult for yourself by being a pioneer.

Since you want to run Linux on a Mac, for an easier life you could try Yellow Dog Linux on instead, it may give you better support.

http://www.yellowdoglinux.com/

Your CPU uses a different instruction set from a PC compatability is not possible (within reason) so unless you can get Mac binaries & drivers for everything you're seriously screwed and at best will have to download and build from source code and may have to do some porting. The best way to get good support for your system is to choose a distro that focuses on supporting it well.

I don't know what the dev environment and 3D drivers are like in Yellow Dog but I'm betting they're a bit better than your current experience.

I have seen OpenGL binaries etc for Yellow Dog that suggest that they at least have some OpenGL support built in. I've also seen mention of DRI support under Yellow Dog suggesting they have hardware syupport. So do yourself a favor and switch distros.

john
09-27-2005, 07:12 PM
well, you can't--of course--recompile code without the source, but this begs the question: who's releasing code for Linux under the PowerPC architecture? Surely all programmes either have source, or they're don't, but then likely are commerical--in which case they'd be compiled for native OSX/FreeBSD/Mac rather than Linux/Mac. WHat are you trying to run? Matlab?!

You CAN run Linux programmes under FreeBSD with the Linux compatability libraries, though. This is true certainly for the x86 distributions, but I can't imagine it'd be any different for PowerPC.

Or are you trying to run x86 Linux emulation under Mac, or something??

BenSanders
09-27-2005, 08:02 PM
thanks for the suggestions, dorbie

john, basically the programs that I am trying to run are distributed at the school I attend -- the teachers write them and consider it "cheating" to look at their source code. Unfortunately, not many comps are provided for undergrads and so I've tried to get linux up and running on my own computer ... where would you get "linux compatability libraries" that you mentioned?

john
09-27-2005, 08:47 PM
Hi,

ok, so that'd explain why you can't have the source, but presumedly your teachers are compiling under Linux but under an *x86* architecture, too? I am greatly surprised that they'd go out of their way to compile something under Linux/PowerPC just to make your life very difficult.

> where would you get "linux compatability libraries" that you mentioned?

well, that's assuming your sticking with FreeBSD under FreeBSD rather than trying some Linux distribution under Mac, of course. I actually doubt Mac would include them, since they wouldn't expect/support someone wanting to install Linux under their archecture. I'll go ask some people here who have Mac, though. They're stored in /usr/compat/linux on the x86 FreeBSD distribution I have acess to. You just (!) have to set your LD_LIBRARY_PATH to /usr/compat/linux/lib directory. Try running ldd on the executable you want to run and make sure it binds libraries stored in /usr/compat/linux to figure out what's going on. (It'll give you a list of the dynamically bound libraries it needs and which one it'll load when executed. It'll also tell you which libraries it can't find, of course.)

ok, news in: no, MacOSX doesn't include linux compatability libraries, which is no real surprise. Rhys reckons you could install FreeBSD under Mac which WOULD... but then you may as well install LInux and be done with it.

I'd just be VERY careful to make sure you're not trying to run x86 linux programmes on a PowerPC FreeBSD distribution. That will end in tears.

BenSanders
09-30-2005, 12:26 PM
ok thanks... yeah, trying to run x86 prog's doesn't work :p I've tried - but if I compile from source would that theoretically work......? I'm still a little "new" at all this since this is the first linux computer I've set up.

impeteperry
10-01-2005, 09:59 PM
Hi Ben, I am very new and this post might not be appropiate, but here goes.
I am using "Ubuntu" with "qt3" added.
I am able to compile a "opengl" example using "qmake"

BenSanders
10-02-2005, 04:51 PM
Hi Pete -- what's qt3 ? and qmake? thanks for the info

dorbie
10-03-2005, 03:15 PM
I'm sure he means the Qt GUI/framework library from trolltech which includes qmake.

Many people can develop using OpenGL on their Linux box without any bells and whistles, so this is definitely a distro/installation/dev environment issue.

john
10-03-2005, 04:44 PM
> trying to run x86 prog's doesn't work :p I've tried - but if I compile from source would that theoretically work......?

Maybe you could ask Apple for one of their x86 macs that they're going to roll out sometime? ;)

But, yes, you need to recompile the source. Maybe you could ask your lecturers to recompile it under MacOSX on your behalf? Point out to them that you're easing burden on their limited compute resources, so its in everyone's best interests! If they compile it for you, then they'd keep their source secret (so you can't be accused of cheating) but you get it to work under MacOSX and all its affiliated OpenGL goodness.

In *theory* it shouldn't be very hard to port it to MacOSX. it maybe not a straight scp and make, but still not very hard. If they sorted out a proper configure script then it'd BE as simple as scp and make. But at a guess, I'd think they wouldn't have done that. :-/

NB, the fast path to getting an OpenGL context is to use GLUT, not Qt. (Qt would be useful if you're developing an application with buttons and menu bars and scroll bars and other miscellaneous widgets; GLUT is bare-bones OpenGL context and probably what you want. It's also easier to set up and use: it doesnt' require crazy C++ language extensions to work!!)

BenSanders
10-05-2005, 02:25 PM
ok, so let's see ... basically if I just compile source under any os on any hardware I *should* get it to work? is that supposedly how it goes?

Thanks,
Ben

john
10-05-2005, 03:52 PM
well, yes. successfully compiling s/w for some architecture will mean it'll run under the target architecture, pending any miscellaneous run-time issues like missing runtime libraries, insufficient memory, missing graphics card, spontaneous combustion, etc, etc