OF gtk+ port

Hi

One of the things that doesn’t work in linux version of OF is fullscreen, it’s a glut issue so I don’t think it will be solved in the short term (you can use game_mode but then you can’t go outside that window). Glut also have some problems managing multihead configurations under linux.

I’ve made an OF version substituting glut with gtk+ / gtkglext. It solves the fullscreen problem and have some advantages over glut, like more complete event management and some cool tricks like transparent-windows.

It has dependencies with some libraries:

GLib (similar to poco c++)
pango (font rendering system based on freetype)
cairo (vector graphics and image compositing)

I have only tried it under linux, if you want to give it a try, here are some instructions:

  1. Download OF 0.05 for linux

  2. Install the libraries headers. In debian/ubuntu:

sudo apt-get install libgtk-dev libgtkglext1-dev
3. Download the modified OF and uncompress it in the libs directory
http://65.111.166.199/OF/openFrameworksGtk.tar.gz

  1. Download the examples and uncompress them in the apps/examples directory. There are only the graphics (with f key to go fullscreen), events (with a new scroll event) and window examples.
    http://65.111.166.199/OF/examplesGtk.tar.gz

  2. Open the examples from codeblocks compile and run as you’d normally do

To compile any other example in codeblocks, go to:
project > properties > libraries

and add the gtkglext-1.0 to the libraries used in project.

The only function which I had to change it’s signature is ofSetupScreen() that it’s now ofSetupScreen(int w, int h). Also ofGetMilliseconds() doesn’t work and ofDrawBitmapString draws a strange character at the beginning of every string that I haven’t managed to get rid of and \n not implemnted, but appart from that every example works without problem.

GTK is multiplatform, so it shouldn’t be a problem to run it under windows. You can download the libraries from:
http://www.gtk.org/download-windows.html
http://www.k-3d.org/gtkglext/Main-Page

There’s also an installer for both gtk+ and gtkglext libraries and headers at:
http://www.bonifazi.eu/appunti/2008/02/-…-ndows.html

Under MacOsX it should be a little bit more complicated because there isn’t already an official native release (mostly because gtk apps have been runing under X11 for macosx). There are some instructions on how to compile gtk natively for Mac here:
http://developer.imendio.com/projects/gtk-macosx/

hey arturo!

I just tried following your instructions for an ubuntu install.
Got the gtk dev packages fine - looks like it is all there

  
/usr/include/gtkglext-1.0/gtk  
gtkgldebug.h  gtkgldefs.h  gtkgl.h  gtkglinit.h  gtkglversion.h  gtkglwidget.h  
  
ls /usr/include/gtkglext-1.0/gdk  
gdkglconfig.h   gdkgldrawable.h   gdkgl.h        gdkglshapes.h   gdkglwindow.h  
gdkglcontext.h  gdkglenumtypes.h  gdkglinit.h    gdkgltokens.h   glext  
gdkgldebug.h    gdkglfont.h       gdkglpixmap.h  gdkgltypes.h    x11  
gdkgldefs.h     gdkglglext.h      gdkglquery.h   gdkglversion.h  

But if I compile the examples you posted I get:

  
          from /home/theo/Desktop/005-FAT-GTK/apps/examplesGtk/eventsExample/src/main.cpp:1:  
../../../libs/openFrameworks/graphics/ofGraphics.h:6:21: error: gtk/gtk.h: No such file or directory  
../../../libs/openFrameworks/graphics/ofGraphics.h:7:23: error: gtk/gtkgl.h: No such file or directory  

I don’t see a project > properties > libraries in my CodeBlocks
But Looking through the build options -> search directories and build options -> linker settings I don’t see any references to the gtkglext-1.0 folder. Did you include it in your CB global includes?

I tried adding /usr/include/gtkglext-1.0/ to the search directories but then it gave me:

  
In file included from ../../../libs/openFrameworks/graphics/ofTexture.h:5,  
                 from ../../../libs/openFrameworks/ofMain.h:17,  
                 from /home/theo/Desktop/005-FAT-GTK/apps/examplesGtk/graphicsExample/src/main.cpp:1:  
../../../libs/openFrameworks/graphics/ofGraphics.h:6:21: error: gtk/gtk.h: No such file or directory  
In file included from /usr/include/gtkglext-1.0/gtk/gtkgl.h:22,  

Looks like it found the first gtkglext include but something with the path prevented it from recognizing the leading gtk/

Anyway I am going to keep searching on how to get it to compile - thought I would let you know in case someone else tries to follow the instructions.

Cheers!
Theo

Hi theo

In my code blocks there’s a tab in the project > properties window called libraries.

Under linux with every lib…-dev installed there’s a pkg-config package that automatically sets the includes and libs for gcc. When you set a library in your project under this libraries tab it just adds the pkg-config call to the gcc options. If you don’t find the libraries tab (it’s weird I’,ve the last svn codeblocks version and it’s already there) you can add the extension block to the cbp project:

  
  
<Project>  
....  
<Unit filename="../../../libs/openFrameworks/video/ofVideoPlayer.cpp">  
	<Option virtualFolder="libs/openframeworks/video/" />  
</Unit>  
<Unit filename="../../../libs/openFrameworks/video/ofVideoPlayer.h">  
	<Option virtualFolder="libs/openframeworks/video/" />  
</Unit>  
  
  
<Extensions>  
	<code_completion />  
	<envvars />  
	<lib_finder>  
		<lib name="gtkglext-1.0" />  
	</lib_finder>  
	<debugger />  
</Extensions>  
  
  
</Project>  
  

Also note that the only examples adapted to gtk are the graphicsExample, eventsExample and one more I don’t remember but the rest should work just by adding the library.

I’m trying to compile it and although it compiles ok for me, I get an undefined reference when linking, i’ll try to solve it and post about it but sure it has to do with the order of the included libraries.

ahh - I think I might have a slightly older version of Codeblocks - as that setting is not there.

all that stuff I have to access through the “build options” window.
in the end I got it to compile by putting these settings in:

  
build options -> linker -> linker settings:   
libgtkglext-x11-1.0  
  
build options -> search paths  -> compiler:   
/usr/include/gtkglext-1.0/  
/usr/lib/gtkglext-1.0/include/  
  
build options -> search paths -> linker:   
/usr/lib/gtkglext-1.0/include/  

then it compiled and ran fine.

Some things I noticed that didn’t work though:

  • ofGetFramerate() - as it uses ofGetElapsedMillis()
  • OF_KEY_UP / DOWN / LEFT / RIGHT - had to put in the numerical values instead
  • Videoplayer doesn’t seem to play a video - just shows the first frame.
    this could be a timing thing - or even ofGetElapsedMillis();

But apart from that it was great - having fullscreen was so nice :smiley:
thanks!

T

Yes, ofElapsedMillis is not implemented as it has dependencies with glut so I supose the videoPlayer problem is because of that as the linux module works by calculating the time between frames.

I forgot to tell in my previous post that executing:

pkg-config --libs --cflags gtkglext-1.0

(or any other library) from a console you get the output of includes and libraries needed to compile a project that has dependencies with that library.

Hi Arturo,

Any news about gtk (needed for fullscreen) and videoplayer in linux?

Cheers

Hans

Hi hans

I developed this just as a proof of concept, and haven’t done anything with it since then.

The problem is, videoplayer needs ofGetMillis that has dependencies with glut and I didn’t implement it, but it doesn’t seem too hard.

I’m going to try to replace the current ofGetMillis implementation and post an update.

Also note there’re some problems with ofDrawBitmapString

Arturo thanks,
I’ll wait for your update.

When it’s too big an issue I can always fall back to OS X :wink:

I was so happy with the opportunity to work fullscreen that I took the ofDrawBitmapString issue for granted. Next week I have a presentation in Italy that hopefully will be documented (photos as well as video) and I can put stuff online.

Cheers

Hans

Solved…

http://65.111.166.199/openframeworks/gtkofgetMillisPatch.zip

just substitute the files with the ones in the zip.

Arturo, I love you (in a very manly, platonic way ;-))

I can test it tomorrow. I’ll let you know.

Cheers

Hans

:lol:

Hi Arturo,
Got it running on my (too slow) 32 bits ubuntu system. It cleans the screen very well after termination, so thats all ok.

On my core2duo system it produces segmentation faults in 64 bits (also ubuntu), after I copied the gtk-libs and patched them, so I concentrate on finishing the application, after which I’ll rebuild the core2duo to a 32 bits ubuntu system. Which should be the solution at this stage.

Thanks
Hans

Hey Hans

Does the segmentation fault occurs at the end, when closing the application or it doesn’t work at all?

Hi Arturo,

The Segmentation fault is directly at the start. No messages, just crash.
But at the moment I’m trying to get an application done and already converted the system to 32 bits (and it runs perfectly), sorry.
After the Luce dipinta festival (Coldrano Italy - plug!), I’ll be happy to rebuild the system again to test this crashing. Again, thanks for the gtk fix (I’m perfectly happy with it now).
I’ll post again in this section, when I’ve rebuild the core2duo system to 64bits. This can take a few weeks though.

Cheers

Hans

No worries, indeed I don’t think it’s worth to put too much effort in this, it’s really platform specific and affects very much of the core files in oF so I don’t think it’s a good solution as it is now.

Hi Arturo,
our little demo at Luce dipinta was a great success with the public and pro’s!
Unfortunately I ended up in hospital and had a serious operation (just got out after 5 days).
I’m typing this with a on-screen keyboard arrggghhhh!
Got loads and loads of videos and stills. when they are online I give a holler
cheers
hans

Hey Hans

Congratulations for the presentation, and good luck with the recovery!