Compiling GtkGlExt on Windows

September 21st, 2008

I was developing a 3D sample application wit Gtkmm and GtkGlExtmm. I needed to provide Windows binaries and that literally yesterday.

The developers of Gtkmm provide a all inclusive SDK and runtime installer, so that was not an issue. They actually took over maintenance for the installer and updated it to 2.12. It used to be a third party product that used in parts the glade for windows installer for Gtk+ and was always a version old. The problem was that GtkGlExt and GtkGlExtmm is not bundled with that installer, unlike other things like libxml++ are bundled with it.

On the side of GtkGlExt, there was no real help, since the binaries provided for Windows are outdated and only for GtkGlExt and not GtkGlExtmm. So I had to install the two libraries from source.

The last time I seriously developed under Windows I used Cygwin and cross built to mingw32 (native Windows) target. The reason was that Cygwin provides all necessary tools in a sufficiently recent version to bootstrap any Automake/Autoconf project and proceeded replacements for POSIX only features.

So after installing the Cygwin with the bare bones development tools, I started to build GtkGlExt. Of course it failed to build the test program in configure. I disabled the test and got it almost to compile. I fixed on odd rule in a Makefile and it finally worked fine. The same was for GtkGlExtmm. Bot took forever to complete and needed a bit of touching up. Finally I got onto my actual program. It compiled fine and then crashed with a segmentation fault. At that point my hart skipped a beat.

The reason for the test to fail, seemed to have something to do with my general setup. The first odd thing was that I needed the cygwin.dll, though I had cross built to mingw32. Although this is a common problem with C++ programs, it normally is not an issue. So I installed gdb and painfully stepped through the program, only to find out that I crashed in some trivial code in Glib::RefPtr, Glibmm’s smart pointer class. This smelled of version and compiler settings mismatch; actually It stank. At that point confused and irritated, I did not know how to really fix the problem.

I looked at the Gtk and co. binaries and found out that they where perfectly mingw32 and had zero cygwin. I then looked at my program and it needed cygwin. Since I did not have any POSIX code, the need should not have been. I figured out that It must have not used mingw32 for everything.

Since I only wanted to compile GtkGlExt and my program, I figured I did not need anything that MinGW and MSys did not provide. So I decided to install MinGW with MSys.

Configuring GtkGlExt went fine, even the test programs worked. This spurred some hope that I would get it done before this universe ends. The compile of GtkGlExt failed because some code generation scripts used from Glib needed perl. So I installed perl and cyrpt from the MSys packages and finally all went fine.

At first GtkGlExtmm did not work that fine. The reason was that there was a stray character in all CXXFLAGS within the Makefiles. Suddenly I remembered the other reason why I used cygwin last time. Well I found the stray SOH (Start of Heading) character and replaced it with a space. Now all worked fine.

I finally got my program to compile and run. Boy was I relived as this workd. The best part is I now have a sane build envirnement on my Windows PC for Gtk, something I pushed off for a relative long while.

HOWTO Compile GtkGlExt on Windows

You need:

  1. Install MinGW. This should be stright forward, but check that g++ and make are installed.
  2. Install MSys. Again simple installer.
  3. Copy the perl and crypt package to a place you find again, like C:\msys\1.0\home\username.
  4. Open a MSys shell and type cd /
  5. Untar perl: tar -xjf /home/usename/perl-5.6.1-MSYS-1.0.11-1.tar.bz2
  6. Untar crypt: tar -xjf /home/usename/crypt-1.1-1-MSYS-1.0.11-1.tar.bz2
  7. Copy GtkGlExt and GtkGlExtmm source to a place find again. C:\msys\1.0\home\username.
  8. In the MSys shell go the place with your sources: cd /home/username
  9. Set the environement variable PKG_CONFIG_PATH to msys local path: export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  10. Untar GtkGlExt: tar -xzf gtkglext-1.2.0.tar.gz
  11. Enter the GtkGlExt source tree: cd gtkglext-1.2.0
  12. Configure, build and install GtkGlExt: ./configure && make && make install
  13. Exit GtkGlExt source tree: cd ..
  14. Untar GtkGlExtmm: tar -xzf gtkglextmm-1.2.0.tar.gz
  15. Enter the GtkGlExtmm source tree: cd gtkglextmm-1.2.0
  16. Configure, build and install GtkGlExtmm: ./configure && make && make install

Now you are done. You can find the binaries in C:\msys\1.0\local\bin, along with all other stuff required to build your application.

Binary GtkGlExt

Alternativly you can use my build result and downlaod gtkglextmm-120-win32.tar.gz.

Experiments with Heightmaps

June 14th, 2008

Don’t ask me how I got the idea but I started experimenting with height maps. It is incredible how much one can do with very little effort.

Heightmap

Heightmap

I riped off a few heightmaps from the internet. Here you can see a mountain range.

The results are quire nice. The only problem comes from the fact that images only have 256 distinct height values. The result can be seen in the valley, the different levels are distinctly visible. But the computation of the lighting is still slightly broken. Either there is a real bug or it is a case of “gourand just won’t cut it”. Grourand shading, the default for openGL, is quite good but in many cases where the geometry is complex the lighting samples are not sufficient.

The shading / lighting problem can be solved in many ways, but on obvious solution is per pixel lighting. The visual artifacts in the plane can be solved with a smoothing filter, but I fear that that will destroy the features in the mountains.

The rendering performance is not great, since a relative trivial implementation was used. I am planing to implement ROAM. Also just reducing the samples in areas with little change can obviously help.

Terrain

Terrain

Terrain

Terrain

Terrain

Terrain

You Have To Burn The Rope

May 1st, 2008

If you think portal was an innovative short game, here comes the next Developer Choice Award winning game You Have To Burn The Rope. (Well maybe…)