Application develop --> GTK+OpenGL under Linux

I’m not very good in english because I’m italian…

I’m doing an application under Linux for the Venice University (ITALY). My application will be a graph viewer for web sites so I need to have a window (probably develop with GTK) with a lot of buttons and an open gl box (with the 3d graph)…Can this two libs interact together? This are my ideas to develop my project (in bold there are some questions):

[ul][li] I will create the base of the project implementing the open gl box in C…or C++??? (spheres and cylinders will be my graph). I need to install mesa3d? Where can i found a big tutorial to do this in the perfect way?[] After that I will create the GUI with GTK. Is this the best choice I can do or can I use other libs with simple Open GL interaction?[] At the end I will create the interaction [/ul].[/li]Thanks if someone will help me, I put his name in the Credits box o my project…

see gtk-glarea.

GtkGLArea is deprecated.

What you want is GtkGLExt .

And have a look at the examples that come with GtkGLExt to see what’s possible with it

Hey Paisano!

> I’m not very good in english because I’m
> italian…

Well, let’s not mistake correlation for causation.

> Thanks if someone will help me, I put his
> name in the Credits box o my project…

Now now. No need for that – unless someone actually contributes some source code.

> Can this two libs interact together?

Yes, GTK+ and an OpenGL implementation can almost always work together. Whether it’s Mesa3D’s, nVidia’s, or whomever’s.

> [Do] I need to install mesa3d?

That depends. If you are using the DRI drivers for your video card, and you want 3D hardware acceleration, then yes – unless the DRI is already installed, in which case you should already have mesa installed along with it.

If you aren’t using the DRI drivers (shame on you! then you’re probably using proprietary drivers with your card (for example, nVidia drivers for an nVidia card) and have no need of Mesa. In this situation, you could use Mesa for rendering done in-software if you wanted to, but it’s much slower than with hardware acceleration.

> Where can i found a big tutorial to do
> this in the perfect way?

The faq at http://dri.sourceforge.net/ is very helpful. There’s faq pages on this site as well. Also look for sample code that comes with whichever GUI toolkit you choose.

> Is this the best choice I can do or can I
> use other libs with simple Open
> GL interaction?

I’m just starting to fiddle with http://www.fltk.org/ and it looks pretty good. It’s C++. Actually, the way it looks to me so far is that v1.1.3 is pretty much “C with classes” whereas v2.0 is more hardcore C++ (exceptions, templates, etc.).

Note that GTK+ is a C toolkit, but an object-oriented one.

I wanted to give gtkmm (a C++ wrapper for GTK+) a try but couldn’t figure out how to install the darn thing.

Ciao!

Fantastic JMG!

Yesterday I’ve done a nice gtk interface for my project and tomorrow morning I’ll try to interoperate with gtkglext (very cool).
I’ve another question for you:

I want to buy a video card with full linux drivers…what can I buy.

Thanks a lot for your perfect answer…

Grazie

Ciao

Matrox or NVIDIA.

Personally I would go for NVIDIA, mostly because their drivers are flaky^H^H^H^H^rocksolid!
(the latest driver contains a bug especially for Gnome users that makes everything related to 2D really slow, the 3x.xx driver is very fast though)

Or Matrox because it’s the best card for using DirectFB :stuck_out_tongue:
(I guess you’re not interested in that though, you won’t have accelerated 3D support (for now))

Originally posted by JMG:
I wanted to give gtkmm (a C++ wrapper for GTK+) a try but couldn’t figure out how to install the darn thing.

What was the problem?

It’s very easy to install Gtkmm (remember that you’ll need libsigc++ 1.2 though, there’s no 2.x version)

> I want to buy a video card with full linux
> drivers…what can I buy.
http://dri.sourceforge.net/dri_status.phtml

I went with the Matrox G400 for a number of reasons:

  1. I could use the DRI/Mesa drivers with it.

  2. Excellent 2d quality (noticably better than my nVidia GeForce 2 MX 200) with my analog lcd display.

  3. Inexpensive.

  4. I didn’t need ultra fast 3d performance.


richardve,

Wow. I haven’t posted here in a while (somehow I keep making my way back) but I recognize your name. :slight_smile:

Lessee… I had some notes that I was keeping during my attempts, but I think I’ve thrown them out (lesson learned for the day: save those notes in my little programming file cabinet!).

I’m running redhat8 at the moment (soon to transition to debian woody). As I recall, I wanted to use the newest gtkmm 2.2.0. I Couldn’t find an rpm, so I was trying to build from source. configure went a little ways but then gave me the following error:

checking for sigc+±1.2 >= 1.2.0 glib-2.0 >= 2.2.0 gobject-2.0 >= 2.2.0 gmodule-2.0 >= 2.2.0… Package sigc+±1.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `sigc+±1.2.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘sigc+±1.2’ found

configure: error: Library requirements (sigc+±1.2 >= 1.2.0 glib-2.0 >= 2.2.0 gobject-2.0 >= 2.2.0 gmodule-2.0 >= 2.2.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.

I believe I have all the prerequisites for gtkmm 2.2.0 installed. libsigc+±1.2.3 was installed by-hand (configure; make; make install to /usr/local/lib). Other rpm packages (glibc-2.2.93, etc.) are all there and installed, so I don’t get it.

—j

Interesting,… I just noticed that I’ve got a directory:

/usr/local/lib/pkgconfig

with a file in it called sigc+±1.2.pc containing the text:

prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: SigC++
Description: Type-safe signal and callback system for C++
Version: 1.2.3
Libs: -L${libdir} -lsigc-1.2
Cflags: -I${exec_prefix}/lib/sigc+±1.2/include -I${includedir}/sigc+±1.2

and since I do in fact have a /usr/local/lib/sigc+±1.2 directory (!) things look sorta kosher. Maybe the configure script is looking for an installed rpm?

Hmm… there’s a binary /usr/bin/pkg-config which uses .pc files – and also looks at a PKG_CONFIG_PATH env var.

Ok, I set

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

but now I get… DOH!

Looks like I need a newer glib (2.2.0 or newer). Sorry. :frowning:

Trouble is, looking at freshrpms for redhat8 (“phyche”), they don’t even have a glib listed. Searching rpmfind.net they only have the older 1.x rpms.

I don’t think I have the experience to download the glib 2.2.0 sources, build them, turn them into an rpm, and use that to upgrade my current installation.

Hmm… fltk seems a whole lot easier. :slight_smile: I already managed to retrieve the newest 2.0.x sources via CVS – and they built & installed successfully. :slight_smile:

Wow. Sorry for this going so far off-topic. I hope some gentle readers out there got something from it.

pkg-config is a handy little tool for querying compiler and linker flags.

ie. Try the following command: “pkg-config --cflags gtk±2.0” and you’ll see a lot of include directories.

This used to be done using tiny whatever-config programs (Gnome 1.x) but now every Gnome program is using one universal program (pkg-config) for saving/querying all compiler flags.

Using “pkg-config --list-all” you can see what programs / libraries are installed on your system (this doesn’t have anything to do with rpm btw, it’s just for when you’re compiling things yourself).

Anyway, on Red Hat, everything is installed into /usr by default.
But the autotools default to /usr/local.

pkg-config is installed into /usr so it automatically looks into /usr/lib/pkgconfig, but not /usr/local/lib/pkgconfig since it isn’t installed into /usr/local.
You can fix that by adding “export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig” to your ~/.bashrc or ~/.bash_profile (doesn’t really matter wich one)

To install new software (from source) into /usr you can use the prefix option when configuring the software, eg: “./configure --prefix=/usr

Personally I do this for every type of program I’m installing from source.
(this is not a good thing to do though, system specific software should actually go in /usr and additional software should go in /usr/local or /opt/blah)

The reason you can’t find a RPM or so for glib is because glib is a part of Gtk+
Installing Gtk+ 2.2 will also get you Glib 2.2

Also, if you’re going to install Gtk+ 2.2, I’d also install Gnome 2.2 (if you’re using Gnome, that is) because it’s a bit nicer and faster in some areas (especially Nautilus), and more apps are HiG-ified (HiG == Human Interface Guidelines).

Installing Gnome 2.2 is very easy using the Garnome scripts (there’s also some scripts in it to install Gtkmm).

Well, I hope this long and way offtopic post helps a bit :mrgreen:

Originally posted by jmg:
[i]
richardve,

Wow. I haven’t posted here in a while (somehow I keep making my way back) but I recognize your name. [/i]

Woah, that’s the first time I actually get recognized by someone

(and yeay, we’re ‘oldbies’ now)

Oh and by the way, when installing program into /usr/local you should also (once) add /usr/local/lib to /etc/ld.so.conf

Otherwise the program won’t be able to find its libraries.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.