Starting OpenGL In Linux

Started by
14 comments, last by Halsafar 18 years, 5 months ago
http://www.opengl.org/resources/faq/getting_started.html This page is confusing me. What do I need to start programming for OpenGL using C++ in Linux. It says I may need some Mesa OpenGL-Work-Alike... But I know my current configuration can run openGL apps just fine (Cedega tests for example). I assume I need an SDK of somesort... Otherwise I'm beginning with the all-to-famous NEHE tutorials :)
Advertisement
if other GL apps work fine i think all is in order.

check /usr/include for GL headers. if they're not there then you will need them

just remember the includes and (if using gcc on command line) the relevant -l things.( i cant quite remember them... )
Well I checked that directory and there are no includes files which start with GL or resemable anything like openGL.

I do know I have OpenGL up and running tho, Cedega demands an OpenGL test before running, it showed a window up and some gears turning, this ran at 1000fps on my system.

By relevant -l commands, care to elaborate?

Thanks,
Halsafar
Quote:Original post by Halsafar
Well I checked that directory and there are no includes files which start with GL or resemable anything like openGL.

They'd all be in a subfolder labeled GL (GL/gl.h, GL/glu.h, GL/glut.h are common ones)
Quote:By relevant -l commands, care to elaborate?

These tell GCC what to link. For example, if I wanted to do some programming using libglut.so, I'd comple using something like:
gcc -lglut example.cpp -o example

-L flags may also be necessary to specify where a library file is, for example:
gcc -L/usr/X11R6/lib -lX example_xwindows_program.cpp -o example
i havent tested this, im under windows at the minute, but something like this

(if anyone does know, please post )

g++ -o program source.cpp -lGL -lGLU

the second one is if you use GLutilites.

i think theres one for the GLaux utilites but im not 100% sure...
NeHe's tutorials mostly are targetted at wgl hence use user32 and are win32 gui apps.

But the principles apply, and many have been ported to Linux, with or without the use of SDL or something else.

The easiest way to get apps working is to use glut. glut is not really very good for games, but works.

The exact libraries you need to link a GL application might vary slightly, but the following works for me:

LIBRARIES = -lX11 -lXi -lXmu -lSDL -lGL -lGLU -lm
LIBDIR = -L/usr/X11R6/lib -L/usr/local/lib

Some of these are probably unnecessary. Don't use -LSDL if you're not using SDL.

Mark
There seems to be a little debate, but it really isn't too complex.

If you need the gl library (which you most definitely do), then use:
#include <GL/gl.h>
in your files. When you compile, add
-lGL
to the compiler flags. (If you link manually, then do it then)

If you need the glu library, use:
#include <GL/glu.h>
and
-lGLU

For glut:
#include <GL/glut.h>
-lglut

That's it for the OpenGL library. If you use additional libraries, then you have to include those too, of course.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Well to be honest I'm not getting anywhere with this heh.
Its not the compiling, I just cannot find a tutorial which even answers my simple questions... Like how do I create the window, what do I use to do it... Well and I cannot compile any of the source I do find :)
missing gltk.h on most.


Edit:
Okay I need GLUT.... I cannot find the Linux download on the opengl main webpage... I can only locate the Win32 Source.
What distro of linux are you using? I didnt have a problem getting GL up and running fine in Arch or Gentoo, some distros fiddle with where the files are put (SuSE..)
Adventures of a Pro & Hobby Games Programmer - http://neilo-gd.blogspot.com/Twitter - http://twitter.com/neilogd
I am using Mandriva 2006.
OpenGL is installed and all its headers are there.
I found GLUT, installed it.

All the headers exist in /usr/inclue/GL/.

Anything I plainly compile gives me tons of missing reference errors. Which is where I came back here to find the flags you guys dicussed.

None of them work, I've tried everything here and all I get is missing reference errors on every call to a GL or GLUT function. This leads me to believe I do not have the OpenGL Libraries... the Devel I guess. But I know opeNGL works, Mandriva 2006 has a test feature for it, and Cedega works 'kinda' well.

This topic is closed to new replies.

Advertisement