PDA

View Full Version : getting started on linux



petrF
01-20-2010, 04:38 AM
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

Stephen A
01-20-2010, 05:24 AM
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).

ZbuffeR
01-20-2010, 05:33 AM
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 ?

Dark Photon
01-20-2010, 05:58 AM
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
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.

petrF
01-20-2010, 08:14 AM
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?

petrF
01-20-2010, 10:19 AM
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

ZbuffeR
01-20-2010, 10:31 AM
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.

Dark Photon
01-20-2010, 07:56 PM
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?
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.

ZbuffeR
01-21-2010, 01:53 AM
<library>-dev on Ubuntu and other Debian variants.
<library>-devel is for RedHat/Fedora variants.

petrF
01-21-2010, 03:17 AM
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
#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 ();
}

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'
...

ZbuffeR
01-21-2010, 06:26 AM
"undefined reference" is a linker error.
What is your compile/link command line ?

Dark Photon
01-21-2010, 06:33 AM
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...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'
...
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.

petrF
01-22-2010, 08:43 AM
$ g++ -o test-sdl test-sdl.cpp -lSDL is my compile command

petrF
01-24-2010, 02:07 AM
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

petrF
02-06-2010, 05:09 AM
is it possible to use python instead of c++? if so, whad do i need to install and what is the compile command?

marshats
02-06-2010, 08:33 PM
I am a fan of C/C++ but yes you can use python with openGL based on this Linux Journal article (http://www.linuxjournal.com/article/4830).

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 (http://pyopengl.sourceforge.net/) will be the most up to date resource.

And some more examples can be found at NEHE python. (http://www.pygame.org/gamelets/#NEHE)

Have fun!

ps ruby may be another alternative if you are curious see ruby-opengl (http://ruby-opengl.rubyforge.org/tutorial.html). 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.

beginnertom
02-16-2010, 11:12 PM
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.

Dark Photon
02-18-2010, 07:04 AM
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 (http://www.opensuse.org/). 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.

ZbuffeR
02-18-2010, 01:02 PM
Ubuntu is dead easy too, and they have very helpful forums for beginners.

beginnertom
02-19-2010, 12:54 PM
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 (http://www.opensuse.org/). 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.

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