Archive

Archive for January, 2009

Emacs for Blogging

January 31st, 2009

This is a test post using weblogger.el for Aquamacs 1.6*. If it works
I’ll probably use it as my main offline blogging client.

Aquamacs is a Mac port of the popular multi-purpose program
Emacs. Emacs is used for many purposes such as tetris, email,
calendar and organiser…. There are even rumours that it can be used
for editing text!

Self, Software , , ,

GLUT on Mac OS X

January 30th, 2009

I was having a problem using Glut (GL Utility Toolkit) on my Mac today – despite the number of sites saying that it was a snap to set up:  ”Just add the GLUT.Framework to your project and compile.”  – Well, my program was compiling OK, but running it would always result in a “bus error” and drop into the debugger.  I tried various combinations of compiling from command line, running under X11, trying port and fink for different libraries – What could this weird problem be?

I eventually came across the root of the problem and since I haven’t seen it posted anywhere on the web I decided to add my own contribution to the “GLUT on OS X” billboard.  I’ll try to give the complete setup I used to start a Glut project in XCode.

Setup XCode Project

Like many others will suggest, open XCode (or project builder) and create a Standard Tool (or C++ Application or whatever). I recommend a Standard Tool because you just get a basic main.c file and that’s enough. Add the GL.Framework and GLUT.Framework files from /System/Library/Frameworks.  (This is where they are on my Mac)

Rename the file main.cpp/m to main.c for a basic C application.  (I’ll stick with this for now as it is sufficient)

Modifying the standard code

Headers need to be changed from gl/ to OpenGL/ and GLUT/ in order to correctly locate the headers in OS X’s frameworks.  The top of main.c should read as follows:

  1. #include <OpenGL/gl.h>
  2. #include <OpenGL/glu.h>
  3. #include <GLUT/glut.h>

And here’s the bit that was killing me.  Most of my glut code is based on the skeleton provided from NeHe’s tutorials which initialise glut then initialise opengl then sets up glut’s window properties. like so:

  1. int main ( int argc, char** argv ){
  2.     glutInit ( &amp;argc, argv );
  3.     initGL ( );
  4.     glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE );
  5.     glutInitWindowSize ( 500, 500 );
  6.     glutCreateWindow ( "NeHe’s OpenGL Framework" );
  7.     glutDisplayFunc ( display );
  8.     glutReshapeFunc ( reshape );
  9.     glutKeyboardFunc ( keyboard );
  10.     glutSpecialFunc ( arrow_keys );
  11.     glutMainLoop ( );
  12.     return 0;
  13. }

OK, everything looks good right?  Not for OS X apparently.  Maybe this is obvious for some people but I had to trace a bit to see what was causing my problem.  As it turns out I was able to fix it by moving the initGL call after all the glutInit*/glutCreate* calls.  Thus, my new main looks as follows:

  1. int main ( int argc, char** argv ){
  2.     glutInit ( &amp;argc, argv );
  3.     glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE );
  4.     glutInitWindowSize ( 500, 500 );
  5.     glutCreateWindow ( "NeHe’s OpenGL Framework" );
  6.     initGL ( );
  7.     glutDisplayFunc ( display );
  8.     glutReshapeFunc ( reshape );
  9.     glutKeyboardFunc ( keyboard );
  10.     glutSpecialFunc ( arrow_keys );
  11.     glutMainLoop ( );
  12.     return 0;
  13. }

I hope this is helpful to someone else since it seems to be a rather obscure error (that only affects Mac OS?).  I’m glad I caught it though – as much as I intend to use Cocoa in the future, it’s nice to know a simple framework is still available. :-)

Programming , , , , ,

IT Department:

January 23rd, 2009

This is an automated message from corporate I.T.

We shut down your computer last night.  Oh, we installed some updates first.  You are too dumb to manually install updates, so we force them upon you at inconvenient times.

Sorry for any inconvenience, loss of data, waste of time, closing all your browser pages, etc.

Enjoy getting back to that state in the morning.

Self, Software , ,

Flash Harry

January 23rd, 2009

OK, this is a quickie as it’s a bit late. It’s just kind of an update and a plug for my flickr feed.

So, last weekend I went to see the Flash Harry concert in the Odyssey.  Flash Harry are a Queen tribute band and they were pretty awesome.  What made the evening even better, though, was that they were accompanied by the Ulster orchestra and Magee University Choir (which my sister is in!)

I tried to take a few covert snaps here and there when the idiot’s usher’s back was turned…

…ok, I took 500 photos.

If you’re interested, you can check out a few of my favourites on flickr.

So back to the concert itself.  They played for a few hours and covered pretty much all the well known Queen songs.   A lot of the songs had additional orchestral arrangements and some had very cool backing by the choir (Someone to Love, Bohemian Rhapsody).

Self , , , ,