Getting started on linux

Hello everybody,
i’m trying to start working in openGL on ubuntu, but i can’t find anything helpful fot my very start. All tutorials i have found start from basic programming, but i can’t find out what to install, what to get and where using what tools to make anything.
Thanks for any help

I assume you already have a compiler. If not: “sudo apt-get install build-essential” will install a C compiler.

To develop OpenGL applications you need a couple of ‘dev’ packages. If I remember correctly, the following command will do the trick: “sudo apt-get install libgl1-mesa-dev mesa-common-dev”

You would probably wish to use something like SDL to make things simpler: “sudo apt-get install libsdl-dev”

Gedit is an simple but good editor. If you want a full-blown IDE, I’d suggest going for ‘Geany’ or ‘Codeblocks’ (the latter is cross-platform, which is nice).

Finally, you should check Programs -> Ubuntu Software Center. It is dead simple to use and allows you to search and install programs you might find useful (check under the “Programming” section, it lists available compilers, libraries, IDEs, documentation and everything you might need).

Try this first :
http://ubuntu-gamedev.wikispaces.com/How-To+Setup+SDL+for+games+development
Read the rest while you are at it :
http://ubuntu-gamedev.wikispaces.com/3D+HowTos

Do you have more precise questions related to OpenGL ?

Honestly, if you are just starting out, I’d start coding in GLUT. Plenty of tutorials out there on that too with 100% working source. GLUT hides all the window manager interaction, allowing you to focus on GL.

So install the “freeglut” and “freeglut-devel” packages to get GLUT. I’m assuming you’ve already installed the vendor’s drivers for your GPU.

To compile your GLUT-based test programs, use:

(For C++:) g++ -o tst tst.cxx -lglut -lGL
(For C:) gcc -o tst tst.cxx -lglut -lGL

If any questions, follow-up.

thanks, it seems to work.
I installed all you have told and in the articles you linked me to i read another howto and tried the “test” at the end - it showed nothing, but i expect “no error” was the proof it’s all okay.
So, the last basic question: when i use any library using “include”, i need to have a copy in the same file as the file i want to compile?

ups, i’m little confused in what libraries do i need while using ubuntu? i got some examples from school, but it’s all for windows and yet i haven’t found out how to handle the missing stuff messages

Open synaptic, search for what you need, often it will be there but not the -dev part, so add that, apply, done.

For more details about programming in general on Ubuntu, head over http://ubuntuforums.org/ , they are very good.

This got lost in the translation. When you #include a library include file, that library’s header files need to be installed. Also when you link with a library, the library object file needs to be installed. Typically the includes are stored in a package named <library>-devel, and the library object file is stored in a package named <library>.

If you’re having trouble, post the error message.

<library>-dev on Ubuntu and other Debian variants.
<library>-devel is for RedHat/Fedora variants.

i’m using the on-line redbook at http://www.glprogramming.com/red/ and the first should-be working example don’t work to me; it starts with
[b]#include <GL/gl.h>
#include <GL/glut.h>

void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);

/* draw white polygon (rectangle) with corners at

  • (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
    */
    glColor3f (1.0, 1.0, 1.0);
    glBegin(GL_POLYGON);
    glVertex3f (0.25, 0.25, 0.0);
    glVertex3f (0.75, 0.25, 0.0);
    glVertex3f (0.75, 0.75, 0.0);
    glVertex3f (0.25, 0.75, 0.0);
    glEnd();

/* don’t wait!

  • start processing buffered OpenGL routines
    */
    glFlush ();
    }[/b]

and returns error:

/tmp/ccodHrad.o: In function display()': test-sdl.cpp:(.text+0xe): undefined reference to glClear’
test-sdl.cpp:(.text+0x2d): undefined reference to `glColor3f’

“undefined reference” is a linker error.
What is your compile/link command line ?

You need to add -lGL to the link line. E.g.:

> g++ -o test_sdl test_sdl.cpp -lglut -lGL

-l<libname> instructs the linker to go looking for a library named lib<libname>.so or lib<libname>.a and link it in.

$ g++ -o test-sdl test-sdl.cpp -lSDL is my compile command

the suggested g++ -o test_sdl test_sdl.cpp -lglut -lGL works well, now after i realised i use slightly different name of files, shame on me;
thanks for helping me so much, i hope now i’ll be able to get through the tutorials and examples

is it possible to use python instead of c++? if so, whad do i need to install and what is the compile command?

I am a fan of C/C++ but yes you can use python with openGL based on this Linux Journal article.

As a test I installed “python-opengl” with synaptic (apt-get would work too). I then cut-n-pasted listing 1 from the Linux Journal article. It did not work – probably due to it being an 8 year old article and the opengl-to-python mappings changed a little. It was an easy fix though – change the lines


glutSetDisplayFuncCallback(display)
glutDisplayFunc()

to


glutDisplayFunc(display)

which frankly makes more sense ie it exactly maps to the C glut function of the same name.

Also be warned that the article being so old uses an outdated “Togl” library that I couldn’t get working on my machine … confirmed by reading the comments at the bottom of the article. But the article should still give you a start – it looks like going to pyopengl will be the most up to date resource.

And some more examples can be found at NEHE python.

Have fun!

ps ruby may be another alternative if you are curious see ruby-opengl. On ubuntu this is a simple install of “libopengl-ruby” which has the nice benefit of installing some Redbook and Orange Book examples in /usr/share/doc/libopengl-ruby/examples/ by default.

i am a beginner too.
i think develop under linux is very hard work.
many packet need to be install.
and you will not found where it is.

Try OpenSuSE 11.2. Free download and easy install. I’ve been deving OpenGL on Linux for about 10 years, and I almost never have to go build a package – they’re all just there in the package manager! This distro is great for development! All available through a std GUI, which makes MS Windows users feel more comfortable.

If you’re a new user, do not start with Gentoo or Debian (other Linux distributions), IMO. YMMV, but that’s my experience.

Ubuntu is dead easy too, and they have very helpful forums for beginners.

Try OpenSuSE 11.2. Free download and easy install. I’ve been deving OpenGL on Linux for about 10 years, and I almost never have to go build a package – they’re all just there in the package manager! This distro is great for development! All available through a std GUI, which makes MS Windows users feel more comfortable.

If you’re a new user, do not start with Gentoo or Debian (other Linux distributions), IMO. YMMV, but that’s my experience.
[/QUOTE]
i donn’t know opensuse.i meand i am not the professional of IT .
i think that
you must be good at this.
thank your advice
thank you