Archive

Posts Tagged ‘mac’

C++ Templates for XCode 3.2

November 19th, 2009

Here are a couple of Project templates I made for XCode 3.2. One for a WxWidgets based project (wxMac 2.8), and one for a GLUT project. Hope they work.

  • GLUT C++ Project – Initializes GLUT and creates a scene containing a cube which can be rotated using the keyboard arrow keys. toggle an axis widget using ‘w’, toggle fullscreen using ‘o’ and exit using ESC. The FPS is displayed in the titlebar.
  • WxWidgets C++ Project – Initializes a WxWidgets based app with an empty frame.

Programming , , ,

Nethack on OS X 10.6 (Snow Leopard)

November 13th, 2009

O.K. So, this is kind of a followup to a previous post I did about how I like to setup Nethack on my Mac. However, more recently, some of the patches I had used stopped working on later versions of Mac OS (10.5 and 10.6). So I spent a bit of time looking into this today and I got some positive results. (update: I think the problem I had with Menucolor compiling was that it didn’t like the regexp method – I changed this to simply use the wildcard matching.)

Nethack with Status Colors and Menu Colors

Nethack with Status Colors and Menu Colors

Unfortunately, because the two patches I’m applying have resulting conflicts- it meant manually applying the patches to the source code in some cases (also: I’m lazy). I, therefore, don’t have an elegant method of actually applying the two patches that I can pass on. What I am doing instead is providing two things: The complete refined archive of the patched Nethack source which should be ready-to-compile on OS 10.6; And also the .diff file produced from a vanilla copy of the source and my own patched version. I will also provide my new updated nethackrc file. (ok… 3 things :-) )

Here’s some details about the setup this provides:

  1. The Status Colors patch is applied. This is a configurable patch allowing you to color code status effects – hunger, blindness, HP, Gold, AC, etc. It’s very, very cool! :-)
  2. Menucolors patch applied. This is a configurable patch that let’s you apply colors to popup menus. e.g. inventory items can be red for cursed, green for blessed, etc. Again, this patch is very neat!
  3. The initial configuration for getting Nethack to build on mac has been taken care of.

So Here are the links to get everything up and running. I should say at this point that this stuff works on my machine and YMMV. If something is broken and you want my to take a look at it just leave a comment of send an email – I’ll try to fix it if I have time. You may also want to dig through the changes in the patch.

  1. nethack-3.4.3-patched.zip
  2. nh343-_menustatus_orig.diff
  3. .nethackrc

I hope this is useful for someone who wants a nice shiny setup of Nethack on Snow Leopard. :-)

Programming , , , , ,

Snow Leopard can DIAF

September 16th, 2009

Hurray! Apple fanboys should be pleased with the release of OS X, version 10.6. Snow Leopard panders to their desire for an all Apple platform. For the rest of us sensible users, Apple have screwed the pooch.

Okay, we have new shiny toys like Quicktime X and – well, that’s about the height of noticeable changes. I’m all for enhancing the user experience, but in this case, in my opinion, it has come at the expense of developer comfort.

What I’m referring to here is the lack of Java support in the new XCode 3.2. I’ve always felt that XCode was a fairly elegant environment for writing all C/C++, Java and Objective-C projects. So- why, Apple, would you arbitrarily drop support for a language? Out of spite? You didn’t even drop support – you just made it frigging irritating to use. Do you enjoy kicking your users in the nuts with each new release?

I’m not even surprised at this stage. I guess I could add the XCode templates back in manually but I’m more in favour of adopting a more portable command line build process… It seems the best way to get away from Apple’s user abuse.

Programming , , , ,

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 , , , , ,

Nethack Settings for OS X

November 22nd, 2008

There is now an update to this post.

This is a quick tutorial post for anyone requiring convenient pre-configured Nethack Files. Nethack comes from a tradition of Hack’n'slash adventure games known as Roguelikes. They are similar to text based adventures in that, originally, grapics were rendered using ASCII characters. This is still a popular way to play the games. This is the end of the similarity, though, as the gameplay is more like that of Dungeons & Dragons or other Role Playing Games.

Personally, I enjoy using ASCII graphics because I think it makes the games more readable, imaginative and because nicely rendered fonts just look better than tiny 16×16 tiles. (How can a mighty dragon be crammed into a small 16×16 bitmap?)

Nethack in Terminal.app

Nethack in Terminal.app

So, here are some things I have done to pretty up Nethack a bit for OS X. Many other people, I’m sure, use a similar setup, and many others probably differ. For added convenience I’ll include my configuration files for download.

  1. Build Nethack from source. There is a good tutorial for this on the Nethack Wiki
  2. Apply the following Source Code patches: hpmon, Menucolors and rebuild. (They provide groovy abilities like menu highlighting for easy reading)
  3. Download a copy of my .nethackrc to configure- this already has decent settings for Menucolors and well as some traditional options: (keybindings, graphics mode, etc). You can get the file here: nethackrc (save it into your home directory as .nethackrc)
  4. Make a custom Terminal.app config ad export it. I use Monaco 18pt font, no-blink cursor, autorun /usr/games/nethack. You can grab a copy of this file here: nethack
Hopefully this has helped a little in setting up classic command line Nethack on OS X (and making it look a little prettier).

Gaming, Self , , , ,

Weak Type Systems

November 8th, 2008

I read an article a while back by Steve Yegge.  In case you don’t know, Steve is a programmer.  He is also a blogger.  A big blogger.  I don’t mean simply that he really likes to blog- I mean he writes big blog entries. He also tends to write very good blog entries and if you have an interest in programming or business or just want a good read then I highly recommend checking him out.

I read an article.  It didn’t leave me with the warm glow of a satisfying read.  It left me with a guilty, hollow feeling.  This article might have been called “Stuart’s Story: The death of typing”, or “Stuart, I know all about your lazy habits.” Or… you get the picture.  The point is, Steve was talking directly to me.

You see, I’m also a programmer.

I’m a programmer and it’s been about 10 years since I fell of the touch-typing wagon.

However, I’m not one to stay disheartened.  As of this moment I intend to take the advice given in the article and re-learn to touch type.  Not only that, but I also intend to do it using the Dvorak layout.  Qwerty isn’t a standard- it’s a widely adopted flaw, designed to slow typists to a speed that wouldn’t jam those mechanical typewriters.

In the hopes that my own short experience so far might benefit others I present the steps I’m taking to re-aquaint myself with touch typing:

  1. I have blanked the keys on my MacBook – and will do so on any other keyboard I own now.  Here’s a fairly cheap and effective way to do it.  Buy stickers from this site (their P&P is reasonable, even to the UK) – 4Keyboard Blank Stickers. The resulting keyboard looks like this: Blanked MacBook
  2. Get a typing tutor, preferably one that will do focussed drills rather than just punching in random strings.  I’m currently trying to demo of Ten Thumbs Type Tutor. Which is rather fun and features a Viking!  (It’s not free but there is a 10 day trial.  So far I’m rather impressed)
  3. Learn the drills and common patterns.  Whether on Qwerty or Dvorak, learn patterns like: the, ion, uous, at, in, etc. Building up a good vocabulary of common use strings will help to build up an acceptable speed early on, allowing you to adopt quicker.  (I think I recall Steve mentioning this in his post.)
  4. Practice.  This is the stage I am at and will probably be at for a good while to come.  I trust Steve when he says that it only takes about 30 minutes a day to get reasonably proficient – but it goes without saying that this takes a bit of dedication.

This was a useful post for me to lay down some goals for the future.  I hope anyone reading found it interesting too.

Peace.

Self , , ,

Document Entropy

November 7th, 2008

While my MacBook typically runs as happily as ever, I have started to notice that various folders are becoming somewhat messy.  There is no explanation other than the laziness of the user.

My ‘documents’ folder, for example, is fully of unclassified .c, .h, .tex, .pdf – all the files of the day with cryptic titles to boot.  Such examples include: al_7.aux and booktest.log.  Months on I can’t remember what happened to the ‘Als’ which preceded number 7, nor can I remember which book I was testing.  In short, I really need to clean up my documents.

I’m somewhat reluctant to start though in case I decide to buy OS 10.5 soon – *gasp* yes, ok… My ‘last-year’ MacBook is still running Tiger.  I will join the 21st century yet!

Self, Software , , ,

got Mac

September 3rd, 2007

I finally did something I should have done a long time ago and bought a macBook. It’s wonderful – like Linux only hardware works; like Windows only it doesn’t look like crap…and hardware works.A lot of thing on Windows I had started to take for granted: “If I want to do this, I must first do that” or “This works when that is already running” but OSX seems to take care of a lot of this stuff under the bonnet, so to speak.

The Mac came with a plethora of software for it’s internal peripherals and features – web browsing, photo software, iTunes, quicktime – pretty much what you’d expect. Further to this the apple development tools is a free package adding a good gigabyte of extra tools, SDKs, documentation and utilities. Add to that Mactex and Emacs and you’ve pretty much got a complete development station.Package management is dead easy – in most cases simply dragging the application into the ‘applications’ directory.

The User Interface is very smooth without being obnoxious. I for one am very fond of seeing windows slide off the screen and back in… my brain seems to comprehend window management when bits and pieces move around for it.If I have but one complaint, it’s that I seem to require almost an entire installation of Gnome just to get Gimp up and running: It may be time to explore the image editing market again.

[edit] It turns out there is now a rather nice Gimp package for OS X.

Computers, Development, Geek, fun, life , , , ,